Java Code Examples for org.eclipse.draw2d.Connection#getPoints()
The following examples show how to use
org.eclipse.draw2d.Connection#getPoints() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RailroadConnectionRouter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void route(Connection connection) { PointList points = connection.getPoints(); points.removeAllPoints(); Point startPoint = getStartPoint(connection); connection.translateToRelative(startPoint); points.addPoint(startPoint); Point endPoint = getEndPoint(connection); connection.translateToRelative(endPoint); Object constraint = getConstraint(connection); if (constraint instanceof BendConstraint) { int dx = Integer.signum(endPoint.x - startPoint.x) * ILayoutConstants.CONNECTION_RADIUS; int dy = Integer.signum(endPoint.y - startPoint.y) * ILayoutConstants.CONNECTION_RADIUS; // can be simplified but becomes unreadable if (((BendConstraint) constraint).isConvex()) { if (((BendConstraint) constraint).isStart()) { points.addPoint(startPoint.x - dx, startPoint.y + dy); points.addPoint(startPoint.x - dx, endPoint.y - dy); points.addPoint(startPoint.x , endPoint.y); } else { points.addPoint(endPoint.x, startPoint.y); points.addPoint(endPoint.x + dx, startPoint.y + dy); points.addPoint(endPoint.x + dx, endPoint.y - dy); } } else { if (((BendConstraint) constraint).isStart()) { points.addPoint(startPoint.x + dx, startPoint.y + dy); points.addPoint(startPoint.x + dx, endPoint.y - dy); points.addPoint(startPoint.x + 2 * dx, endPoint.y); } else { points.addPoint(endPoint.x - 2 * dx, startPoint.y); points.addPoint(endPoint.x - dx, startPoint.y + dy); points.addPoint(endPoint.x - dx, endPoint.y - dy); } } } points.addPoint(endPoint); connection.setPoints(points); }
Example 2
Source File: FixedBendpointEditPolicy.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private PointList getInitialPoints(Connection connection) { ConnData cd = router.getCD(connection); if (cd != null) { return relbpUtil.convertToPointList(cd.initialVisualPoints); } return connection.getPoints(); }
Example 3
Source File: Animation.java From olca-app with Mozilla Public License 2.0 | 5 votes |
static boolean playbackState(Connection conn) { if (!PLAYBACK) { return false; } PointList list1 = (PointList) initialStates.get(conn); PointList list2 = (PointList) finalStates.get(conn); if (list1 == null) { conn.setVisible(false); return true; } if (list1.size() == list2.size()) { Point pt1 = new Point(), pt2 = new Point(); PointList points = conn.getPoints(); points.removeAllPoints(); for (int i = 0; i < list1.size(); i++) { list1.getPoint(pt2, i); list2.getPoint(pt1, i); pt1.x = (int) Math.round(pt1.x * progress + (1 - progress) * pt2.x); pt1.y = (int) Math.round(pt1.y * progress + (1 - progress) * pt2.y); points.addPoint(pt1); } conn.setPoints(points); } return true; }
Example 4
Source File: TreeConnectionRouter.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override public void route(Connection conn) { // pre route NULL.route(conn); // get points PointList points = conn.getPoints(); Point first = points.getFirstPoint(); Point last = points.getLastPoint(); // distance from to point to connection anchor final int trans = GraphLayoutManager.verticalSpacing / 4; // create new list PointList newPoints = new PointList(); // add first point newPoints.addPoint(first); // add 2 new points newPoints.addPoint(first.x, first.y - trans); newPoints.addPoint(last.x, last.y + trans); // add last point newPoints.addPoint(last); // set new list conn.setPoints(newPoints); }
Example 5
Source File: ConnectionRouterImp.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override public void route(Connection conn) { NULL.route(conn); PointList points = conn.getPoints(); Point start = points.getFirstPoint(); Point end = points.getLastPoint(); points.removeAllPoints(); points.addPoint(start); if (start.y > end.y) routeBottomToTop(start, end, points); else routeTopToBottom(start, end, points); points.addPoint(end); }