use of org.gephi.graph.api.Table in project gephi by gephi.
the class DataTableTopComponent method prepareColumnManipulatorsButtons.
/**
* Creates the buttons that call the AttributeColumnManipulators.
*/
private void prepareColumnManipulatorsButtons() {
Table table;
Column[] columns;
if (isShowingNodesTable()) {
table = graphModel.getNodeTable();
} else {
table = graphModel.getEdgeTable();
}
columns = getTableAvailableColumnsModel(table).getAvailableColumns();
DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
AttributeColumnsManipulator[] manipulators = dlh.getAttributeColumnsManipulators();
JCommandButtonStrip currentButtonGroup = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);
currentButtonGroup.setDisplayState(CommandButtonDisplayState.BIG);
Integer lastManipulatorType = null;
for (AttributeColumnsManipulator acm : manipulators) {
if (lastManipulatorType == null) {
lastManipulatorType = acm.getType();
}
if (lastManipulatorType != acm.getType()) {
columnManipulatorsPanel.add(currentButtonGroup);
currentButtonGroup = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);
currentButtonGroup.setDisplayState(CommandButtonDisplayState.BIG);
}
lastManipulatorType = acm.getType();
currentButtonGroup.add(prepareJCommandButton(graphModel, table, columns, acm));
}
columnManipulatorsPanel.add(currentButtonGroup);
}
use of org.gephi.graph.api.Table in project gephi by gephi.
the class DataTableTopComponent method exportCurrentTable.
@Override
public void exportCurrentTable(ExportMode exportMode) {
Table table;
String fileName = prepareTableExportFileName();
boolean edgesTable;
if (isShowingNodesTable()) {
table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable();
edgesTable = false;
fileName += " [Nodes]";
} else {
table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getEdgeTable();
edgesTable = true;
fileName += " [Edges]";
}
fileName += ".csv";
switch(exportMode) {
case CSV:
showCSVExportUI(table, edgesTable, fileName);
break;
}
}
use of org.gephi.graph.api.Table in project gephi by gephi.
the class DataLaboratoryPersistenceProvider method readDataTablesModel.
private void readDataTablesModel(XMLStreamReader reader, Workspace workspace) throws XMLStreamException {
GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
Table nodesTable = graphModel.getNodeTable();
Table edgesTable = graphModel.getEdgeTable();
DataTablesModel dataTablesModel = workspace.getLookup().lookup(DataTablesModel.class);
if (dataTablesModel == null) {
workspace.add(dataTablesModel = new DataTablesModel(workspace));
}
AvailableColumnsModel nodeColumns = dataTablesModel.getNodeAvailableColumnsModel();
nodeColumns.removeAllColumns();
AvailableColumnsModel edgeColumns = dataTablesModel.getEdgeAvailableColumnsModel();
edgeColumns.removeAllColumns();
boolean end = false;
while (reader.hasNext() && !end) {
Integer eventType = reader.next();
if (eventType.equals(XMLEvent.START_ELEMENT)) {
String name = reader.getLocalName();
if (NODE_COLUMN.equalsIgnoreCase(name)) {
Integer id = Integer.parseInt(reader.getAttributeValue(null, "id"));
Column column = nodesTable.getColumn(id);
if (column != null) {
nodeColumns.addAvailableColumn(column);
}
} else if (EDGE_COLUMN.equalsIgnoreCase(name)) {
Integer id = Integer.parseInt(reader.getAttributeValue(null, "id"));
Column column = edgesTable.getColumn(id);
if (column != null) {
edgeColumns.addAvailableColumn(column);
}
}
} else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
if (AVAILABLE_COLUMNS.equalsIgnoreCase(reader.getLocalName())) {
end = true;
}
}
}
}
use of org.gephi.graph.api.Table in project gephi by gephi.
the class ClusteringCoefficient method initializeAttributeColunms.
private Column initializeAttributeColunms(GraphModel graphModel) {
if (graphModel == null) {
return null;
}
Table nodeTable = graphModel.getNodeTable();
Column clusteringCol = nodeTable.getColumn("clustering");
if (clusteringCol == null) {
clusteringCol = nodeTable.addColumn("clustering", "Clustering Coefficient", Double.class, new Double(0));
}
return clusteringCol;
}
use of org.gephi.graph.api.Table in project gephi by gephi.
the class SearchReplaceUI method showSearchResult.
private void showSearchResult() {
if (searchResult != null) {
Table table;
Object value;
if (mode == Mode.NODES_TABLE) {
Node node = searchResult.getFoundNode();
dataTablesController.setNodeTableSelection(new Node[] { node });
if (!dataTablesController.isNodeTableMode()) {
dataTablesController.selectNodesTable();
}
table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable();
value = node.getAttribute(table.getColumn(searchResult.getFoundColumnIndex()));
} else {
Edge edge = searchResult.getFoundEdge();
dataTablesController.setEdgeTableSelection(new Edge[] { edge });
if (!dataTablesController.isEdgeTableMode()) {
dataTablesController.selectEdgesTable();
}
table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getEdgeTable();
value = edge.getAttribute(table.getColumn(searchResult.getFoundColumnIndex()));
}
TimeFormat timeFormat = table.getGraph().getModel().getTimeFormat();
DateTimeZone timeZone = table.getGraph().getModel().getTimeZone();
String columnName;
if (mode == Mode.NODES_TABLE) {
columnName = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable().getColumn(searchResult.getFoundColumnIndex()).getTitle();
} else {
columnName = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getEdgeTable().getColumn(searchResult.getFoundColumnIndex()).getTitle();
}
StringBuilder sb = new StringBuilder();
sb.append("<html>");
sb.append(NbBundle.getMessage(SearchReplaceUI.class, "SearchReplaceUI.column", HTMLEscape.stringToHTMLString(columnName)));
sb.append("<br>");
if (value != null) {
String text = AttributeUtils.print(value, timeFormat, timeZone);
sb.append(HTMLEscape.stringToHTMLString(text.substring(0, searchResult.getStart())));
sb.append("<font color='blue'>");
sb.append(HTMLEscape.stringToHTMLString(text.substring(searchResult.getStart(), searchResult.getEnd())));
sb.append("</font>");
sb.append(HTMLEscape.stringToHTMLString(text.substring(searchResult.getEnd())));
} else {
sb.append("<font color='blue'>null</font>");
}
sb.append("</html>");
resultText.setText(sb.toString());
} else {
JOptionPane.showMessageDialog(null, NbBundle.getMessage(SearchReplaceUI.class, "SearchReplaceUI.not.found", searchText.getText()));
resultText.setText("");
}
}
Aggregations