Exemplo n.º 1
0
  /**
   * Removes a {@link TileSet} from the map, and removes any tiles in the set from the map layers. A
   * {@link MapChangedEvent} is fired when all processing is complete.
   *
   * @param tileset TileSet to remove
   * @throws LayerLockedException when the tileset is in use on a locked layer
   */
  public void removeTileset(TileSet tileset) throws LayerLockedException {
    // Sanity check
    final int tilesetIndex = tilesets.indexOf(tileset);
    if (tilesetIndex == -1) return;

    // Go through the map and remove any instances of the tiles in the set
    Iterator<Object> tileIterator = tileset.iterator();
    while (tileIterator.hasNext()) {
      Tile tile = (Tile) tileIterator.next();
      Iterator<MapLayer> layerIterator = getLayers();
      while (layerIterator.hasNext()) {
        MapLayer ml = (MapLayer) layerIterator.next();
        if (ml instanceof TileLayer) {
          ((TileLayer) ml).removeTile(tile);
        }
      }
    }

    tilesets.remove(tileset);
    fireTilesetRemoved(tilesetIndex);
  }