Package org.gephi.graph.dhns.core

Examples of org.gephi.graph.dhns.core.TreeStructure


        graphView.setEdgesCountTotal(Integer.parseInt(reader.getAttributeValue(null, "edgestotal")));
        graphView.setMutualEdgesEnabled(Integer.parseInt(reader.getAttributeValue(null, "mutualedgesenabled")));
        graphView.setMutualEdgesTotal(Integer.parseInt(reader.getAttributeValue(null, "mutualedgestotal")));
        graphView.setNodesEnabled(Integer.parseInt(reader.getAttributeValue(null, "nodesenabled")));

        TreeStructure mainStructure = graphStructure.getMainView().getStructure();
        TreeStructure treeStructure = graphView.getStructure();

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

            switch (type) {
                case XMLStreamReader.START_ELEMENT:
                    String name = reader.getLocalName();
                    if (ELEMENT_VIEW_NODE.equalsIgnoreCase(name)) {
                        Boolean enabled = Boolean.parseBoolean(reader.getAttributeValue(null, "enabled"));
                        AbstractNode mainNode = mainStructure.getNodeAt(Integer.parseInt(reader.getAttributeValue(null, "mainpre")));
                        AbstractNode parentNode = treeStructure.getNodeAt(Integer.parseInt(reader.getAttributeValue(null, "parent")));
                        AbstractNode node = new AbstractNode(mainNode.getNodeData(), graphView.getViewId(), 0, 0, 0, parentNode);
                        Integer inDegree = Integer.parseInt(reader.getAttributeValue(null, "enabledindegree"));
                        Integer outDegree = Integer.parseInt(reader.getAttributeValue(null, "enabledoutdegree"));
                        Integer mutualDegree = Integer.parseInt(reader.getAttributeValue(null, "enabledmutualdegree"));
                        node.setEnabledInDegree(inDegree);
                        node.setEnabledOutDegree(outDegree);
                        node.setEnabledMutualDegree(mutualDegree);
                        node.setEnabled(enabled);
                        treeStructure.insertAsChild(node, parentNode);
                    } else if (ELEMENT_VIEW_EDGE.equalsIgnoreCase(name)) {
                        AbstractEdge edge = graphStructure.getEdgeFromDictionnary(Integer.parseInt(reader.getAttributeValue(null, "id")));
                        AbstractNode source = edge.getSource(graphView.getViewId());
                        AbstractNode target = edge.getTarget(graphView.getViewId());
                        source.getEdgesOutTree().add(edge);
View Full Code Here


    private static final String ELEMENT_EDGEDATA_COLOR = "color";

    public void writeData(XMLStreamWriter writer, Dhns dhns) throws XMLStreamException {
        writer.writeStartElement(ELEMENT_DATA);

        TreeStructure treeStructure = dhns.getGraphStructure().getMainView().getStructure();
        TreeListIterator itr = new TreeListIterator(treeStructure.getTree(), 1);
        for (; itr.hasNext();) {
            AbstractNode absNode = itr.next();
            NodeDataImpl nodeData = absNode.getNodeData();
            if (nodeData != null) {
                writeNodeData(writer, nodeData);
            }
        }

        EdgeIterator edgeIterator = new EdgeIterator(treeStructure, new TreeListIterator(treeStructure.getTree(), 1), false, Tautology.instance, Tautology.instance);
        for (; edgeIterator.hasNext();) {
            EdgeDataImpl edgeData = edgeIterator.next().getEdgeData();
            if (edgeData != null) {
                writeEdgeData(writer, edgeData);
            }
View Full Code Here

    }

    public void readData(XMLStreamReader reader, Dhns dhns) throws XMLStreamException {

        GraphStructure structure = dhns.getGraphStructure();
        TreeStructure treeStructure = structure.getMainView().getStructure();

        boolean end = false;
        while (reader.hasNext() && !end) {
            Integer eventType = reader.next();
            if (eventType.equals(XMLEvent.START_ELEMENT)) {
                String name = reader.getLocalName();
                if (ELEMENT_NODEDATA.equalsIgnoreCase(name)) {
                    AbstractNode node = treeStructure.getNodeAt(Integer.parseInt(reader.getAttributeValue(null, "nodepre")));
                    NodeDataImpl nodeDataImpl = (NodeDataImpl) node.getNodeData();
                    readNodeData(reader, nodeDataImpl, structure);
                } else if (ELEMENT_EDGEDATA.equalsIgnoreCase(name)) {
                    AbstractNode source = treeStructure.getNodeAt(Integer.parseInt(reader.getAttributeValue(null, "sourcepre")));
                    AbstractNode target = treeStructure.getNodeAt(Integer.parseInt(reader.getAttributeValue(null, "targetpre")));
                    AbstractEdge edge = source.getEdgesOutTree().getItem(target.getId());
                    EdgeDataImpl edgeDataImpl = (EdgeDataImpl) edge.getEdgeData();
                    readEdgeData(reader, edgeDataImpl, structure);
                }
            } else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
View Full Code Here

        writer.writeEndElement();
    }

    public void readEdges(XMLStreamReader reader, GraphStructure graphStructure, GraphFactoryImpl factory) throws XMLStreamException {
        TreeStructure treeStructure = graphStructure.getMainView().getStructure();

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

            switch (type) {
                case XMLStreamReader.START_ELEMENT:
                    String name = reader.getLocalName();

                    Integer source = 0;
                    Integer target = 0;
                    Integer id = 0;
                    Boolean directed = false;
                    Float weight = 0f;

                    for (int i = 0; i < reader.getAttributeCount(); i++) {
                        String attName = reader.getAttributeName(i).getLocalPart();
                        if ("id".equalsIgnoreCase(attName)) {
                            id = Integer.parseInt(reader.getAttributeValue(i));
                        } else if ("source".equalsIgnoreCase(attName)) {
                            source = Integer.parseInt(reader.getAttributeValue(i));
                        } else if ("target".equalsIgnoreCase(attName)) {
                            target = Integer.parseInt(reader.getAttributeValue(i));
                        } else if ("directed".equalsIgnoreCase(attName)) {
                            directed = Boolean.parseBoolean(reader.getAttributeValue(i));
                        } else if ("weight".equalsIgnoreCase(attName)) {
                            weight = Float.parseFloat(reader.getAttributeValue(i));
                        }
                    }
                    AbstractNode srcNode = treeStructure.getNodeAt(source);
                    AbstractNode destNode = treeStructure.getNodeAt(target);
                    AbstractEdge edge;
                    if (ELEMENT_EDGES_PROPER.equalsIgnoreCase(name)) {
                        edge = new ProperEdgeImpl(id, srcNode, destNode);
                    } else if (ELEMENT_EDGES_MIXED.equalsIgnoreCase(name)) {
                        edge = new MixedEdgeImpl(id, srcNode, destNode, directed);
View Full Code Here

        graphStructure.getMainView().setEdgesCountTotal(Integer.parseInt(reader.getAttributeValue(null, "edgestotal")));
        graphStructure.getMainView().setMutualEdgesEnabled(Integer.parseInt(reader.getAttributeValue(null, "mutualedgesenabled")));
        graphStructure.getMainView().setMutualEdgesTotal(Integer.parseInt(reader.getAttributeValue(null, "mutualedgestotal")));
        graphStructure.getMainView().setNodesEnabled(Integer.parseInt(reader.getAttributeValue(null, "nodesenabled")));

        TreeStructure treeStructure = graphStructure.getMainView().getStructure();

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

            switch (type) {
                case XMLStreamReader.START_ELEMENT:
                    String name = reader.getLocalName();
                    if (ELEMENT_TREESTRUCTURE_NODE.equalsIgnoreCase(name)) {
                        Boolean enabled = Boolean.parseBoolean(reader.getAttributeValue(null, "enabled"));
                        AbstractNode parentNode = treeStructure.getNodeAt(Integer.parseInt(reader.getAttributeValue(null, "parent")));
                        AbstractNode absNode = new AbstractNode(Integer.parseInt(reader.getAttributeValue(null, "id")), 0, 0, 0, 0, parentNode);
                        absNode.setEnabled(enabled);
                        Integer inDegree = Integer.parseInt(reader.getAttributeValue(null, "enabledindegree"));
                        Integer outDegree = Integer.parseInt(reader.getAttributeValue(null, "enabledoutdegree"));
                        Integer mutualDegree = Integer.parseInt(reader.getAttributeValue(null, "enabledmutualdegree"));
                        absNode.setEnabledInDegree(inDegree);
                        absNode.setEnabledOutDegree(outDegree);
                        absNode.setEnabledMutualDegree(mutualDegree);
                        absNode.getNodeData().setAttributes(factory.newNodeAttributes(absNode.getNodeData()));
                        absNode.getNodeData().setTextData(factory.newTextData());
                        treeStructure.insertAsChild(absNode, parentNode);
                        graphStructure.addToDictionnary(absNode);
                    }
                    break;

                case XMLStreamReader.END_ELEMENT:
View Full Code Here

        dhnsGlobal = new Dhns(controller, null);
        graphGlobal = new HierarchicalDirectedGraphImpl(dhnsGlobal, dhnsGlobal.getGraphStructure().getMainView());
        nodeMap = new HashMap<String, Node>();
        edgeMap = new HashMap<String, Edge>();

        TreeStructure treeStructure = dhnsGlobal.getGraphStructure().getMainView().getStructure();
        GraphFactoryImpl factory = dhnsGlobal.factory();

        //Nodes
        //System.out.println("-----Global-----");
        for (int i = 0; i < 10; i++) {
View Full Code Here

TOP

Related Classes of org.gephi.graph.dhns.core.TreeStructure

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.