@Override
  protected List<?> createSelectionHandles() {
    List<BendpointHandle> list = new ArrayList<BendpointHandle>();
    ConnectionEditPart connEP = (ConnectionEditPart) getHost();
    PointList points = getConnection().getPoints();
    List<?> bendPoints = (List<?>) getConnection().getRoutingConstraint();
    int bendPointIndex = 0;
    Point currBendPoint = null;

    if (bendPoints == null) bendPoints = NULL_CONSTRAINT;
    else if (!bendPoints.isEmpty()) currBendPoint = ((Bendpoint) bendPoints.get(0)).getLocation();

    for (int i = 0; i < points.size() - 1; i++) {
      // Put a create handle on the middle of every segment
      list.add(new SnappingBendpointCreationHandle(connEP, bendPointIndex, i));

      // If the current user bendpoint matches a bend location, show a
      // move handle
      if (i < points.size() - 1
          && bendPointIndex < bendPoints.size()
          && currentBendPointMatches(currBendPoint, points.getPoint(i + 1))) {
        list.add(new SnappingBendpointMoveHandle(connEP, bendPointIndex, i + 1));

        // Go to the next user bendpoint
        bendPointIndex++;
        if (bendPointIndex < bendPoints.size())
          currBendPoint = ((Bendpoint) bendPoints.get(bendPointIndex)).getLocation();
      }
    }
    return list;
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics)
   */
  @Override
  public void paintFigure(Graphics graphics) {
    graphics.setLineWidth(2);

    Rectangle r = getBounds();

    // Define the points of a diamond
    Point p1 = new Point(r.x, r.y + r.height / 2);
    Point p2 = new Point(r.x + r.width / 2, r.y);
    Point p3 = new Point(r.x + r.width, r.y + r.height / 2);
    Point p4 = new Point(r.x + r.width / 2, r.y + r.height - 1);

    PointList pointList = new PointList();

    pointList.addPoint(p1);
    pointList.addPoint(p2);
    pointList.addPoint(p3);
    pointList.addPoint(p4);

    // Fill the shape
    graphics.fillPolygon(pointList);

    // Draw the outline
    graphics.drawLine(p1, p2);
    graphics.drawLine(p2, p3);
    graphics.drawLine(p3, p4);
    graphics.drawLine(p4, p1);
  }
 static {
   RECTANGLE_TIP.addPoint(-2, 0);
   RECTANGLE_TIP.addPoint(-1, 1);
   RECTANGLE_TIP.addPoint(-0, 0);
   RECTANGLE_TIP.addPoint(-1, -1);
   RECTANGLE_TIP.addPoint(-2, 0);
 }
    /** @generated NOT */
    private RotatableDecoration createTargetDecoration() {
      PolygonDecoration df = new PolygonDecoration();
      df.setLineWidth(1);

      PointList pl = new PointList();

      pl.addPoint(getMapMode().DPtoLP(4), getMapMode().DPtoLP(1));
      pl.addPoint(getMapMode().DPtoLP(3), getMapMode().DPtoLP(3));
      pl.addPoint(getMapMode().DPtoLP(1), getMapMode().DPtoLP(4));
      pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(4));
      pl.addPoint(getMapMode().DPtoLP(-3), getMapMode().DPtoLP(3));
      pl.addPoint(getMapMode().DPtoLP(-4), getMapMode().DPtoLP(1));
      pl.addPoint(getMapMode().DPtoLP(-4), getMapMode().DPtoLP(-1));
      pl.addPoint(getMapMode().DPtoLP(-3), getMapMode().DPtoLP(-3));
      pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(-4));
      pl.addPoint(getMapMode().DPtoLP(1), getMapMode().DPtoLP(-4));
      pl.addPoint(getMapMode().DPtoLP(3), getMapMode().DPtoLP(-3));
      pl.addPoint(getMapMode().DPtoLP(4), getMapMode().DPtoLP(-1));
      pl.addPoint(getMapMode().DPtoLP(4), getMapMode().DPtoLP(1));

      df.setTemplate(pl);
      df.setScale(getMapMode().DPtoLP(1), getMapMode().DPtoLP(1));
      df.setBackgroundColor(ColorConstants.white);
      return df;
    }
  public void performLayout() {
    Rectangle fromBox = fromFigure.getLayoutDimensions();
    Rectangle toBox = toFigure.getLayoutDimensions();

    Point fromPoint = pointOnSide(fromBox, exitSide, exitTweak);
    Point toPoint = pointOnSide(toBox, entrySide, entryTweak);

    Point middlePoint;

    if (isHorizontal(exitSide))
      if (isHorizontal(entrySide)) { // both horizontal, ignore entryTweak and entryPoint.y
        middlePoint = new Point((fromPoint.x + toPoint.x) / 2, fromPoint.y);
        toPoint.y = fromPoint.y; // make line vertical
      } else { // from horizontal, to vertical
        middlePoint =
            new Point(
                toBox.x + toBox.width / 2 + entryTweak, fromBox.y + fromBox.height / 2 + exitTweak);
      }
    else if (isHorizontal(entrySide)) { // from vertical, to horizontal
      middlePoint =
          new Point(
              fromBox.x + fromBox.width / 2 + exitTweak, toBox.y + toBox.height / 2 + entryTweak);
    } else { // both vertical, ignore entryTweak and entryPoint.x
      middlePoint = new Point(fromPoint.x, (fromPoint.y + toPoint.y) / 2);
      toPoint.x = fromPoint.x; // make line horizontal
    }

    nonTranslatedPoints = new PointList();
    nonTranslatedPoints.addPoint(fromPoint);
    nonTranslatedPoints.addPoint(middlePoint);
    nonTranslatedPoints.addPoint(toPoint);

    if (actionFigure != null) actionFigure.performCenteredLayout(middlePoint.x, middlePoint.y);
  }
 protected PointList getTemplate() {
   PointList pl = new PointList();
   pl.addPoint(-1, -2);
   pl.addPoint(1, 0);
   pl.addPoint(-1, 2);
   pl.addPoint(-1, -2);
   return pl;
 }
 protected List<BezierPoint> getBezierPoints(PointList points, double zoom) {
   List<BezierPoint> ret = new ArrayList<BezierPoint>(points.size());
   for (int i = 0; i < points.size(); i++) {
     int bezierDistance = (int) (getGeneralBezierDistance() * zoom);
     Point point = points.getPoint(i);
     ret.add(new BezierPoint(point.x, point.y, bezierDistance, bezierDistance));
   }
   return ret;
 }
 /**
  * Create a decoration for the composition
  *
  * @return the new decoration
  */
 private PolygonDecoration createCompositionDecoration() {
   PolygonDecoration decoration = new PolygonDecoration();
   PointList decorationPointList = new PointList();
   decorationPointList.addPoint(0, 0);
   decorationPointList.addPoint(-1, 1);
   decorationPointList.addPoint(-2, 0);
   decorationPointList.addPoint(-1, -1);
   decoration.setTemplate(decorationPointList);
   decoration.setScale(10, 5);
   return decoration;
 }
Beispiel #9
0
 /**
  * Sets the start and end points for the given connection.
  *
  * @param conn The connection
  */
 protected void setEndPoints(Connection conn) {
   PointList points = conn.getPoints();
   points.removeAllPoints();
   Point start = getStartPoint(conn);
   Point end = getEndPoint(conn);
   conn.translateToRelative(start);
   conn.translateToRelative(end);
   points.addPoint(start);
   points.addPoint(end);
   conn.setPoints(points);
 }
 private Point getPointForEnd(PointList points) {
   Point point = null;
   if (end == End_c.Middle) {
     point = points.getMidpoint();
   } else if (end == End_c.Start) {
     point = points.getFirstPoint();
   } else if (end == End_c.End) {
     point = points.getLastPoint();
   }
   return point;
 }
Beispiel #11
0
 public void paintFigure(Graphics g) {
   Rectangle r = bounds;
   PointList pl = new PointList(4);
   pl.addPoint(r.x + r.width / 2, r.y);
   pl.addPoint(r.x, r.y + r.height / 2);
   pl.addPoint(r.x + r.width / 2, r.y + r.height - 1);
   pl.addPoint(r.x + r.width, r.y + r.height / 2);
   g.drawPolygon(pl);
   g.drawText(message, r.x + r.width / 4 + 5, r.y + 3 * r.height / 8);
   g.drawText("N", r.x + 7 * r.width / 8, r.y + 3 * r.height / 8);
   g.drawText("Y", r.x + r.width / 2 - 2, r.y + 3 * r.height / 4);
 }
 /**
  * Create a decoration for the aggregation
  *
  * @return the new decoration
  */
 private PolygonDecoration createAggregationDecoration() {
   PolygonDecoration decoration = new PolygonDecoration();
   PointList decorationPointList = new PointList();
   decorationPointList.addPoint(0, 0);
   decorationPointList.addPoint(-1, 1);
   decorationPointList.addPoint(-2, 0);
   decorationPointList.addPoint(-1, -1);
   decoration.setBackgroundColor(ModelerColorConstants.white);
   decoration.setTemplate(decorationPointList);
   decoration.setScale(10, 5);
   return decoration;
 }
Beispiel #13
0
 /** @generated */
 private RotatableDecoration createTargetDecoration() {
   PolygonDecoration df = new PolygonDecoration();
   df.setFill(true);
   df.setBackgroundColor(ColorConstants.black);
   PointList pl = new PointList();
   pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
   pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(1));
   pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(-1));
   pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
   df.setTemplate(pl);
   df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
   return df;
 }
 @Override
 public boolean test() throws Exception {
   boolean location = false;
   PointList points = ((PolylineConnectionEx) connectionEditPart.getFigure()).getPoints();
   if (checkFirstBendpoint) {
     location = !initialLocation.equals(points.getFirstPoint());
   } else if (checkLastBendpoint) {
     location = !initialLocation.equals(points.getLastPoint());
   } else if (bendpointPosition >= 0 || bendpointPosition < points.size()) {
     location = !initialLocation.equals(points.getPoint(bendpointPosition));
   }
   return location;
 }
  /** @see IFigure#validate() */
  @Override
  public void validate() {
    super.validate();
    Rectangle r = new Rectangle();
    r.setBounds(getBounds());
    r.crop(getInsets());
    r.resize(-1, -1);
    int size;
    switch (direction & (NORTH | SOUTH)) {
      case 0: // East or west.
        size = Math.min(r.height / 2, r.width);
        r.x += (r.width - size) / 2;
        break;
      default: // North or south
        size = Math.min(r.height, r.width / 2);
        r.y += (r.height - size) / 2;
        break;
    }

    size = Math.max(size, 1); // Size cannot be negative

    Point head, p2, p3;

    switch (direction) {
      case NORTH:
        head = new Point(r.x + r.width / 2, r.y);
        p2 = new Point(head.x - size, head.y + size);
        p3 = new Point(head.x + size, head.y + size);
        break;
      case SOUTH:
        head = new Point(r.x + r.width / 2, r.y + size);
        p2 = new Point(head.x - size, head.y - size);
        p3 = new Point(head.x + size, head.y - size);
        break;
      case WEST:
        head = new Point(r.x, r.y + r.height / 2);
        p2 = new Point(head.x + size, head.y - size);
        p3 = new Point(head.x + size, head.y + size);
        break;
      default:
        head = new Point(r.x + size, r.y + r.height / 2);
        p2 = new Point(head.x - size, head.y - size);
        p3 = new Point(head.x - size, head.y + size);
    }
    triangle.removeAllPoints();
    triangle.addPoint(head);
    triangle.addPoint(p2);
    triangle.addPoint(p3);
  }
  /**
   * getPointsFromConstraint Utility method retrieve the PointList equivalent of the bendpoint
   * constraint set in the Connection.
   *
   * @param conn Connection to retrieve the constraint from.
   * @return PointList list of points that is the direct equivalent of the set constraint.
   */
  public PointList getPointsFromConstraint(final Connection conn) {
    final List bendpoints = (List) conn.getRoutingConstraint();
    if (bendpoints == null) {
      return new PointList();
    }

    final PointList points = new PointList(bendpoints.size());
    for (int i = 0; i < bendpoints.size(); i++) {
      final Bendpoint bp = (Bendpoint) bendpoints.get(i);
      points.addPoint(bp.getLocation());
    }

    DTreeRouter.straightenPoints(points, MapModeUtil.getMapMode(conn).DPtoLP(3));
    return points;
  }
 public DsToExcelConnectionFigure(DatasetToGridConnection con) {
   super();
   this.con = con;
   PolygonDecoration pd = new PolygonDecoration();
   PointList pl = new PointList();
   pl.addPoint(0, 0);
   pl.addPoint(-2, 2);
   pl.addPoint(0, 0);
   pl.addPoint(-2, -2);
   pd.setTemplate(pl);
   setLineStyle(SWT.LINE_DASH);
   setTargetDecoration(pd);
   setConnectionRouter(new BendpointConnectionRouter());
   setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW));
 }
 /**
  * Due to the on the fly creation of bendpoints we must gather the points using the routing
  * constraint as the connection may not be routed yet, meaning the points in the connection are
  * not up to date
  *
  * @param connectionFigure
  * @return
  */
 private PointList getPoints(Connection connectionFigure) {
   PointList points = new PointList();
   if (connectionFigure.getConnectionRouter() instanceof RectilinearRouter) {
     points.addAll(connectionFigure.getPoints());
     ((RectilinearRouter) connectionFigure.getConnectionRouter()).route(connectionFigure);
     return points;
   } else {
     List<?> bendpoints =
         (List<?>) connectionFigure.getConnectionRouter().getConstraint(connectionFigure);
     if (bendpoints == null) {
       bendpoints = Collections.EMPTY_LIST;
     }
     Point firstPoint = connectionFigure.getPoints().getFirstPoint();
     Point lastPoint = connectionFigure.getPoints().getLastPoint();
     if ((firstPoint.x == 100 && firstPoint.y == 100)
         || (lastPoint.x == 100 && lastPoint.y == 100)) {
       // the connection may need to be routed
       // as well as the source and target if connectors
       if (parent instanceof ConnectorEditPart) {
         ConnectorEditPart con = (ConnectorEditPart) parent;
         if (con.getSource() instanceof ConnectorEditPart) {
           ConnectorEditPart source = (ConnectorEditPart) con.getSource();
           source.getConnectionFigure().getConnectionRouter().route(source.getConnectionFigure());
         }
         if (con.getTarget() instanceof ConnectorEditPart) {
           ConnectorEditPart target = (ConnectorEditPart) con.getTarget();
           target.getConnectionFigure().getConnectionRouter().route(target.getConnectionFigure());
         }
       }
       connectionFigure.getConnectionRouter().route(connectionFigure);
     }
     if (connectionFigure.getPoints().size() != bendpoints.size()) {
       // rectilinear will have the start and end points in the
       // routing constraint
       points.addPoint(connectionFigure.getPoints().getFirstPoint());
     }
     for (int i = 0; i < bendpoints.size(); i++) {
       Bendpoint bp = (Bendpoint) bendpoints.get(i);
       points.addPoint(bp.getLocation());
     }
     if (connectionFigure.getPoints().size() != bendpoints.size()) {
       points.addPoint(connectionFigure.getPoints().getLastPoint());
     }
   }
   return points;
 }
 protected FlowFigure createFlowFigure(boolean directed) {
   FlowFigure flowFigure = new FlowFigure();
   if (directed) {
     PolygonDecoration decoration = new PolygonDecoration();
     PointList template = new PointList();
     template.addPoint(0, -LINE_WIDTH / 2);
     template.addPoint(0, LINE_WIDTH / 2);
     template.addPoint(-ARROW_LENGTH, LINE_WIDTH / 2 + 10);
     template.addPoint(-ARROW_LENGTH, -(LINE_WIDTH / 2 + 10));
     decoration.setTemplate(template);
     decoration.setScale(1, 1);
     flowFigure.setTargetDecoration(decoration);
   }
   flowFigure.setForegroundColor(DASHBOARD_FG);
   flowFigure.setLineWidth(LINE_WIDTH);
   return flowFigure;
 }
  private void processStaleConnections() {
    Iterator<Connection> iter = staleConnections.iterator();
    if (iter.hasNext() && connectionToPaths == null) {
      connectionToPaths = new HashMap<Connection, Path>();
      hookAll();
    }

    while (iter.hasNext()) {
      Connection conn = (Connection) iter.next();

      Path path = (Path) connectionToPaths.get(conn);
      if (path == null) {
        path = new Path(conn);
        connectionToPaths.put(conn, path);
        algorithm.addPath(path);
      }

      List<?> constraint = (List<?>) getConstraint(conn);
      if (constraint == null) {
        constraint = Collections.EMPTY_LIST;
      }

      Point start = conn.getSourceAnchor().getReferencePoint().getCopy();
      Point end = conn.getTargetAnchor().getReferencePoint().getCopy();

      container.translateToRelative(start);
      container.translateToRelative(end);

      path.setStartPoint(start);
      path.setEndPoint(end);

      if (!constraint.isEmpty()) {
        PointList bends = new PointList(constraint.size());
        for (int i = 0; i < constraint.size(); i++) {
          Bendpoint bp = (Bendpoint) constraint.get(i);
          bends.addPoint(bp.getLocation());
        }
        path.setBendPoints(bends);
      } else {
        path.setBendPoints(null);
      }

      isDirty |= path.isDirty;
    }
    staleConnections.clear();
  }
  /** {@inheritDoc} */
  public PointList getDrawPoints() {
    PointList result = new PointList();
    Rectangle bounds = getBounds();
    double cellWidth = bounds.preciseWidth() * 0.618;
    double cellHeight = bounds.preciseHeight() / 2;

    result.addPoint(new PrecisionPoint(0.0, 0.0));
    //		result.addPoint(new PrecisionPoint(cellWidth * 2, 0.0));
    result.addPoint(new PrecisionPoint(cellWidth, 0.0));
    result.addPoint(new PrecisionPoint(bounds.preciseWidth(), cellHeight));
    result.addPoint(new PrecisionPoint(cellWidth, bounds.preciseHeight()));

    //		result.addPoint(new PrecisionPoint(cellWidth * 2, bounds.preciseHeight()));
    result.addPoint(new PrecisionPoint(0.0, bounds.preciseHeight()));
    //		result.addPoint(new PrecisionPoint(cellWidth, cellHeight));

    return result;
  }
  /**
   * UpdateConstraint Updates the constraint value for the connection based on the tree vertex.
   *
   * @param conn Connection whose constraint is to be updated.
   */
  protected void updateConstraint(final Connection conn) {
    boolean update =
        conn != null && conn.getSourceAnchor() != null && conn.getTargetAnchor() != null;
    update =
        update
            && conn.getSourceAnchor().getOwner() != null
            && conn.getTargetAnchor().getOwner() != null;
    if (update) {
      if (isUpdatingPeers()) {
        return;
      }

      List bendpoints = (List) conn.getRoutingConstraint();
      if (bendpoints == null) {
        bendpoints = new ArrayList(conn.getPoints().size());
      }

      final Point sourceRefPoint = conn.getSourceAnchor().getReferencePoint();
      conn.translateToRelative(sourceRefPoint);

      final Point targetRefPoint = conn.getTargetAnchor().getReferencePoint();
      conn.translateToRelative(targetRefPoint);

      final Point ptTrunk = getTrunkLocation(conn);
      final Point ptSource = getBranchRouter().getSourceLocation(conn, ptTrunk);

      bendpoints.clear();
      final PointList pts = getBranchRouter().recreateBranch(conn, ptSource, ptTrunk);
      for (int i = 0; i < pts.size(); i++) {
        final Bendpoint bp = new AbsoluteBendpoint(pts.getPoint(i));
        bendpoints.add(bp);
      }

      setUpdatingPeers(true);

      try {
        setConstraint(conn, bendpoints);
        conn.invalidate();
        conn.validate();
      } finally {
        setUpdatingPeers(false);
      }
    }
  }
  public void testMoveShape() {
    List newConstraint = initializeConstraint(test1, test1Start, test1End, test1Other);

    getTreeRouter().setConstraint(getConnection1(), newConstraint);
    getTreeRouter().route(getConnection2());
    getTreeRouter().route(getConnection1());

    Rectangle newBounds = new Rectangle(test1Start);
    newBounds.translate(4000, 4000);
    getConnection1().getSourceAnchor().getOwner().setBounds(newBounds);
    getTreeRouter().route(getConnection1());

    getConnection2().validate();

    PointList c1Pts = getConnection1().getPoints();
    PointList c2Pts = getConnection2().getPoints();
    assertTrue(
        "Trunk values don't match after tree routing", //$NON-NLS-1$
        c1Pts.getPoint(2).equals(c2Pts.getPoint(2)));
  }
  /** @param newConstraint */
  private void validateConstraint(List newConstraint) {
    getTreeRouter().setConstraint(getConnection1(), newConstraint);
    PointList ptl1 = getTreeRouter().getPointsFromConstraint(getConnection1());

    getTreeRouter().route(getConnection2());
    getTreeRouter().route(getConnection1());

    assertTrue(
        "Connection1 points aren't orthogonal", //$NON-NLS-1$
        getTreeRouter().isOrthogonalTreeBranch(getConnection1(), ptl1));

    PointList c1Pts = getConnection1().getPoints();
    PointList c2Pts = getConnection2().getPoints();
    assertTrue(
        "Connection2 points aren't orthogonal", //$NON-NLS-1$
        getTreeRouter().isOrthogonalTreeBranch(getConnection2(), c2Pts));
    assertTrue(
        "Trunk values don't match after tree routing", //$NON-NLS-1$
        c1Pts.getPoint(2).equals(c2Pts.getPoint(2)));
  }
 private Point getAbsoluteEdgeExtremity(
     ConnectionNodeEditPart editPart, boolean isStart, Float[] preferPosition) {
   if (editPart == null) {
     return null;
   }
   PointList points = editPart.getConnectionFigure().getPoints().getCopy();
   if (points.size() == 2
       && new Point(0, 0).equals(points.getFirstPoint())
       && new Point(100, 100).equals(points.getLastPoint())) {
     // not display yet.
     if (preferPosition != null) {
       if (isStart && preferPosition[0] != null) {
         return new Point(0, preferPosition[0].intValue());
       } else if (!isStart && preferPosition[1] != null) {
         return new Point(0, preferPosition[1].intValue());
       }
     }
     return SequenceUtil.getAbsoluteEdgeExtremity(editPart, isStart, false);
   }
   return SequenceUtil.getAbsoluteEdgeExtremity(editPart, isStart, true);
 }
  /**
   * straightenPoints This is a simpler version of the.
   *
   * @see updateIfNotRectilinear that simply ensures that the lines are horizontal or vertical
   *     without any intelligence in terms of shortest distance around a rectangle.
   * @param newLine PointList to check for rectilinear qualities and change if necessary.
   * @param tolerance int tolerance value by which points will be straightened in HiMetrics
   */
  protected static void straightenPoints(final PointList newLine, final int tolerance) {
    for (int i = 0; i < newLine.size() - 1; i++) {
      final Point ptCurrent = newLine.getPoint(i);
      final Point ptNext = newLine.getPoint(i + 1);

      final int xDelta = Math.abs(ptNext.x - ptCurrent.x);
      final int yDelta = Math.abs(ptNext.y - ptCurrent.y);

      if (xDelta < yDelta) {
        if (xDelta > tolerance) {
          return;
        }
        if (i == newLine.size() - 2) {
          // The last point is more important than the other (not
          // change the end of the line)
          ptCurrent.x = ptNext.x;
        } else {
          ptNext.x = ptCurrent.x;
        }
      } else {
        if (yDelta > tolerance) {
          return;
        }
        if (i == newLine.size() - 2) {
          // The last point is more important than the other (not
          // change the end of the line)
          ptCurrent.y = ptNext.y;
        } else {
          ptNext.y = ptCurrent.y;
        }
      }

      newLine.setPoint(ptNext, i + 1);
    }
  }
  /**
   * This method is used to compute the shapes polygon points. This is currently based on the shapes
   * bounding box.
   *
   * @param rect the rectangle that the shape will fit in
   */
  protected PointList calculatePoints(Rectangle rect) {

    double xOffset = rect.preciseWidth() * factor;
    double yOffset = rect.preciseHeight() * factor;

    PointList points = new PrecisionPointList();

    Point p1 = new PrecisionPoint(rect.preciseX(), rect.preciseY() + yOffset);
    Point p2 = new PrecisionPoint(rect.preciseX() + xOffset, rect.preciseY());
    Point p3 = new PrecisionPoint(rect.preciseX() + rect.preciseWidth() - xOffset, rect.preciseY());
    Point p4 =
        new PrecisionPoint(rect.preciseX() + rect.preciseWidth() - 1, rect.preciseY() + yOffset);
    Point p5 = new PrecisionPoint(p4.preciseX(), rect.preciseY() + rect.preciseHeight() - yOffset);
    Point p6 = new PrecisionPoint(p3.preciseX(), rect.preciseY() + rect.preciseHeight() - 1);
    Point p7 = new PrecisionPoint(p2.preciseX(), p6.preciseY());
    Point p8 = new PrecisionPoint(rect.preciseX(), p5.preciseY());

    points.addPoint(p1);
    points.addPoint(p2);
    points.addPoint(p3);
    points.addPoint(p4);
    points.addPoint(p5);
    points.addPoint(p6);
    points.addPoint(p7);
    points.addPoint(p8);
    points.addPoint(p1);

    return points;
  }
  private boolean trunkVertexEqual(final Connection connMaster, final Connection connSlave) {
    final PointList cmPts = connMaster.getPoints();
    final PointList csPts = connSlave.getPoints();
    if (cmPts.size() > 2 && csPts.size() > 2) {
      return cmPts.getPoint(2).equals(csPts.getPoint(2));
    }

    return false;
  }
 static {
   points.addPoint(2, 10);
   points.addPoint(2, 2);
   points.addPoint(4, 4);
   points.addPoint(6, 5);
   points.addPoint(7, 5);
   points.addPoint(8, 5);
   points.addPoint(10, 4);
   points.addPoint(12, 2);
   points.addPoint(12, 10);
 }
  /**
   * Utility method to determine if the given set of points conforms to the constraints of being a
   * connection tree-branch. 1. Points size must be 4. 2. Source point resides with-in boundary of
   * source shape based on orientation 3. Target point resides with-in boundary of target shape
   * based on orientation
   *
   * @param conn the <code>Connection</code> to test
   * @param points the <code>PointList</code> to test constraints against
   * @return <code>boolean</code> <code>true</code> if points represent valid tree branch, <code>
   *     false</code> otherwise.
   */
  public boolean isTreeBranch(final Connection conn, final PointList points) {
    boolean result = false;
    if (points.size() == 4) {
      // just check if ends are with-in the owner bounding box
      final Rectangle targetBounds = getTargetAnchorRelativeBounds(conn);
      final Rectangle sourceBounds = getSourceAnchorRelativeBounds(conn);

      if (isTopDown(conn)) {
        result =
            (points.getPoint(0).x > sourceBounds.x
                    && points.getPoint(0).x < sourceBounds.x + sourceBounds.width)
                && (points.getPoint(3).x > targetBounds.x
                    && points.getPoint(3).x < targetBounds.x + targetBounds.width);
      } else {
        result =
            (points.getPoint(0).y > sourceBounds.y
                    && points.getPoint(0).y < sourceBounds.y + sourceBounds.height)
                && (points.getPoint(3).y > targetBounds.y
                    && points.getPoint(3).y < targetBounds.y + targetBounds.height);
      }
    }

    return result;
  }