Package org.eclipse.zest.layouts.exampleStructures

Examples of org.eclipse.zest.layouts.exampleStructures.SimpleNode


      }
    }

    private void paintRelationship(LayoutRelationship rel, Graphics g) {

      SimpleNode src = (SimpleNode) rel.getSourceInLayout();
      SimpleNode dest = (SimpleNode) rel.getDestinationInLayout();

      // Add bend points if required
      if (((SimpleRelationship) rel).getBendPoints() != null && ((SimpleRelationship) rel).getBendPoints().length > 0) {
        drawBendPoints(rel, g);
      } else {
        double srcX = src.getX() + src.getWidth() / 2.0;
        double srcY = src.getY() + src.getHeight() / 2.0;
        double destX = dest.getX() + dest.getWidth() / 2.0;
        double destY = dest.getY() + dest.getHeight() / 2.0;
        double dx = getLength(srcX, destX);
        double dy = getLength(srcY, destY);
        double theta = Math.atan2(dy, dx);
        drawRelationship(src, dest, theta, srcX, srcY, destX, destY, g);
View Full Code Here


     */
    private void drawBendPoints(LayoutRelationship rel, Graphics g) {
      final String DUMMY_TITLE = "dummy";
      LayoutBendPoint bp;

      SimpleNode startEntity = (SimpleNode) rel.getSourceInLayout();
      SimpleNode destEntity = (SimpleNode) rel.getDestinationInLayout();
      double srcX = startEntity.getX();
      double srcY = startEntity.getY();

      // Transform the bendpoints to this coordinate system
      LayoutBendPoint[] bendPoints = ((SimpleRelationship) rel).getBendPoints();

      srcX = bendPoints[1].getX();
      srcY = bendPoints[1].getY();
      int bpNum = 2;
      while (bpNum < bendPoints.length - 1) { // ignore first and last bendpoints (src and dest)
        int currentBpNum = bpNum;
        bp = bendPoints[bpNum];
        if (bp.getIsControlPoint()) {
          if (bendPoints[bpNum + 1].getIsControlPoint()) {
            destEntity = new SimpleNode(DUMMY_TITLE, bendPoints[bpNum + 2].getX(), bendPoints[bpNum + 2].getY(), 0.01, 0.01);
            drawCurvedRelationship(srcX, srcY, bp.getX(), bp.getY(), bendPoints[bpNum + 1].getX(), bendPoints[bpNum + 1].getY(), bendPoints[bpNum + 2].getX(), bendPoints[bpNum + 2].getY(), g);
            bpNum += 4;
          } else {
            destEntity = new SimpleNode(DUMMY_TITLE, bp.getX(), bp.getY(), 0.01, 0.01);
          }
        } else {
          drawRelationship(srcX, srcY, bp.getX(), bp.getY(), g);
          bpNum++;
          destEntity = new SimpleNode(DUMMY_TITLE, bp.getX(), bp.getY(), 0.01, 0.01);
        }
        startEntity = destEntity;
        if (currentBpNum == bendPoints.length - 2) { // last point
          // draw an arrow in the middle of the line
          double dx = getLength(srcX, destEntity.getX());
          double dy = getLength(srcY, destEntity.getY());
          double theta = Math.atan2(dy, dx);
          drawArrow(theta, srcX, srcY, dx, dy, g);
        } else {
          srcX = startEntity.getX();
          srcY = startEntity.getY();
View Full Code Here

TOP

Related Classes of org.eclipse.zest.layouts.exampleStructures.SimpleNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.