예제 #1
0
  /**
   * 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);
      }
    }
  }
예제 #2
0
 /** @see org.eclipse.draw2d.ConnectionRouter#invalidate(Connection) */
 public void invalidate(Connection conn) {
   if (next() != null) next().invalidate(conn);
   if (conn.getSourceAnchor() == null || conn.getTargetAnchor() == null) return;
   HashKey connectionKey = new HashKey(conn);
   ArrayList connectionList = connections.get(connectionKey);
   int affected = connections.remove(connectionKey, conn);
   if (affected != -1) {
     for (int i = affected; i < connectionList.size(); i++)
       ((Connection) connectionList.get(i)).revalidate();
   } else connections.removeValue(conn);
 }
예제 #3
0
 /** @see org.eclipse.draw2d.ConnectionRouter#remove(Connection) */
 public void remove(Connection conn) {
   if (conn.getSourceAnchor() == null || conn.getTargetAnchor() == null) return;
   HashKey connectionKey = new HashKey(conn);
   ArrayList connectionList = connections.get(connectionKey);
   if (connectionList != null) {
     int index = connections.remove(connectionKey, conn);
     for (int i = index + 1; i < connectionList.size(); i++)
       ((Connection) connectionList.get(i)).revalidate();
   }
   if (next() != null) next().remove(conn);
 }