コード例 #1
0
  /**
   * Creates a tileset editor.
   *
   * @param mainWindow The main window of the quest editor.
   * @param tileset Id of the tileset to open.
   * @throws QuestEditorException If the tileset could not be loaded.
   */
  public TilesetEditorPanel(EditorWindow mainWindow, String tilesetId) throws QuestEditorException {
    super(mainWindow, getEditorId(tilesetId));

    setLayout(new BorderLayout());

    // tile patterns list and tileset image

    // tile patterns list
    tilePatternsView = new TilePatternsView();
    tilePatternsView.setAlignmentY(Component.TOP_ALIGNMENT);
    tilePatternsView.setPreferredSize(new Dimension(200, Integer.MAX_VALUE));
    tilePatternsView.setMinimumSize(new Dimension(0, 0));

    // tileset image
    tilesetImageView = new TilesetImageView(true);
    JScrollPane tilesetImageScroller = new JScrollPane(tilesetImageView);
    tilesetImageScroller.setAlignmentY(Component.TOP_ALIGNMENT);

    JSplitPane tilesetPanel =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tilePatternsView, tilesetImageScroller);
    tilesetPanel.setContinuousLayout(true);
    tilesetPanel.setDividerLocation(400);
    // we must put our main panel in another panel
    // otherwise the background color of the window is bad
    add(tilesetPanel);

    tileset = new Tileset(tilesetId);

    // Notify the children views.
    tilePatternsView.setTileset(tileset);
    tilesetImageView.setTileset(tileset);
  }
コード例 #2
0
  /** Closes this editor without confirmation. */
  @Override
  public void close() {
    tileset.deleteObservers();

    // Notify the children views.
    tilePatternsView.setTileset(null);
    tilesetImageView.setTileset(null);
  }