private void moveConstrained(int indexInConnection, Connection c, double diffx, double diffy) { double amountX = diffx, amountY = diffy; int mappedIndex = mapToEditPointIndex(indexInConnection); Point2D p = getConnection().getPoints().get(indexInConnection); if (p.getX() == c.getAbsoluteX1() || p.getX() == c.getAbsoluteX2()) { amountX = 0; } if (p.getY() == c.getAbsoluteY1() || p.getY() == c.getAbsoluteY2()) { amountY = 0; } editpoints.get(mappedIndex).setLocation(p.getX() + amountX, p.getY() + amountY); }
private void insertConnectionPointToNode(Connection c, int outcode, int index) { Point2D newpoint = new Point2D.Double(); Point2D segmentPoint = getConnection().getPoints().get(index); if (outcode == Rectangle2D.OUT_BOTTOM) { newpoint.setLocation(segmentPoint.getX(), c.getAbsoluteY2()); addEditPoint(index, newpoint); } else if (outcode == Rectangle2D.OUT_TOP) { newpoint.setLocation(segmentPoint.getX(), c.getAbsoluteY1()); addEditPoint(index, newpoint); } else if (outcode == Rectangle2D.OUT_LEFT) { newpoint.setLocation(c.getAbsoluteX1(), segmentPoint.getY()); addEditPoint(index, newpoint); } else if (outcode == Rectangle2D.OUT_RIGHT) { newpoint.setLocation(c.getAbsoluteX2(), segmentPoint.getY()); addEditPoint(index, newpoint); } }