/** Constructor. */
  public TilePatternsView() {
    super();

    tilePatternIcons = new ArrayList<TilePatternIcon>();

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // tileset properties
    // the tile pattern list
    // view of the current tile pattern

    // tileset properties
    tilesetPropertiesView = new TilesetPropertiesView();
    tilesetPropertiesView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 120));
    tilesetPropertiesView.setAlignmentX(Component.LEFT_ALIGNMENT);

    // list
    tilePatternsListModel = new TilePatternsListModel();
    tilePatternsList = new JList(tilePatternsListModel);
    tilePatternsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tilePatternsList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    tilePatternsList.setVisibleRowCount(-1); // make the rows as wide as possible
    tilePatternsList
        .getSelectionModel()
        .addListSelectionListener(new TilePatternListSelectionListener());
    tilePatternsList.setCellRenderer(new TilePatternListRenderer());

    tilePatternsList.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_DELETE) {
              if (tileset != null && tileset.getSelectedTilePattern() != null) {
                tileset.removeTilePattern();
              }
            }
          }
        });

    JScrollPane listScroller = new JScrollPane(tilePatternsList);
    listScroller.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    listScroller.setAlignmentX(Component.LEFT_ALIGNMENT);

    // tile view
    tilePatternView = new TilePatternView();
    tilePatternView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 300));
    tilePatternView.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(tilesetPropertiesView);
    add(Box.createRigidArea(new Dimension(0, 5)));
    add(listScroller);
    add(Box.createRigidArea(new Dimension(0, 5)));
    add(tilePatternView);
  }
  /**
   * Constructor.
   *
   * @param tileset A tileset.
   * @param oldPatternId The tile pattern id to change in this tileset.
   */
  public TilePatternIdRefactoringComponent(Tileset tileset, String oldPatternId) {
    super();

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel patternIdPanel = new JPanel();
    patternIdPanel.setLayout(new BoxLayout(patternIdPanel, BoxLayout.LINE_AXIS));
    patternIdPanel.setAlignmentX(1.0f);
    JLabel patternIdLabel = new JLabel("Tile pattern id:");
    patternIdPanel.add(patternIdLabel);
    patternIdPanel.add(Box.createHorizontalStrut(10));
    patternIdField = new JTextField(oldPatternId, 20);
    patternIdField.selectAll();
    patternIdPanel.add(patternIdField);
    patternIdPanel.setAlignmentX(0.0f);
    add(patternIdPanel);
    add(Box.createVerticalStrut(10));
    updateMapsCheckBox = new JCheckBox("Update references in existing maps");
    updateMapsCheckBox.setSelected(true);
    updateMapsCheckBox.setAlignmentX(0.0f);
    add(updateMapsCheckBox);
  }