本文整理汇总了Java中org.netbeans.api.visual.graph.layout.UniversalGraph.getNodes方法的典型用法代码示例。如果您正苦于以下问题:Java UniversalGraph.getNodes方法的具体用法?Java UniversalGraph.getNodes怎么用?Java UniversalGraph.getNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.visual.graph.layout.UniversalGraph
的用法示例。
在下文中一共展示了UniversalGraph.getNodes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performGraphLayout
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入方法依赖的package包/类
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);
}
示例2: performGraphLayout
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入方法依赖的package包/类
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);
}
示例3: performGraphLayout
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入方法依赖的package包/类
/**
* Performs the grid graph layout on an universal graph.
*
* @param graph the universal graph
*/
@Override
protected void performGraphLayout(UniversalGraph<GraphNode, EdgeNode> graph) {
ObjectScene scene = graph.getScene();
List<GraphNode> leftNodes = new ArrayList<GraphNode>();
List<GraphNode> rightNodes = new ArrayList<GraphNode>();
for (GraphNode node : graph.getNodes()) {
Integer rightAlign = (Integer) node.getValue(LAYOUT_NODE_LOCATION);
if (rightAlign != null && rightAlign == LOCATION_RIGHT) {
rightNodes.add(node);
} else {
leftNodes.add(node);
}
}
List<GraphLocation> leftWidgets = createRelativeLocations(scene, leftNodes, Align.LEFT);
List<GraphLocation> rightWidgets = createRelativeLocations(scene, rightNodes, Align.LEFT);
Rectangle leftBoundMax = findMaxBound(leftWidgets);
Point leftStart = new Point(LEFT_SPACING, TOP_SPACING);
Point rightStart = new Point(RIGHT_START_X, TOP_SPACING);
if (RIGHT_START_X < (LEFT_SPACING + leftBoundMax.width + horizontalGap)) {
rightStart = new Point(LEFT_SPACING + leftBoundMax.width + horizontalGap, TOP_SPACING);
}
resolveNodeLocations(graph, leftWidgets, leftStart);
resolveNodeLocations(graph, rightWidgets, rightStart);
}
示例4: DirectedGraph
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入方法依赖的package包/类
/**
* 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>();
}
示例5: MixedGraph
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入方法依赖的package包/类
/** 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>();
}
示例6: MGraph
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入方法依赖的package包/类
/**
*
* @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();
}
示例7: performGraphLayout
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入方法依赖的package包/类
@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 ());
}