/**
   * Updates all coordinates
   *
   * @todo Optimise. Some info can be cached
   * @todo Handle m:n (leftY/rightY etc)
   */
  public void update() {
    /*
     *  int leftY = _leftTable.getY() + _leftTable.getColumnY(_leftRole.getColumnMap().getPrimaryKey());
     *  int rightY;
     *  if (!_leftRole.getRelation().isMany2Many()) {
     *  rightY = _rightTable.getY() + _rightTable.getColumnY(_leftRole.getColumnMap().getForeignKey());
     *  }
     *  else {
     *  rightY = _rightTable.getY() + _rightTable.getColumnY(_rightRole.getColumnMap().getPrimaryKey());
     *  }
     */
    int leftY = _leftTable.getY() + _leftColumnY;
    int rightY = _rightTable.getY() + _rightColumnY;

    // find out which table is farthest west (and east)
    JTablePanel westTable;
    JTablePanel eastTable;
    int westY;
    int eastY;
    Line2D.Float[] westLines;
    Line2D.Float[] eastLines;
    int[] westEdgeY;
    int[] eastEdgeY;

    _leftIsWest = _leftTable.getX() < _rightTable.getX();

    if (_leftIsWest) {
      westTable = _leftTable;
      eastTable = _rightTable;
      westY = leftY;
      eastY = rightY;
      westLines = _leftLines;
      eastLines = _rightLines;
      westEdgeY = _leftEdgeY;
      eastEdgeY = _rightEdgeY;
    } else {
      westTable = _rightTable;
      eastTable = _leftTable;
      westY = rightY;
      eastY = leftY;
      westLines = _rightLines;
      eastLines = _leftLines;
      westEdgeY = _rightEdgeY;
      eastEdgeY = _leftEdgeY;
    }

    // find out whether the tables are more or less vertically aligned
    boolean aligned = (eastTable.getX() - westTable.getX()) < eastTable.getWidth() / 2;
    // TODO: handle different widths

    int westX;
    if (aligned) {
      westX = westTable.getX() - 10;
      for (int i = 0; i < westEdgeY.length; i++) {
        westLines[i].setLine(westX, westY, westTable.getX(), westEdgeY[i] + westTable.getY());
      }
    } else {
      westX = westTable.getX() + westTable.getWidth() + 10;
      for (int i = 0; i < westEdgeY.length; i++) {
        westLines[i].setLine(
            westX, westY, westTable.getX() + westTable.getWidth(), westEdgeY[i] + westTable.getY());
      }
    }
    int eastX = eastTable.getX() - 10;

    for (int i = 0; i < eastEdgeY.length; i++) {
      eastLines[i].setLine(eastX, eastY, eastTable.getX(), eastEdgeY[i] + eastTable.getY());
    }

    _mainLine.setLine(westX, westY, eastX, eastY);

    setCardinalityPoints();
  }