本文整理汇总了Java中org.netbeans.api.visual.graph.layout.UniversalGraph类的典型用法代码示例。如果您正苦于以下问题:Java UniversalGraph类的具体用法?Java UniversalGraph怎么用?Java UniversalGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UniversalGraph类属于org.netbeans.api.visual.graph.layout包,在下文中一共展示了UniversalGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VertexWrapper
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
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();
}
示例2: 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);
}
示例3: 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);
}
示例4: performGraphLayout
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
@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);
}
}
示例5: 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);
}
示例6: 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>();
}
示例7: 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>();
}
示例8: 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();
}
示例9: Node
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
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));
}
}
示例10: calculateMaxSpace
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
/**
* 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;
}
示例11: performGraphLayout
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
@Override
protected void performGraphLayout(UniversalGraph<N, E> graph) {
this.graph = graph;
vertexToLayoutNode = new HashMap<N, LayoutNode>();
reversedLinks = new HashSet<E>();
nodes = new ArrayList<LayoutNode>();
// #############################################################
// Step 1: Build up data structure
new BuildDatastructure().start();
// #############################################################
// STEP 2: Reverse edges, handle backedges
new ReverseEdges().start();
// #############################################################
// STEP 3: Assign layers
new AssignLayers().start();
// #############################################################
// STEP 4: Create dummy nodes
new CreateDummyNodes().start();
// #############################################################
// STEP 5: Crossing Reduction
new CrossingReduction().start();
// #############################################################
// STEP 7: Assign X coordinates
//new AssignXCoordinates().start();
new AssignXCoordinates().start();
// #############################################################
// STEP 6: Assign Y coordinates
new AssignYCoordinates().start();
// #############################################################
// STEP 8: Write back to interface
new WriteResult().start();
}
示例12: createGraph
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
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;
}
示例13: createGraph
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
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;
}
示例14: 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 ());
}
示例15: performNodesLayout
import org.netbeans.api.visual.graph.layout.UniversalGraph; //导入依赖的package包/类
@Override
protected void performNodesLayout (UniversalGraph<N, E> universalGraph, Collection<N> nodes) {
throw new UnsupportedOperationException (); // TODO
}