Package org.gephi.graph.api

Examples of org.gephi.graph.api.HierarchicalGraph


     *
     * @param graphModel
     * @param attributeModel
     */
    public void execute(GraphModel graphModel, AttributeModel attributeModel) {
        HierarchicalGraph graph = null;
        if (isDirected) {
            graph = graphModel.getHierarchicalDirectedGraphVisible();
        } else {
            graph = graphModel.getHierarchicalUndirectedGraphVisible();
        }
View Full Code Here


    private static final String ELEMENT_VALUE = "attvalue";

    public void writeRows(XMLStreamWriter writer, GraphModel graphModel) throws XMLStreamException {
        writer.writeStartElement(ELEMENT_ROWS);

        HierarchicalGraph hierarchicalGraph = graphModel.getHierarchicalGraph();
        for (Node node : hierarchicalGraph.getNodesTree()) {
            if (node.getNodeData().getAttributes() != null && node.getNodeData().getAttributes() instanceof AttributeRowImpl) {
                AttributeRowImpl row = (AttributeRowImpl) node.getNodeData().getAttributes();
                writer.writeStartElement(ELEMENT_NODE_ROW);
                writer.writeAttribute("for", String.valueOf(node.getId()));
                if (writeRow(writer, row)) {
                    writer.writeEndElement();
                }
            }
        }

        for (Node node : hierarchicalGraph.getNodesTree()) {
            for (Edge edge : hierarchicalGraph.getEdges(node)) {
                if (edge.getEdgeData().getAttributes() != null && edge.getEdgeData().getAttributes() instanceof AttributeRowImpl) {
                    AttributeRowImpl row = (AttributeRowImpl) edge.getEdgeData().getAttributes();
                    writer.writeStartElement(ELEMENT_EDGE_ROW);
                    writer.writeAttribute("for", String.valueOf(edge.getId()));
                    if (writeRow(writer, row)) {
View Full Code Here

        writer.writeEndElement();
    }

    public void readRows(XMLStreamReader reader, GraphModel graphModel, AbstractAttributeModel attributeModel) throws XMLStreamException {
        HierarchicalGraph hierarchicalGraph = graphModel.getHierarchicalGraph();

        boolean end = false;
        while (reader.hasNext() && !end) {
            int type = reader.next();

            switch (type) {
                case XMLStreamReader.START_ELEMENT:
                    String name = reader.getLocalName();
                    if (ELEMENT_NODE_ROW.equalsIgnoreCase(name)) {
                        int id = Integer.parseInt(reader.getAttributeValue(null, "for"));
                        Node node = hierarchicalGraph.getNode(id);
                        if (node.getNodeData().getAttributes() != null && node.getNodeData().getAttributes() instanceof AttributeRowImpl) {
                            AttributeRowImpl row = (AttributeRowImpl) node.getNodeData().getAttributes();
                            readRow(reader, attributeModel, attributeModel.getNodeTable(), row);
                        }
                    } else if (ELEMENT_EDGE_ROW.equalsIgnoreCase(name)) {
                        int id = Integer.parseInt(reader.getAttributeValue(null, "for"));
                        Edge edge = hierarchicalGraph.getEdge(id);
                        if (edge.getEdgeData().getAttributes() != null && edge.getEdgeData().getAttributes() instanceof AttributeRowImpl) {
                            AttributeRowImpl row = (AttributeRowImpl) edge.getEdgeData().getAttributes();
                            readRow(reader, attributeModel, attributeModel.getEdgeTable(), row);
                        }
                    }
View Full Code Here

         * Sets nodesToSearch as all nodes in the graph if they are null or empty array.
         * Also only search on visible view if data table is showing visible only.
         */
        private void checkNodesToSearch() {
            if (nodesToSearch == null || nodesToSearch.length == 0) {
                HierarchicalGraph hg;
                if (Lookup.getDefault().lookup(DataTablesController.class).isShowOnlyVisible()) {
                    hg = Lookup.getDefault().lookup(GraphController.class).getModel().getHierarchicalGraphVisible();
                } else {
                    hg = Lookup.getDefault().lookup(GraphController.class).getModel().getHierarchicalGraph();
                }
                nodesToSearch = hg.getNodesTree().toArray();
            }
        }
View Full Code Here

         * Sets edgesToSearch as all edges in the graph if they are null or empty array.
         * Also only search on visible view if data table is showing visible only.
         */
        private void checkEdgesToSearch() {
            if (edgesToSearch == null || edgesToSearch.length == 0) {
                HierarchicalGraph hg;
                if (Lookup.getDefault().lookup(DataTablesController.class).isShowOnlyVisible()) {
                    hg = Lookup.getDefault().lookup(GraphController.class).getModel().getHierarchicalGraphVisible();
                } else {
                    hg = Lookup.getDefault().lookup(GraphController.class).getModel().getHierarchicalGraph();
                }
                edgesToSearch = hg.getEdges().toArray();
            }
        }
View Full Code Here

    private static final String ELEMENT_VALUE = "attvalue";

    public void writeRows(XMLStreamWriter writer, GraphModel graphModel) throws XMLStreamException {
        writer.writeStartElement(ELEMENT_ROWS);

        HierarchicalGraph hierarchicalGraph = graphModel.getHierarchicalGraph();
        for (Node node : hierarchicalGraph.getNodesTree()) {
            if (node.getNodeData().getAttributes() != null && node.getNodeData().getAttributes() instanceof AttributeRowImpl) {
                AttributeRowImpl row = (AttributeRowImpl) node.getNodeData().getAttributes();
                writer.writeStartElement(ELEMENT_NODE_ROW);
                writer.writeAttribute("for", String.valueOf(node.getId()));
                if (writeRow(writer, row)) {
                    writer.writeEndElement();
                }
            }
        }

        for (Edge edge : hierarchicalGraph.getEdges()) {
            if (edge.getEdgeData().getAttributes() != null && edge.getEdgeData().getAttributes() instanceof AttributeRowImpl) {
                AttributeRowImpl row = (AttributeRowImpl) edge.getEdgeData().getAttributes();
                writer.writeStartElement(ELEMENT_EDGE_ROW);
                writer.writeAttribute("for", String.valueOf(edge.getId()));
                if (writeRow(writer, row)) {
View Full Code Here

        writer.writeEndElement();
    }

    public void readRows(XMLStreamReader reader, GraphModel graphModel, AbstractAttributeModel attributeModel) throws XMLStreamException {
        HierarchicalGraph hierarchicalGraph = graphModel.getHierarchicalGraph();

        boolean end = false;
        while (reader.hasNext() && !end) {
            int type = reader.next();

            switch (type) {
                case XMLStreamReader.START_ELEMENT:
                    String name = reader.getLocalName();
                    if (ELEMENT_NODE_ROW.equalsIgnoreCase(name)) {
                        int id = Integer.parseInt(reader.getAttributeValue(null, "for"));
                        Node node = hierarchicalGraph.getNode(id);
                        if (node.getNodeData().getAttributes() != null && node.getNodeData().getAttributes() instanceof AttributeRowImpl) {
                            AttributeRowImpl row = (AttributeRowImpl) node.getNodeData().getAttributes();
                            readRow(reader, attributeModel, attributeModel.getNodeTable(), row);
                        }
                    } else if (ELEMENT_EDGE_ROW.equalsIgnoreCase(name)) {
                        int id = Integer.parseInt(reader.getAttributeValue(null, "for"));
                        Edge edge = hierarchicalGraph.getEdge(id);
                        if (edge.getEdgeData().getAttributes() != null && edge.getEdgeData().getAttributes() instanceof AttributeRowImpl) {
                            AttributeRowImpl row = (AttributeRowImpl) edge.getEdgeData().getAttributes();
                            readRow(reader, attributeModel, attributeModel.getEdgeTable(), row);
                        }
                    }
View Full Code Here

            //Add property
            addProperty(Range.class, "range");
        }

        public boolean init(Graph graph) {
            HierarchicalGraph hg = (HierarchicalGraph) graph;
            this.partition = Lookup.getDefault().lookup(PartitionController.class).buildPartition(partition.getColumn(), hg);
            if (partition.getParts().length > 0) {
                return true;
            }
            return false;
View Full Code Here

        public String getName() {
            return NbBundle.getMessage(PartitionBuilder.class, "PartitionBuilder.name") + " (" + partition.getColumn().getTitle() + ")";
        }

        public boolean init(Graph graph) {
            HierarchicalGraph hg = (HierarchicalGraph) graph;
            this.partition = Lookup.getDefault().lookup(PartitionController.class).buildPartition(partition.getColumn(), hg);
            return true;
        }
View Full Code Here

        public boolean init(Graph graph) {
            return true;
        }

        public Graph filter(Graph graph) {
            HierarchicalGraph hierarchicalGraph = (HierarchicalGraph) graph;
            hierarchicalGraph.flatten();
            return hierarchicalGraph;
        }
View Full Code Here

TOP

Related Classes of org.gephi.graph.api.HierarchicalGraph

Copyright © 2018 www.massapicom. 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.