Gridarta Editor
MapTilePanel.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.gui.map.maptilepane;
21 
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import javax.swing.border.TitledBorder;
25 import org.jetbrains.annotations.NotNull;
26 
34 public class MapTilePanel {
35 
36  @NotNull
37  private final TilePanel tilePanel;
38 
46  public MapTilePanel(final int direction, final int @NotNull [] nextFocus, @NotNull final TilePanel tilePanel, @NotNull final String name) {
47  this.tilePanel = tilePanel;
48  final TitledBorder border = new TitledBorder(name);
49  border.setTitleJustification(TitledBorder.CENTER);
50  tilePanel.setBorder(border);
51 
52  final ActionListener actionListener = new ActionListener() {
53 
57  @Override
58  public void actionPerformed(@NotNull final ActionEvent e) {
60  ((AbstractMapTilePane<?, ?, ?>) tilePanel.getParent().getParent()).getTilePath(nextFocus[direction]).tilePanel.activateTextField();
61  }
62 
63  };
64  tilePanel.addTextFieldActionListener(actionListener);
65  }
66 
67  @NotNull
69  return tilePanel;
70  }
71 
72 }
name
name
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:2
net.sf.gridarta.gui.map.maptilepane.MapTilePanel.tilePanel
final TilePanel tilePanel
Definition: MapTilePanel.java:37
net.sf.gridarta.gui.map.maptilepane.MapTilePanel.getTilePanel
TilePanel getTilePanel()
Definition: MapTilePanel.java:68
net.sf.gridarta.gui.map.maptilepane.TilePanel.updateRAState
void updateRAState()
Updates the state of the raSwitch.
Definition: TilePanel.java:257
net.sf.gridarta.gui.map.maptilepane.AbstractMapTilePane
A Panel for managing the tiling of maps.
Definition: AbstractMapTilePane.java:65
net.sf.gridarta.gui.map.maptilepane.MapTilePanel
A MapTilePanel extends a TilePanel with a border and makes focus traversal work within the map tile p...
Definition: MapTilePanel.java:34
net.sf.gridarta.gui.map.maptilepane.MapTilePanel.MapTilePanel
MapTilePanel(final int direction, final int @NotNull[] nextFocus, @NotNull final TilePanel tilePanel, @NotNull final String name)
Creates a new instance.
Definition: MapTilePanel.java:46
net.sf.gridarta.gui.map.maptilepane.TilePanel.addTextFieldActionListener
void addTextFieldActionListener(@NotNull final ActionListener actionListener)
Adds an ActionListener to the text input field.
Definition: TilePanel.java:250
net.sf.gridarta.gui.map.maptilepane.TilePanel
A tile panel displays exactly one direction for map tiling.
Definition: TilePanel.java:52