Search in sources :

Example 21 with GraphController

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;
}
Also used : Column(org.gephi.graph.api.Column) GraphModel(org.gephi.graph.api.GraphModel) GraphController(org.gephi.graph.api.GraphController)

Example 22 with GraphController

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();
}
Also used : Graph(org.gephi.graph.api.Graph) Node(org.gephi.graph.api.Node) GraphController(org.gephi.graph.api.GraphController)

Example 23 with GraphController

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;
}
Also used : Layout(org.gephi.layout.spi.Layout) GraphModel(org.gephi.graph.api.GraphModel) GraphController(org.gephi.graph.api.GraphController)

Example 24 with GraphController

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();
}
Also used : Column(org.gephi.graph.api.Column) MigLayout(net.miginfocom.swing.MigLayout) ArrayList(java.util.ArrayList) GraphController(org.gephi.graph.api.GraphController)

Example 25 with GraphController

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;
    }
}
Also used : GraphModel(org.gephi.graph.api.GraphModel) ProjectController(org.gephi.project.api.ProjectController) GraphController(org.gephi.graph.api.GraphController) Workspace(org.gephi.project.api.Workspace)

Aggregations

GraphController (org.gephi.graph.api.GraphController)28 GraphModel (org.gephi.graph.api.GraphModel)19 Graph (org.gephi.graph.api.Graph)12 Node (org.gephi.graph.api.Node)9 Edge (org.gephi.graph.api.Edge)7 Column (org.gephi.graph.api.Column)5 TimeFormat (org.gephi.graph.api.TimeFormat)4 MouseClickEventListener (org.gephi.tools.spi.MouseClickEventListener)3 NodeClickEventListener (org.gephi.tools.spi.NodeClickEventListener)3 ArrayList (java.util.ArrayList)2 AbstractShortestPathAlgorithm (org.gephi.algorithms.shortestpath.AbstractShortestPathAlgorithm)2 BellmanFordShortestPathAlgorithm (org.gephi.algorithms.shortestpath.BellmanFordShortestPathAlgorithm)2 DijkstraShortestPathAlgorithm (org.gephi.algorithms.shortestpath.DijkstraShortestPathAlgorithm)2 AttributeColumnsController (org.gephi.datalab.api.AttributeColumnsController)2 GraphFactory (org.gephi.graph.api.GraphFactory)2 GraphView (org.gephi.graph.api.GraphView)2 DynamicStatistics (org.gephi.statistics.spi.DynamicStatistics)2 NotifyDescriptor (org.openide.NotifyDescriptor)2 Color (java.awt.Color)1 Font (java.awt.Font)1