/** Called when an entry is added to {@link AtlantiObject#TILES}. */
  public void tilesAdded(AtlantiTile tile) {
    Log.info("Adding tile to board " + tile + ".");

    // if we add a tile that is the same as our most recently placed
    // tile, leave the placed tile. otherwise clear it out
    if (!tile.equals(_placedTile)) {
      _placedTile = null;
    }

    // add the tile
    _tiles.add(tile);

    // reference this as our most recently placed tile
    _lastPlacedTile = tile;

    // resort the list
    Collections.sort(_tiles);

    // have the new tile inherit its claim groups
    TileUtil.inheritClaims(_tiles, tile);

    // recompute our desired dimensions and then have our parent
    // adjust to our changed size
    computeDimensions();
  }
  /** Called by our adapter when the mouse is clicked. */
  protected void mouseClicked(MouseEvent evt) {
    int modifiers = evt.getModifiers();

    // if this is a right button click, and we're in piecen placing
    // mode, generate a PLACE_NOTHING notification instead
    if (_placingPiecen && (modifiers & MouseEvent.BUTTON3_MASK) != 0) {
      // stop piecen placement
      _placingPiecen = false;
      // clear out any placed piecen because we're placing nothing
      if (_placedTile != null && _placedTile.piecen != null) {
        _placedTile.piecen = null;
        repaintTile(_placedTile);
      }
      // tell the controller we're done
      _ctrl.placeNothing();

    } else {
      // ignore non-button one presses other than cancel piecen
      // placement
      if ((modifiers & MouseEvent.BUTTON1_MASK) == 0) {
        return;
      }
    }

    // if we have a placing tile and it's in a valid position, we want
    // to dispatch an action letting the controller know that the user
    // placed it
    if (_placingTile != null && _validPlacement) {
      // move the placing tile to the placed tile
      _placedTile = _placingTile;
      _placingTile = null;

      // inherit claims on the placed tile
      TileUtil.inheritClaims(_tiles, _placedTile);

      // post the action
      _ctrl.tilePlaced(_placedTile);

      // move into placing piecen mode
      _placingPiecen = true;

      // recompute our dimensions (which will relayout or repaint)
      computeDimensions();
    }

    // if we're placing a piecen and the piecen is in a valid position, we
    // want to let the controller know that the user placed it
    if (_placingPiecen && _placedTile != null && _placedTile.piecen != null) {
      _ctrl.piecenPlaced(_placedTile.piecen);
      // clear out placing piecen mode
      _placingPiecen = false;
    }
  }