use of org.gephi.graph.api.GraphController in project gephi-plugins-bootcamp by gephi.
the class NodesZOrderingUI method createComboBoxModel.
private ComboBoxModel createComboBoxModel() {
DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
//Add a element for no column selected
comboBoxModel.addElement(NO_SELECTION);
//Get the current attribute columns in the current workspace
GraphController attributeController = Lookup.getDefault().lookup(GraphController.class);
GraphModel attributeModel = attributeController.getGraphModel();
for (Column col : attributeModel.getNodeTable()) {
if (AttributeUtils.isNumberType(col.getTypeClass())) {
comboBoxModel.addElement(col);
}
}
return comboBoxModel;
}
use of org.gephi.graph.api.GraphController in project gephi-plugins-bootcamp by gephi.
the class FindTool method select.
@Override
public void select() {
//Get current visible graph
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
Graph graph = graphController.getGraphModel().getGraphVisible();
//Build the autocomplete data. A simple map from node's label
graph.readLock();
data = new HashMap<String, Node>();
for (Node n : graph.getNodes()) {
String label = n.getLabel();
String id = n.getId().toString();
if (label != null) {
if (!label.isEmpty()) {
data.put(label, n);
}
} else if (id != null && !id.isEmpty()) {
data.put(id, n);
}
}
graph.readUnlock();
}
use of org.gephi.graph.api.GraphController in project gephi by gephi.
the class LayoutModelImpl method getLayout.
@Override
public Layout getLayout(LayoutBuilder layoutBuilder) {
Layout layout = layoutBuilder.buildLayout();
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel(workspace);
layout.setGraphModel(graphModel);
selectedBuilder = layoutBuilder;
layout.resetPropertiesValues();
return layout;
}
use of org.gephi.graph.api.GraphController in project gephi by gephi.
the class LabelAttributesPanel method refresh.
private void refresh() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
List<Column> availableColumns = new ArrayList<>();
List<Column> selectedColumns = new ArrayList<>();
AttributesCheckBox[] target;
if (elementButtonGroup.getSelection() == nodesToggleButton.getModel()) {
for (Column c : graphController.getGraphModel().getNodeTable()) {
if (!c.isProperty()) {
availableColumns.add(c);
} else if (showProperties && c.isProperty() && !c.getId().equals("timeset")) {
availableColumns.add(c);
}
}
if (textModel.getNodeTextColumns() != null) {
selectedColumns = Arrays.asList(textModel.getNodeTextColumns());
}
nodeCheckBoxs = new AttributesCheckBox[availableColumns.size()];
target = nodeCheckBoxs;
} else {
for (Column c : graphController.getGraphModel().getEdgeTable()) {
if (!c.isProperty()) {
availableColumns.add(c);
} else if (showProperties) {
if (showProperties && c.isProperty() && !c.getId().equals("timeset")) {
availableColumns.add(c);
}
}
}
if (textModel.getEdgeTextColumns() != null) {
selectedColumns = Arrays.asList(textModel.getEdgeTextColumns());
}
edgeCheckBoxs = new AttributesCheckBox[availableColumns.size()];
target = edgeCheckBoxs;
}
contentPanel.removeAll();
contentPanel.setLayout(new MigLayout("", "[pref!]"));
for (int i = 0; i < availableColumns.size(); i++) {
Column column = availableColumns.get(i);
AttributesCheckBox c = new AttributesCheckBox(column, selectedColumns.contains(column));
target[i] = c;
contentPanel.add(c.getCheckBox(), "wrap");
}
contentPanel.revalidate();
contentPanel.repaint();
}
use of org.gephi.graph.api.GraphController in project gephi by gephi.
the class CopyOrMoveToWorkspaceSubItem method copyToWorkspace.
public boolean copyToWorkspace(Workspace workspace) {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Workspace currentWorkspace = projectController.getCurrentWorkspace();
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel;
if (workspace == null) {
workspace = Lookup.getDefault().lookup(ProjectControllerUI.class).newWorkspace();
graphModel = graphController.getGraphModel(workspace);
GraphModel currentGraphModel = graphController.getGraphModel(currentWorkspace);
graphModel.setConfiguration(currentGraphModel.getConfiguration());
graphModel.setTimeFormat(currentGraphModel.getTimeFormat());
graphModel.setTimeZone(currentGraphModel.getTimeZone());
} else {
graphModel = graphController.getGraphModel(workspace);
}
try {
graphModel.bridge().copyNodes(nodes);
return true;
} catch (Exception e) {
String error = NbBundle.getMessage(CopyOrMoveToWorkspace.class, "GraphContextMenu_CopyOrMoveToWorkspace_ConfigurationNotCompatible");
String title = NbBundle.getMessage(CopyOrMoveToWorkspace.class, "GraphContextMenu_CopyOrMoveToWorkspace_ConfigurationNotCompatible_Title");
JOptionPane.showMessageDialog(null, error, title, JOptionPane.ERROR_MESSAGE);
return false;
}
}
Aggregations