Examples of HierarchicalGraph


Examples of org.gephi.graph.api.HierarchicalGraph

        }
    }

    public Node[] getAvailableGroupsToMoveNodes(Node[] nodes) {
        if (canGroupNodes(nodes)) {
            HierarchicalGraph hg = getHierarchicalGraph();
            Set<Node> nodesSet = new HashSet<Node>();
            nodesSet.addAll(Arrays.asList(nodes));

            //All have the same parent, get children and check what of them are groups and are not in the nodes array:
            Node parent = hg.getParent(nodes[0]);
            Node[] possibleGroups;
            //If no parent, get nodes at level 0:
            if (parent != null) {
                possibleGroups = hg.getChildren(parent).toArray();
            } else {
                possibleGroups = hg.getNodes(0).toArray();
            }
            ArrayList<Node> availableGroups = new ArrayList<Node>();

            for (Node n : possibleGroups) {
                if (!nodesSet.contains(n) && getNodeChildrenCount(hg, n) > 0) {
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

            return null;
        }
    }

    public boolean canMoveNodeToGroup(Node node, Node group) {
        HierarchicalGraph hg = getHierarchicalGraph();
        return node != group && hg.getParent(node) == hg.getParent(group) && canUngroupNode(group);
    }
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

        return node != group && hg.getParent(node) == hg.getParent(group) && canUngroupNode(group);
    }

    public boolean removeNodeFromGroup(Node node) {
        if (isNodeInGroup(node)) {
            HierarchicalGraph hg = getHierarchicalGraph();
            Node parent = hg.getParent(node);
            hg.readLock();
            int childrenCount = hg.getChildrenCount(parent);
            hg.readUnlock();
            if (childrenCount == 1) {
                hg.ungroupNodes(parent);//Break group when the last child is removed.
            } else {
                hg.removeFromGroup(node);
            }
            return true;
        } else {
            return false;
        }
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

            removeNodeFromGroup(n);
        }
    }

    public boolean isNodeInGroup(Node node) {
        HierarchicalGraph hg = getHierarchicalGraph();
        return hg.getParent(node) != null;
    }
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

                    //Attributes columns
                    final AttributeColumn[] cols = nodeAvailableColumnsModel.getAvailableColumns();

                    //Nodes from DHNS
                    HierarchicalGraph graph;
                    if (visibleOnly) {
                        graph = graphModel.getHierarchicalGraphVisible();
                    } else {
                        graph = graphModel.getHierarchicalGraph();
                    }
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

            }
        }
    }

    public void exportToColumn(String title, Query query) {
        HierarchicalGraph result;
        if (model.getCurrentQuery() == query) {
            GraphView view = model.getCurrentResult();
            if (view != null) {
                return;
            }
            result = model.getGraphModel().getHierarchicalGraph(view);
        } else {
            FilterProcessor processor = new FilterProcessor();
            GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
            result = (HierarchicalGraph) processor.process((AbstractQueryImpl) query, graphModel);
        }
        AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
        AttributeColumn nodeCol = am.getNodeTable().getColumn("filter_" + title);
        if (nodeCol == null) {
            nodeCol = am.getNodeTable().addColumn("filter_" + title, title, AttributeType.BOOLEAN, AttributeOrigin.COMPUTED, Boolean.FALSE);
        }
        AttributeColumn edgeCol = am.getEdgeTable().getColumn("filter_" + title);
        if (edgeCol == null) {
            edgeCol = am.getEdgeTable().addColumn("filter_" + title, title, AttributeType.BOOLEAN, AttributeOrigin.COMPUTED, Boolean.FALSE);
        }
        result.readLock();
        for (Node n : result.getNodes()) {
            n.getNodeData().getAttributes().setValue(nodeCol.getIndex(), Boolean.TRUE);
        }
        for (Edge e : result.getEdgesAndMetaEdges()) {
            e.getEdgeData().getAttributes().setValue(edgeCol.getIndex(), Boolean.TRUE);
        }
        result.readUnlock();
        //StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(FilterControllerImpl.class, "FilterController.exportToColumn.status", title));
    }
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

                    //Attributes columns
                    final AttributeColumn[] cols = edgeAvailableColumnsModel.getAvailableColumns();

                    //Edges from DHNS
                    HierarchicalGraph graph;
                    if (visibleOnly) {
                        graph = graphModel.getHierarchicalGraphVisible();
                    } else {
                        graph = graphModel.getHierarchicalGraph();
                    }
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

        result.readUnlock();
        //StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(FilterControllerImpl.class, "FilterController.exportToColumn.status", title));
    }

    public void exportToNewWorkspace(Query query) {
        HierarchicalGraph result;
        if (model.getCurrentQuery() == query) {
            GraphView view = model.getCurrentResult();
            if (view == null) {
                return;
            }
            result = model.getGraphModel().getHierarchicalGraph(view);
        } else {
            FilterProcessor processor = new FilterProcessor();
            GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
            result = (HierarchicalGraph) processor.process((AbstractQueryImpl) query, graphModel);
        }

        final HierarchicalGraph graphView = result;
        new Thread(new Runnable() {

            public void run() {
                ProgressTicketProvider progressProvider = Lookup.getDefault().lookup(ProgressTicketProvider.class);
                ProgressTicket ticket = null;
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

            }
        }, "Export filter to workspace").start();
    }

    public void exportToLabelVisible(Query query) {
        HierarchicalGraph result;
        if (model.getCurrentQuery() == query) {
            GraphView view = model.getCurrentResult();
            if (view == null) {
                return;
            }
            result = model.getGraphModel().getHierarchicalGraph(view);
        } else {
            FilterProcessor processor = new FilterProcessor();
            result = (HierarchicalGraph) processor.process((AbstractQueryImpl) query, model.getGraphModel());
        }
        HierarchicalGraph fullHGraph = model.getGraphModel().getHierarchicalGraph();
        fullHGraph.readLock();
        for (Node n : fullHGraph.getNodes()) {
            boolean inView = n.getNodeData().getNode(result.getView().getViewId()) != null;
            n.getNodeData().getTextData().setVisible(inView);
        }
        for (Edge e : fullHGraph.getEdgesAndMetaEdges()) {
            boolean inView = result.contains(e);
            e.getEdgeData().getTextData().setVisible(inView);
        }
        fullHGraph.readUnlock();
    }
View Full Code Here

Examples of org.gephi.graph.api.HierarchicalGraph

    private TimeInterval visibleInterval;

    public boolean execute() {
        attributeModel = workspace.getLookup().lookup(AttributeModel.class);
        graphModel = workspace.getLookup().lookup(GraphModel.class);
        HierarchicalGraph graph = null;
        if (exportVisible) {
            graph = graphModel.getHierarchicalGraphVisible();
        } else {
            graph = graphModel.getHierarchicalGraph();
        }
        DynamicModel dynamicModel = workspace.getLookup().lookup(DynamicModel.class);
        visibleInterval = dynamicModel != null && exportVisible ? dynamicModel.getVisibleInterval() : new TimeInterval();
        try {
            exportData(createDocument(), graph, attributeModel);
        } catch (Exception e) {
            graph.readUnlockAll();
            throw new RuntimeException(e);
        }

        return !cancel;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.