Search in sources :

Example 1 with VisualizationController

use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.

the class FilterControllerImpl method selectVisible.

@Override
public void selectVisible(Query query) {
    if (query != null && model.getCurrentQuery() == query && model.isSelecting()) {
        return;
    }
    model.setSelecting(query != null);
    model.setCurrentQuery(query);
    if (model.getFilterThread() != null) {
        model.getFilterThread().setRunning(false);
        model.setFilterThread(null);
    }
    model.getGraphModel().setVisibleView(null);
    if (model.getCurrentResult() != null) {
        model.getGraphModel().destroyView(model.getCurrentResult());
        model.setCurrentResult(null);
    }
    if (query != null) {
        FilterThread filterThread = new FilterThread(model);
        model.setFilterThread(filterThread);
        filterThread.setRootQuery((AbstractQueryImpl) query);
        filterThread.start();
    } else {
        VisualizationController visController = Lookup.getDefault().lookup(VisualizationController.class);
        if (visController != null) {
            visController.selectNodes(null);
        }
    }
}
Also used : VisualizationController(org.gephi.visualization.api.VisualizationController)

Example 2 with VisualizationController

use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.

the class FilterThread method select.

private void select(AbstractQueryImpl query) {
    FilterProcessor processor = new FilterProcessor();
    GraphModel graphModel = model.getGraphModel();
    Graph result = processor.process((AbstractQueryImpl) query, graphModel);
    if (running) {
        VisualizationController visController = Lookup.getDefault().lookup(VisualizationController.class);
        if (visController != null) {
            visController.selectNodes(result.getNodes().toArray());
            visController.selectEdges(result.getEdges().toArray());
        }
        GraphView view = result.getView();
        model.setCurrentResult(view);
    } else {
        //destroy view
        graphModel.destroyView(result.getView());
    }
}
Also used : Graph(org.gephi.graph.api.Graph) VisualizationController(org.gephi.visualization.api.VisualizationController) GraphModel(org.gephi.graph.api.GraphModel) GraphView(org.gephi.graph.api.GraphView)

Example 3 with VisualizationController

use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.

the class EdgeLabelBuilder method getItems.

@Override
public Item[] getItems(Graph graph) {
    boolean useTextData = false;
    for (Edge e : graph.getEdges()) {
        TextProperties textData = e.getTextProperties();
        if (textData != null && textData.getText() != null && !textData.getText().isEmpty()) {
            useTextData = true;
        }
    }
    //Build text
    VisualizationController vizController = Lookup.getDefault().lookup(VisualizationController.class);
    Column[] edgeColumns = vizController != null ? vizController.getEdgeTextColumns() : null;
    List<Item> items = new ArrayList<>();
    for (Edge e : graph.getEdges()) {
        EdgeLabelItem labelItem = new EdgeLabelItem(e);
        String label = getLabel(e, edgeColumns, graph.getView());
        labelItem.setData(EdgeLabelItem.LABEL, label);
        TextProperties textData = e.getTextProperties();
        if (textData != null && useTextData) {
            if (textData.getAlpha() != 0) {
                labelItem.setData(EdgeLabelItem.COLOR, textData.getColor());
            }
            //                labelItem.setData(EdgeLabelItem.WIDTH, textData.getWidth());
            //                labelItem.setData(EdgeLabelItem.HEIGHT, textData.getHeight());
            labelItem.setData(EdgeLabelItem.SIZE, textData.getSize());
            labelItem.setData(EdgeLabelItem.VISIBLE, textData.isVisible());
            if (textData.isVisible() && textData.getText() != null && !textData.getText().isEmpty()) {
                items.add(labelItem);
            }
        } else if (label != null && !label.isEmpty()) {
            items.add(labelItem);
        }
    }
    return items.toArray(new Item[0]);
}
Also used : Item(org.gephi.preview.api.Item) EdgeLabelItem(org.gephi.preview.plugin.items.EdgeLabelItem) VisualizationController(org.gephi.visualization.api.VisualizationController) ArrayList(java.util.ArrayList) EdgeLabelItem(org.gephi.preview.plugin.items.EdgeLabelItem)

Example 4 with VisualizationController

use of org.gephi.visualization.api.VisualizationController in project gephi by gephi.

the class NodeLabelBuilder method getItems.

@Override
public Item[] getItems(Graph graph) {
    boolean useTextData = false;
    for (Node n : graph.getNodes()) {
        TextProperties textData = n.getTextProperties();
        if (textData != null && textData.getText() != null && !textData.getText().isEmpty()) {
            useTextData = true;
        }
    }
    //Build text
    VisualizationController vizController = Lookup.getDefault().lookup(VisualizationController.class);
    Column[] nodeColumns = vizController != null ? vizController.getNodeTextColumns() : null;
    List<Item> items = new ArrayList<>();
    for (Node n : graph.getNodes()) {
        NodeLabelItem labelItem = new NodeLabelItem(n);
        String label = getLabel(n, nodeColumns, graph.getView());
        labelItem.setData(NodeLabelItem.LABEL, label);
        TextProperties textData = n.getTextProperties();
        if (textData != null && useTextData) {
            if (textData.getR() != -1) {
                labelItem.setData(NodeLabelItem.COLOR, new Color((int) (textData.getR() * 255), (int) (textData.getG() * 255), (int) (textData.getB() * 255), (int) (textData.getAlpha() * 255)));
            }
            //                labelItem.setData(NodeLabelItem.WIDTH, textData.getWidth());
            //                labelItem.setData(NodeLabelItem.HEIGHT, textData.getHeight());
            labelItem.setData(NodeLabelItem.SIZE, textData.getSize());
            labelItem.setData(NodeLabelItem.VISIBLE, textData.isVisible());
            labelItem.setData(NodeLabelItem.LABEL, textData.getText());
            if (textData.isVisible() && label != null && !label.isEmpty()) {
                items.add(labelItem);
            }
        } else if (label != null && !label.isEmpty()) {
            items.add(labelItem);
        }
    }
    return items.toArray(new Item[0]);
}
Also used : NodeLabelItem(org.gephi.preview.plugin.items.NodeLabelItem) Item(org.gephi.preview.api.Item) NodeLabelItem(org.gephi.preview.plugin.items.NodeLabelItem) Column(org.gephi.graph.api.Column) VisualizationController(org.gephi.visualization.api.VisualizationController) Node(org.gephi.graph.api.Node) Color(java.awt.Color) ArrayList(java.util.ArrayList) TextProperties(org.gephi.graph.api.TextProperties)

Aggregations

VisualizationController (org.gephi.visualization.api.VisualizationController)4 ArrayList (java.util.ArrayList)2 Item (org.gephi.preview.api.Item)2 Color (java.awt.Color)1 Column (org.gephi.graph.api.Column)1 Graph (org.gephi.graph.api.Graph)1 GraphModel (org.gephi.graph.api.GraphModel)1 GraphView (org.gephi.graph.api.GraphView)1 Node (org.gephi.graph.api.Node)1 TextProperties (org.gephi.graph.api.TextProperties)1 EdgeLabelItem (org.gephi.preview.plugin.items.EdgeLabelItem)1 NodeLabelItem (org.gephi.preview.plugin.items.NodeLabelItem)1