org.netbeans.api.visual.graph.layout.UniversalGraph Java Examples
The following examples show how to use
org.netbeans.api.visual.graph.layout.UniversalGraph.
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: AbegoTreeLayoutForNetbeans.java From treelayout with BSD 3-Clause "New" or "Revised" License | 7 votes |
@Override protected void performGraphLayout(UniversalGraph<N, E> graph) { if (!graph.getNodes().contains(rootNode)) { throw new IllegalArgumentException( "graph does not contain rootNode"); } TreeLayout<N> layout = new TreeLayout<N>(new MyTreeForTreeLayout( rootNode, graph), new MyNodeExtentProvider(graph), configuration); Map<N, Rectangle2D.Double> bounds = layout.getNodeBounds(); for (Map.Entry<N, Rectangle2D.Double> entry : bounds.entrySet()) { Rectangle2D.Double rect = entry.getValue(); Point pt = new Point((int) Math.round(rect.getX() + originX), (int) Math.round(rect.getY() + originY)); setResolvedNodeLocation(graph, entry.getKey(), pt); } }
Example #2
Source File: HierarchicalGraphLayout.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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-8 with GNU General Public License v2.0 | 6 votes |
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-8 with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #5
Source File: HierarchicalGraphLayout.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: HierarchicalGraphLayout.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #7
Source File: HierarchicalGraphLayout.java From hottub with GNU General Public License v2.0 | 6 votes |
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 hottub with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #9
Source File: HierarchicalGraphLayout.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 #10
Source File: HierarchicalGraphLayout.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #11
Source File: HierarchicalGraphLayout.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 #12
Source File: HierarchicalGraphLayout.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #13
Source File: HierarchicalGraphLayout.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #14
Source File: HierarchicalGraphLayout.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #15
Source File: HierarchicalGraphLayout.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #16
Source File: HierarchicalGraphLayout.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public VertexWrapper(N node, UniversalGraph<N, E> graph) { this.node = node; this.graph = graph; final VertexWrapper vertex = this; this.slot = new Port() { public Vertex getVertex() { return vertex; } public Point getRelativePosition() { return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); } }; Widget w = graph.getScene().findWidget(node); this.position = w.getPreferredLocation(); }
Example #17
Source File: HierarchicalGraphLayout.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 #18
Source File: MixedGraph.java From netbeans with Apache License 2.0 | 5 votes |
/** 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 #19
Source File: DirectedGraph.java From netbeans with Apache License 2.0 | 5 votes |
/** * 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 #20
Source File: TreeGraphLayout.java From netbeans with Apache License 2.0 | 5 votes |
/** * Method to determine the maximal space (horizontaly or verticaly) of each level in the tree. * @param map the {@link Map} to which the maximal space for each level should be stored. * @param lvl the level to analyse. * @return the result of the maximal space calculation for the given level and the sublevels. * @since 2.25 */ private Map<Integer, Integer> calculateMaxSpace(UniversalGraph<N, E> graph, Map<Integer, Integer> map, int lvl) { Widget widget = graph.getScene().findWidget(node); widget.getLayout().layout(widget); relativeBounds = widget.getPreferredBounds(); if (vertical) { space = relativeBounds.height; } else { space = relativeBounds.width; } if (map.get(lvl) != null) { // lvl is in list, but height is greater than the old one. if (map.get(lvl) < space) { map.put(lvl, space); } } else { // lvl isn't in the map right now. map.put(lvl, space); } lvl++; // do iteration over all children of the current node and calculate // the maxSpace for (Node n : children) { n.calculateMaxSpace(graph, map, lvl); } return map; }
Example #21
Source File: TreeGraphLayout.java From netbeans with Apache License 2.0 | 5 votes |
private Node (UniversalGraph<N, E> graph, N node, HashSet<N> loadedSet) { this.node = node; loadedSet.add (node); children = new ArrayList<Node> (); for (E edge: graph.findNodeEdges (node, true, false)) { N child = graph.getEdgeTarget (edge); if (child != null && ! loadedSet.contains (child)) children.add (new Node (graph, child, loadedSet)); } }
Example #22
Source File: MGraph.java From netbeans with Apache License 2.0 | 5 votes |
/** * * @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 #23
Source File: HierarchicalGraphLayout.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
protected void performNodesLayout(UniversalGraph<N, E> graph, Collection<N> nodes) { throw new UnsupportedOperationException(); }
Example #24
Source File: AbegoTreeLayoutForNetbeans.java From treelayout with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void performNodesLayout(UniversalGraph<N, E> universalGraph, Collection<N> nodes) { throw new UnsupportedOperationException( "Cannot layout a subsets of nodes of a tree"); }
Example #25
Source File: DirectedGraph.java From netbeans with Apache License 2.0 | 4 votes |
public static <N, E> DirectedGraph createGraph(UniversalGraph<N, E> uGraph, GraphScene scene) { DirectedGraph<N, E> graph = new DirectedGraph<N, E>(uGraph, scene); graph.createGraph(); //graph.printGraph(); return graph; }
Example #26
Source File: AbegoTreeLayoutForNetbeans.java From treelayout with BSD 3-Clause "New" or "Revised" License | 4 votes |
public MyTreeForTreeLayout(N root, UniversalGraph<N, E> graph) { super(root); this.graph = graph; }
Example #27
Source File: AbegoTreeLayoutForNetbeans.java From treelayout with BSD 3-Clause "New" or "Revised" License | 4 votes |
public MyNodeExtentProvider(UniversalGraph<N, E> graph) { this.graph = graph; }
Example #28
Source File: HierarchicalGraphLayout.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
protected void performNodesLayout(UniversalGraph<N, E> graph, Collection<N> nodes) { throw new UnsupportedOperationException(); }
Example #29
Source File: HierarchicalGraphLayout.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
protected void performNodesLayout(UniversalGraph<N, E> graph, Collection<N> nodes) { throw new UnsupportedOperationException(); }
Example #30
Source File: MixedGraph.java From netbeans with Apache License 2.0 | 4 votes |
public static <N, E> MixedGraph createGraph(UniversalGraph<N, E> uGraph, GraphScene scene) { MixedGraph<N, E> graph = new MixedGraph<N, E>(uGraph, scene); graph.createGraph(); //graph.printGraph(); return graph; }