/** * Routes the given connection. Calls the 'next' router first (if one exists) and if no bendpoints * were added by the next router, collisions are dealt with by calling {@link * #handleCollision(PointList, int)}. * * @param conn The connection to route */ public void route(Connection conn) { if (next() != null) next().route(conn); else { conn.getPoints().removeAllPoints(); setEndPoints(conn); } if (conn.getPoints().size() == 2) { PointList points = conn.getPoints(); HashKey connectionKey = new HashKey(conn); ArrayList connectionList = connections.get(connectionKey); if (connectionList != null) { int index; if (connectionList.contains(conn)) { index = connectionList.indexOf(conn) + 1; } else { index = connectionList.size() + 1; connections.put(connectionKey, conn); } handleCollision(points, index); conn.setPoints(points); } else { connections.put(connectionKey, conn); } } }
/** * 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); }