Java Code Examples for org.netbeans.api.visual.graph.layout.UniversalGraph#getNodes()

The following examples show how to use org.netbeans.api.visual.graph.layout.UniversalGraph#getNodes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HierarchicalGraphLayout.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new HashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 2
Source File: HierarchicalGraphLayout.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new HashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 3
Source File: HierarchicalGraphLayout.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new HashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 4
Source File: HierarchicalGraphLayout.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new HashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 5
Source File: HierarchicalGraphLayout.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new LinkedHashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new LinkedHashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 6
Source File: HierarchicalGraphLayout.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new HashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 7
Source File: HierarchicalGraphLayout.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new HashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 8
Source File: HierarchicalGraphLayout.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void performGraphLayout(UniversalGraph<N, E> graph) {

        Set<LinkWrapper> links = new HashSet<LinkWrapper>();
        Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
        Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();

        for (N node : graph.getNodes()) {
            VertexWrapper v = new VertexWrapper(node, graph);
            vertexMap.put(node, v);
            vertices.add(v);
        }

        for (E edge : graph.getEdges()) {
            N source = graph.getEdgeSource(edge);
            N target = graph.getEdgeTarget(edge);
            LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
            links.add(l);
        }

        HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);

        LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
        m.doLayout(layoutGraph);
    }
 
Example 9
Source File: DirectedGraph.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of DirectedGraph
 */
protected DirectedGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
    this.uGraph = uGraph;
    this.scene = scene;
    this.nodes = uGraph.getNodes();
    this.edges = uGraph.getEdges();

    vertexMap = new HashMap<N, Vertex>();
    edgeMap = new LinkedHashMap<E, Edge>();
    rootVertices = new ArrayList<Vertex>();
    vertices = new ArrayList<Vertex>();
}
 
Example 10
Source File: MixedGraph.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates a new instance of UndirectedGraph */
private MixedGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
    this.uGraph = uGraph;
    this.scene = scene;
    this.nodes = uGraph.getNodes();
    this.edges = uGraph.getEdges() ;

    vertexMap = new HashMap<N, Vertex>();
}
 
Example 11
Source File: MGraph.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param uGraph
 * @param scene
 */
protected MGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
    this.uGraph = uGraph;
    this.scene = scene;
    this.nodes = uGraph.getNodes();

    vertexMap = new HashMap<N, Vertex>();
    edgeMap = new LinkedHashMap<E, Edge>();
    vertices = new ArrayList<Vertex>();

    DummyVertex.resetCounter();
}
 
Example 12
Source File: TreeGraphLayout.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected void performGraphLayout (UniversalGraph<N, E> graph) {
    if (rootNode == null)
        return;
    Collection<N> allNodes = graph.getNodes ();
    if (! allNodes.contains (rootNode))
        return;
    ArrayList<N> nodesToResolve = new ArrayList<N> (allNodes);

    HashSet<N> loadedSet = new HashSet<N> ();
    Node root = new Node (graph, rootNode, loadedSet);
    nodesToResolve.removeAll (loadedSet);

    Map<Integer, Integer> map = root.getMaxSpaceForEveryLevel(graph);

    List<Node.LeftRight> envelope = root.layout(originX, originY, map, 0);

    // correction of originX, if needed
    int moveDistance = Integer.MIN_VALUE;
    // get the most left position and determine the distance to move
    for (Node.LeftRight leftRight : envelope) {
        if (leftRight.getLeft() < originX && originX - leftRight.getLeft() > moveDistance) {
            moveDistance = originX - leftRight.getLeft();
        }
    }

    if (moveDistance == Integer.MIN_VALUE) {
        moveDistance = 0;
    }

    if (!vertical) {
        root.invert(moveDistance);
    } else {
        root.relativeBoundsCorrectionX(moveDistance);
    }

    final HashMap<N, Point> resultPosition = new HashMap<N, Point> ();
    root.upload (resultPosition);

    for (N node : nodesToResolve) {
        Point position = new Point ();
        // TODO - resolve others
        resultPosition.put (node, position);
    }

    for (Map.Entry<N, Point> entry : resultPosition.entrySet ())
        setResolvedNodeLocation (graph, entry.getKey (), entry.getValue ());
}