/** * 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); } } }