Java 类org.eclipse.draw2d.graph.Node 实例源码

项目:PDFReporter-Studio    文件:DummyEdgeCreator.java   
protected void setDummyEdges() {
    Node targetNode = null;
    int nodeCount = nodeList.size();

    // if node count is only one then we don't have to worry about whether
    // the nodes are connected
    if (nodeCount > 1) {
        for (Iterator iter = nodeList.iterator(); iter.hasNext();) {
            Node sourceNode = (Node) iter.next();
            // we will need to set up a dummy relationship for any table not
            // in one already
            if (sourceNode.outgoing.size() == 0 && sourceNode.incoming.size() == 0) {
                targetNode = findTargetNode(sourceNode);
                Edge edge = newDummyEdge(targetNode, sourceNode);
                edgesAdded.add(edge);
            }
        }
    }
}
项目:PDFReporter-Studio    文件:DirectedGraphLayoutVisitor.java   
protected void addEdges(AbstractGraphicalEditPart diagram) {
    for (Object obj : diagram.getChildren()) {
        AbstractGraphicalEditPart part = (AbstractGraphicalEditPart) obj;
        for (Object item : part.getSourceConnections()) {
            RelationshipPart rpart = (RelationshipPart) item;
            Node source = (Node) partToNodesMap.get(rpart.getSource());
            Node target = (Node) partToNodesMap.get(rpart.getTarget());
            if (source != null && target != null) {
                Edge e = new Edge(rpart, source, target);
                e.weight = 2;
                graph.edges.add(e);
                partToNodesMap.put(rpart, e);
            }
        }
    }
}
项目:PDFReporter-Studio    文件:DirectedGraphLayoutVisitor.java   
protected void applyChildrenResults(AbstractGraphicalEditPart diagram) {
    List<AbstractGraphicalEditPart> children = diagram.getChildren();
    Rectangle r = diagram.getFigure().getBounds();
    for (AbstractGraphicalEditPart tp : children) {
        Node n = (Node) partToNodesMap.get(tp);
        IFigure f = tp.getFigure();

        Dimension psize = f.getPreferredSize();
        f.setBounds(new Rectangle(r.x + n.x, r.y + n.y, psize.width,
                psize.height));

        List<RelationshipPart> sc = tp.getSourceConnections();
        for (RelationshipPart rp : sc)
            applyResults(rp);
    }
}
项目:d-case_editor    文件:LocateNodeGraphVisitor.java   
/**
 * Locates the nodes.
 */
private void locateNode() {
    int xPoint = BASE_POINT_X;
    int yPoint = BASE_POINT_Y;

    NodeList baseNodeList = getGraph().getBaseNodeList();
    for (int i = 0; i < baseNodeList.size(); i++) {
        Node node = baseNodeList.getNode(i);
        NodeEx nodeEx = getNodeEx(node);

        Rectangle rect = nodeEx.getBlockBounds();
        locateNode(nodeEx, xPoint, yPoint);
        if (ArrangeAngle.createInstance().getAngle() == ArrangeAngle.Direction.Vertical) {
            xPoint += rect.width + HORIZONTAL_SPACING;
        } else {
            yPoint += rect.height + VERTICAL_SPACING;
        }
    }
}
项目:d-case_editor    文件:NodeEx.java   
/**
 * Returns the children those should be locate to the south.
 * 
 * @return the children those should be locate to the south.
 */
@SuppressWarnings("unchecked")
public NodeList getSouthNodes() {
    EdgeList edgeList = new EdgeList();
    NodeList nodeList = new NodeList();
    for (Object obj : node.outgoing) {
        if (!DcaseDirectedGraph.isEast((Node) ((Edge) obj).target)) {
            edgeList.add(obj);
        }
    }
    // sorts by the sibling order.
    if (edgeList.size() > 1) {
        Collections.sort(edgeList, new DcaseEditPartLayoutComparator());
    }
    for (int i = 0; i < edgeList.size(); i++) {
        nodeList.add(((Edge) edgeList.get(i)).target);
    }
    return nodeList;
}
项目:d-case_editor    文件:NodeEx.java   
/**
 * Returns the children those should be locate to the east.
 * 
 * @return the children those should be locate to the east.
 */
@SuppressWarnings("unchecked")
public NodeList getEastNodes() {
    EdgeList edgeList = new EdgeList();
    NodeList nodeList = new NodeList();
    for (Object obj : node.outgoing) {
        if (DcaseDirectedGraph.isEast((Node) ((Edge) obj).target)) {
            edgeList.add(obj);
        }
    }
    // sorts by the sibling order.
    if (edgeList.size() > 1) {
        Collections.sort(edgeList, new DcaseEditPartLayoutComparator());
    }
    for (int i = 0; i < edgeList.size(); i++) {
        nodeList.add(((Edge) edgeList.get(i)).target);
    }
    return nodeList;
}
项目:d-case_editor    文件:CollectNodeGraphVisitor.java   
/**
 * Collects the first node.
 * 
 * @param node the node.
 */
private void collectBaseNode(Node node) {
    NodeEx nodeEx = getNodeEx(node);
    if (nodeEx != null) {
        if (stack.contains(nodeEx)) {
            nodeEx.setLooped(true);
        }
        return;
    }
    nodeEx = addNodeEx(node);
    stack.push(nodeEx);
    NodeList list = nodeEx.getChildren();
    for (int i = 0; i < list.size(); i++) {
        Node child = list.getNode(i);
        collectBaseNode(child);
    }
    if (nodeEx.getParentCount() > 1) {
        list = nodeEx.getParent();
        for (int i = 0; i < list.size(); i++) {
            Node parent = list.getNode(i);
            getRootParent(parent);
        }
    }
    nodeEx.setDepth(stack.size());
    stack.pop();
}
项目:d-case_editor    文件:CollectNodeGraphVisitor.java   
/**
 * Returns the root of the specified node.
 * 
 * @param node the node.
 */
private void getRootParent(Node node) {
    if (getNodeEx(node) != null) {
        return;
    }
    if (workStack.contains(node)) {
        return;
    }
    workStack.push(node);
    EdgeList edgeList = node.incoming;
    if (edgeList.size() > 0) {
        for (int i = 0; i < edgeList.size(); i++) {
            Node parent = ((Edge) edgeList.get(i)).source;
            getRootParent(parent);
        }
    } else {
        addBaseNodeList(node);
        collectBaseNode(node);
    }
    workStack.pop();
    return;
}
项目:d-case_editor    文件:CalcNodeSizeGraphVisitor.java   
/**
 * Calculates the preferred size of the area to show the specified node and its children.
 * 
 * @param node the root node.
 */
private void calcBlockSize(Node node) {
    NodeEx nodeEx = getNodeEx(node);

    if (stack.contains(nodeEx)) {
        return;
    }
    stack.push(nodeEx);

    NodeList list = nodeEx.getChildren();
    for (int i = 0; i < list.size(); i++) {
        Node child = list.getNode(i);
        NodeEx childEx = getNodeEx(child);
        if (nodeEx.getDepth() < childEx.getDepth()) {
            calcBlockSize(child);
        }
    }
    Dimension dim = nodeEx.calcBlockSize();
    Rectangle rect = nodeEx.getBlockBounds();
    rect.width = dim.width;
    rect.height = dim.height;
    stack.pop();
}
项目:JAADAS    文件:CFGNodeEditPart.java   
public void contributeNodesToGraph(DirectedGraph graph, HashMap map){
    Node node = new Node(this);
    node.width = getFigure().getBounds().width;//getNode().getWidth();
    int height = 22;
    if (((CFGNode)getModel()).getBefore() != null){
        height += ((CFGNode)getModel()).getBefore().getChildren().size() * 22;
    }
    if (((CFGNode)getModel()).getAfter() != null){
        height += ((CFGNode)getModel()).getAfter().getChildren().size() * 22;
    }
    node.height = height;//getFigure().getBounds().height;
    graph.nodes.add(node);
    map.put(this, node);
}
项目:JAADAS    文件:CFGNodeEditPart.java   
public void applyGraphResults(DirectedGraph graph, HashMap map){
    Node node = (Node)map.get(this);
    ((CFGNodeFigure)getFigure()).setBounds(new Rectangle(node.x, node.y, node.width, node.height));//getFigure().getBounds().height));//getFigure().getBounds().height));
    List outgoing = getSourceConnections();
    for (int i = 0; i < outgoing.size(); i++){
        CFGEdgeEditPart edge = (CFGEdgeEditPart)outgoing.get(i);
        edge.applyGraphResults(graph, map);
    }

}
项目:turnus    文件:AutoLayoutFeauture.java   
@Override
@SuppressWarnings("unchecked")
public void execute(ICustomContext context) {

    Diagram diagram = getDiagram();
    CompoundDirectedGraph draw2dGrap = new CompoundDirectedGraph();
    BiMap<PictogramElement, Node> draw2dGraphMap = HashBiMap.create();
    for (Shape shape : diagram.getChildren()) {
        final EObject eObject = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(shape);
        if (eObject instanceof ProcessingUnit || eObject instanceof Medium) {
            Node node = new Node();
            draw2dGrap.nodes.add(node);
            node.setSize(new Dimension(SHAPE_WIDTH, SHAPE_HEIGHT));
            draw2dGraphMap.put(shape, node);
        }
    }

    for (Connection connection : diagram.getConnections()) {
        Node start = draw2dGraphMap.get(connection.getEnd().getParent());
        Node end = draw2dGraphMap.get(connection.getStart().getParent());
        Edge edge = new Edge(start, end);
        draw2dGrap.edges.add(edge);
    }

    new CompoundDirectedGraphLayout().visit(draw2dGrap);

    for (Entry<PictogramElement, Node> e : draw2dGraphMap.entrySet()) {
        PictogramElement pe = e.getKey();
        Node n = e.getValue();
        Graphiti.getGaService().setLocation(pe.getGraphicsAlgorithm(), n.x, n.y);
    }

    hasDoneChanges = true;

}
项目:PDFReporter-Studio    文件:ClusterEdgeCreator.java   
public void visit(DirectedGraph graph) {
    try {
        this.graph = graph;
        this.nodeList = graph.nodes;
        this.edgeList = graph.edges;

        // iterate through all of the nodes in the node list
        for (Iterator iter = nodeList.iterator(); iter.hasNext();) {
            Node node = (Node) iter.next();

            // check whether we have already come across this node
            if (!encountered.contains(node)) {
                // create a new cluster for this node
                currentCluster = new Cluster();
                clusters.add(currentCluster);
                encountered.add(node);
                currentCluster.set.add(node);

                // System.out.println("Adding to NEW cluster: " + node + ", cluster: "
                // + currentCluster);
                // recursively add any other nodes reachable from it
                int depth = INITIAL_RECURSION_DEPTH;
                recursivelyAddToCluster(node, depth);
            } else {
                // System.out.println("Already encountered: " + node);
            }
        }
        coalesceRemainingClusters();

        // System.out.println("");
        joinClusters();
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw e;
    }
}
项目:PDFReporter-Studio    文件:ClusterEdgeCreator.java   
/**
 * creates a new dummy edge to be used in the graph
 */
private Edge newDummyEdge(Node sourceNode, Node targetNode) {
    DummyEdgePart edgePart = new DummyEdgePart();
    Edge edge = new Edge(edgePart, sourceNode, targetNode);
    edge.weight = 2;
    // add the new edge to the edge list
    edgeList.add(edge);
    targetNode = sourceNode;
    return edge;
}
项目:PDFReporter-Studio    文件:DummyEdgeCreator.java   
/**
 * creates a new dummy edge to be used in the graph
 */
private Edge newDummyEdge(Node targetNode, Node sourceNode) {
    DummyEdgePart edgePart = new DummyEdgePart();
    Edge edge = new Edge(edgePart, sourceNode, targetNode);
    edge.weight = 2;
    edgeList.add(edge);
    targetNode = sourceNode;
    return edge;
}
项目:PDFReporter-Studio    文件:DummyEdgeCreator.java   
private Node getNext() {
    if (targetNodeIndex == candidateList.size() - 1)
        targetNodeIndex = 0;
    else
        targetNodeIndex++;
    return (Node) candidateList.get(targetNodeIndex);
}
项目:PDFReporter-Studio    文件:DirectedGraphLayoutVisitor.java   
protected void addNodes(AbstractGraphicalEditPart diagram) {
    for (Object obj : diagram.getChildren()) {
        AbstractGraphicalEditPart part = (AbstractGraphicalEditPart) obj;
        Node n = new Node(part);
        Dimension psize = part.getFigure().getPreferredSize(400, 300);
        n.width = psize.width;
        n.height = psize.height;
        n.setPadding(PADDING);
        partToNodesMap.put(part, n);
        graph.nodes.add(n);
    }
}
项目:PDFReporter-Studio    文件:DirectedGraphLayoutVisitor.java   
protected void applyResults(RelationshipPart relationshipPart) {
    Edge e = (Edge) partToNodesMap.get(relationshipPart);
    if (e == null)
        return;
    NodeList nodes = e.vNodes;

    PolylineConnection conn = (PolylineConnection) relationshipPart
            .getConnectionFigure();
    if (nodes != null) {
        List<AbsoluteBendpoint> bends = new ArrayList<AbsoluteBendpoint>();
        for (int i = 0; i < nodes.size(); i++) {
            Node vn = nodes.getNode(i);
            int x = vn.x;
            int y = vn.y;
            if (e.isFeedback()) {
                bends.add(new AbsoluteBendpoint(x, y + vn.height));
                bends.add(new AbsoluteBendpoint(x, y));
            } else {
                bends.add(new AbsoluteBendpoint(x, y));
                bends.add(new AbsoluteBendpoint(x, y + vn.height));
            }
        }
        conn.setRoutingConstraint(bends);
    } else {
        conn.setRoutingConstraint(Collections.EMPTY_LIST);
    }

}
项目:jive    文件:ContourGraphFactory.java   
private static void sortEdges(final List<Edge> edges)
{
  Collections.sort(edges, new Comparator<Edge>()
    {
      @Override
      public int compare(final Edge e1, final Edge e2)
      {
        final Node v1 = e1.target;
        final Node v2 = e2.target;
        final Long id1 = (Long) v1.data * (v1.incoming.size() == 0 ? -1 : 1);
        final Long id2 = (Long) v2.data * (v2.incoming.size() == 0 ? -1 : 1);
        return id1 < 0 && id2 < 0 ? (int) (id2 - id1) : (int) (id1 - id2);
      }
    });
}
项目:jive    文件:ContourGraphFactory.java   
@SuppressWarnings("unchecked")
private static void sortNodes(final NodeList nodes)
{
  Collections.sort(nodes, new Comparator<Node>()
    {
      @Override
      public int compare(final Node v1, final Node v2)
      {
        final Long id1 = (Long) v1.data;
        final Long id2 = (Long) v2.data;
        final int isz1 = v1.incoming.size();
        final int isz2 = v2.incoming.size();
        final int osz1 = v1.outgoing.size();
        final int osz2 = v2.outgoing.size();
        // at least one node is a root
        if (isz1 == 0 || isz2 == 0)
        {
          // if both are root nodes, oldest first, otherwise, root first
          return isz1 == isz2 ? (int) (id1 - id2) : (isz1 - isz2);
        }
        // at least one node is a leaf
        if (osz1 == 0 || osz2 == 0)
        {
          // if both are leaf nodes, oldest first, otherwise, internal first
          return osz1 == osz2 ? (int) (id1 - id2) : (osz2 - osz1);
        }
        // both nodes are internal
        return (int) (id1 - id2);
      }
    });
}
项目:jive    文件:ContourGraphFactory.java   
@SuppressWarnings("unchecked")
@Override
public void addContourNode(final IContour c, final Node v)
{
  graph.nodes.add(v);
  if (c instanceof IContextContour && ((IContextContour) c).isStatic())
  {
    staticNodes.put(v, graph.nodes.size() - 1);
  }
  updateMappings(c, v);
}
项目:jive    文件:ContourGraphFactory.java   
@SuppressWarnings("unchecked")
@Override
public void addEdge(final Node x, final Node y)
{
  final Edge e = new Edge(x, y);
  graph.edges.add(e);
  x.outgoing.add(e);
  y.incoming.add(e);
}
项目:jive    文件:ContourGraphFactory.java   
private IHierarchicalPosition setPosition(final Node u, final DiagramSection section,
    final IHierarchicalPosition parent, final int column)
{
  final IHierarchicalPosition position = ContourGraphFactory.createHierarchicalPosition(
      section, parent, column);
  nodeToPosition.put(u, position);
  return position;
}
项目:jive    文件:ContourGraphFactory.java   
private void updateMappings(final IContour c, final Node v)
{
  // Color the node white for graph traversal algorithm
  nodeColors.put((Long) v.data, Color.WHITE);
  // Add a contour-node mapping for the contour and its children
  contourToNode.put(c, v);
  // update child mappings
  for (final IContour child : c.children())
  {
    updateMappings(child, v);
  }
}
项目:jive    文件:ContourGraphFactory.java   
@SuppressWarnings("unchecked")
private void visitBF(final Node u, final DiagramSection section,
    final IHierarchicalPosition parent)
{
  setColor(u, Color.BLACK);
  int column = 0;
  // subtrees of this object
  ContourGraphFactory.sortEdges(u.outgoing);
  for (final Object o : u.outgoing)
  {
    final Edge e = (Edge) o;
    final Node v = e.target;
    if (getColor(v) == Color.WHITE)
    {
      final IHierarchicalPosition position = setPosition(v, section, parent, column++);
      visitBF(v, section, position);
    }
  }
  // subtrees leading into this object
  // ContourGraphFactory.sortEdges(u.incoming);
  // for (final Object o : u.incoming)
  // {
  // final Edge e = (Edge) o;
  // final Node v = e.source;
  // if (getColor(v) == Color.WHITE)
  // {
  // final IHierarchicalPosition position = setPosition(v, section, parent, column++);
  // visitBF(v, section, position);
  // }
  // }
}
项目:jive    文件:ContourGraphFactory.java   
@SuppressWarnings("unchecked")
@Override
public void addContourNode(final IContour c, final Node v)
{
  graph.nodes.add(v);
  updateMappings(c, v);
}
项目:jive    文件:ContourGraphFactory.java   
@SuppressWarnings("unchecked")
@Override
public void addEdge(final Node x, final Node y)
{
  final Edge e = new Edge(x, y);
  graph.edges.add(e);
  x.outgoing.add(e);
  y.incoming.add(e);
}
项目:jive    文件:ContourGraphFactory.java   
private void setPosition(final Node u, final DiagramSection section, final int column,
    final int layer, final int cell)
{
  final Long id = (Long) u.data;
  nodeSections.put(id, section);
  nodeColumns.put(id, column);
  nodeLayers.put(id, layer);
  nodeCells.put(id, cell);
}
项目:jive    文件:ContourGraphFactory.java   
private void updateMappings(final IContour c, final Node v)
{
  // Color the node white for graph traversal algorithm
  nodeColors.put((Long) v.data, Color.WHITE);
  // Add a contour-node mapping for the contour and its children
  contourToNode.put(c, v);
  // update child mappings
  for (final IContour child : c.children())
  {
    updateMappings(child, v);
  }
}
项目:jive    文件:ContourGraphFactory.java   
private void visitDF(final Node u, final DiagramSection section, final int column, int layer,
    final Map<Integer, Integer> layerToNextCellMapping)
{
  if (layerToNextCellMapping.containsKey(layer))
  {
    final int cell = layerToNextCellMapping.get(layer);
    setPosition(u, section, column, layer, cell);
    layerToNextCellMapping.put(layer, cell + 1);
  }
  else
  {
    setPosition(u, section, column, layer, 0);
    layerToNextCellMapping.put(layer, 1);
  }
  setColor(u, Color.BLACK);
  layer++;
  for (final Object o : u.outgoing)
  {
    final Edge e = (Edge) o;
    final Node v = e.target;
    if (getColor(v) == Color.WHITE)
    {
      visitDF(v, section, column, layer, layerToNextCellMapping);
    }
  }
  setColor(u, Color.BLACK);
}
项目:jive    文件:ContourGraph.java   
public ContourGraph(final IExecutionModel model)
{
  assert (model != null);
  this.layout = ContourDiagramFactory.createLayout();
  model.readLock();
  try
  {
    // vertices
    for (final IContour c : model.contourView().lookupRoots())
    {
      layout.addContourNode(c, new Node(c.id()));
    }
    // edges
    model.contourView().visit(new IVisitor<IContour>()
      {
        @Override
        public void visit(final IContour contour)
        {
          addGraphEdges(model, contour);
        }
      });
    // let the layout update all node positions
    layout.updatePositions();
  }
  finally
  {
    model.readUnlock();
  }
}
项目:dexdio    文件:DexClassesViewer.java   
private Node getNodeMap(NodeList nodes, DexClass type) {
    if (typeNodeMap.containsKey(type)) {
        return typeNodeMap.get(type);
    }

    Figure newfigure;

    newfigure = new ClassFigure(type);
    Node newnode = new Node(newfigure);

    typeNodeMap.put(type, newnode);
    nodes.add(newnode);

    return newnode;
}
项目:d-case_editor    文件:LocateEdgeGraphVisitor.java   
/**
 * Returns the direction of a link.
 * 
 * @param source the source.
 * @param target the target.
 * @return the direction of a link.
 */
private int getDirection(Node source, Node target) {
    int result = 0;
    if (ArrangeAngle.createInstance().getAngle() == ArrangeAngle.Direction.Vertical) {
        if (DcaseDirectedGraph.isEast(target)) {
            if (source.x < target.x) {
                result = LEFT_TO_RIGHT;
            } else {
                result = RIGHT_TO_LEFT;
            }
        } else {
            if (source.y > target.y) {
                result = BOTTOM_TO_TOP;
            } else {
                result = TOP_TO_BOTTOM;
            }
        }
    } else {
        if (!DcaseDirectedGraph.isEast(target)) {
            if (source.x < target.x) {
                result = LEFT_TO_RIGHT;
            } else {
                result = RIGHT_TO_LEFT;
            }
        } else {
            if (source.y > target.y) {
                result = BOTTOM_TO_TOP;
            } else {
                result = TOP_TO_BOTTOM;
            }
        }
    }
    return result;
}
项目:d-case_editor    文件:LocateNodeGraphVisitor.java   
/**
 * Returns the first node that should be locate in south.
 * 
 * @param nodeEx a node.
 * @return the first node that should be locate in south.
 */
private Node getWestOfSouth(NodeEx nodeEx) {
    Node node = null;
    NodeList list = nodeEx.getSouthNodes();
    for (int i = 0; i < list.size(); i++) {
        Node child = (Node) list.get(i);
        NodeEx childEx = getNodeEx(child);
        if (nodeEx.getDepth() < childEx.getDepth()) {
            node = child;
            break;
        }
    }
    return node;
}
项目:d-case_editor    文件:LocateNodeGraphVisitor.java   
/**
 * Returns the last child that should be locate in south.
 * 
 * @param nodeEx a node.
 * @return the last child that should be locate in south.
 */
private Node getEastOfSouth(NodeEx nodeEx) {
    Node node = null;
    NodeList list = nodeEx.getSouthNodes();
    for (int i = list.size() - 1; i >= 0; i--) {
        Node child = (Node) list.get(i);
        NodeEx childEx = getNodeEx(child);
        if (nodeEx.getDepth() < childEx.getDepth()) {
            node = child;
            break;
        }
    }
    return node;
}
项目:d-case_editor    文件:LocateNodeGraphVisitor.java   
/**
 * Returns the first child that should be locate in east.
 * 
 * @param nodeEx a node.
 * @return the first child that should be locate in east.
 */
private Node getNorthOfEast(NodeEx nodeEx) {
    Node node = null;
    NodeList list = nodeEx.getEastNodes();
    for (int i = 0; i < list.size(); i++) {
        Node child = (Node) list.get(i);
        NodeEx childEx = getNodeEx(child);
        if (nodeEx.getDepth() < childEx.getDepth()) {
            node = child;
            break;
        }
    }
    return node;
}
项目:d-case_editor    文件:LocateNodeGraphVisitor.java   
/**
 * Returns the last child that should be locate in east.
 * 
 * @param nodeEx a node.
 * @return the last child that should be locate in east.
 */
private Node getSouthOfEast(NodeEx nodeEx) {
    Node node = null;
    NodeList list = nodeEx.getEastNodes();
    for (int i = list.size() - 1; i >= 0; i--) {
        Node child = (Node) list.get(i);
        NodeEx childEx = getNodeEx(child);
        if (nodeEx.getDepth() < childEx.getDepth()) {
            node = child;
            break;
        }
    }
    return node;
}
项目:d-case_editor    文件:LocateNodeGraphVisitor.java   
/**
 * Returns the size of the south.
 * 
 * @param nodeEx a node.
 * @return the size of the south.
 */
public Dimension getSouthSize(NodeEx nodeEx) {
    Dimension dim = new Dimension();
    NodeList list = nodeEx.getSouthNodes();
    int count = 0;
    for (int i = 0; i < list.size(); i++) {
        Node child = list.getNode(i);
        NodeEx childEx = getNodeEx(child);

        if (nodeEx.getDepth() < childEx.getDepth()) {
            Rectangle childRect = childEx.getBlockBounds();
            if (ArrangeAngle.createInstance().getAngle() == ArrangeAngle.Direction.Vertical) {
                dim.width += childRect.width;
                dim.height = Math.max(dim.height, childRect.height);
            } else {
                dim.width = Math.max(dim.width, childRect.width);
                dim.height += childRect.height;
            }
            count++;
        }
    }
    if (count > 1) {
        if (ArrangeAngle.createInstance().getAngle() == ArrangeAngle.Direction.Vertical) {
            dim.width += (HORIZONTAL_SPACING * (count - 1));
        } else {
            dim.height += (VERTICAL_SPACING * (count - 1));
        }
    }
    return dim;
}
项目:d-case_editor    文件:LocateNodeGraphVisitor.java   
/**
 * Returns the size of the east.
 * 
 * @param nodeEx a node.
 * @return the size of the east.
 */
public Dimension getEastSize(NodeEx nodeEx) {
    Dimension dim = new Dimension();
    NodeList list = nodeEx.getEastNodes();
    int count = 0;
    for (int i = 0; i < list.size(); i++) {
        Node child = list.getNode(i);
        NodeEx childEx = getNodeEx(child);

        if (nodeEx.getDepth() < childEx.getDepth()) {
            Rectangle childRect = childEx.getBlockBounds();
            if (ArrangeAngle.createInstance().getAngle() == ArrangeAngle.Direction.Vertical) {
                dim.width = Math.max(dim.width, childRect.width);
                dim.height += childRect.height;
            } else {
                dim.width += childRect.width;
                dim.height = Math.max(dim.height, childRect.height);
            }
            count++;
        }
    }
    if (count > 1) {
        if (ArrangeAngle.createInstance().getAngle() == ArrangeAngle.Direction.Vertical) {
            dim.height += (VERTICAL_CONTEXT_SPACING * (count - 1));
        } else {
            dim.width += (HORIZONTAL_CONTEXT_SPACING * (count - 1));
        }
    }
    return dim;
}
项目:d-case_editor    文件:DcaseGraphVisitor.java   
/**
 * Adds the NodeEx that represents the specified node.
 * 
 * @param node the node.
 * @return the added NodeEx.
 */
protected NodeEx addNodeEx(Node node) {
    NodeEx nodeEx = getNodeEx(node);
    if (nodeEx == null) {
        nodeEx = new NodeEx(node);
        DcaseDirectedGraph.setNodeEx(node, nodeEx);
    }
    return nodeEx;
}