 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.map.maptilepane;
22 import java.awt.Component;
23 import java.awt.GridBagConstraints;
24 import java.awt.GridBagLayout;
26 import javax.swing.BorderFactory;
27 import javax.swing.JButton;
28 import javax.swing.JComponent;
29 import javax.swing.JPanel;
30 import javax.swing.border.CompoundBorder;
31 import javax.swing.filechooser.FileFilter;
50 import net.
sf.japi.swing.action.ActionBuilder;
51 import net.
sf.japi.swing.action.ActionBuilderFactory;
52 import net.
sf.japi.swing.action.ActionMethod;
53 import org.jetbrains.annotations.NotNull;
76 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
136 protected AbstractMapTilePane(@NotNull
final MapManager<G, A, R> mapManager, @NotNull
final ProjectSettings projectSettings, @NotNull
final MapModel<G, A, R> mapModel, @NotNull
final MapLink @NotNull [] @NotNull [] tileLink, @NotNull
final Direction @NotNull [] directionMapping,
final int @NotNull []
nextFocus, @NotNull
final FileFilter
mapFileFilter) {
141 assert tileLink.length == 10;
155 canAttachMaps = tileLink[0].length + tileLink[1].length + tileLink[2].length + tileLink[3].length + tileLink[4].length + tileLink[5].length + tileLink[6].length + tileLink[7].length + tileLink[8].length + tileLink[9].length > 0;
178 setLayout(
new GridBagLayout());
179 final GridBagConstraints gbc =
new GridBagConstraints();
180 gbc.gridwidth = GridBagConstraints.REMAINDER;
182 gbc.fill = GridBagConstraints.BOTH;
197 for (
int index = 0; index < tilePanels.length; index++) {
216 for (
int index = 0; index < tilePanels.length; index++) {
217 panel.add(tilePanels[index].getTilePanel(), directionMapping[index]);
229 final JComponent subPanel =
new JPanel(
new GridBagLayout());
231 final GridBagConstraints gbc =
new GridBagConstraints();
232 gbc.fill = GridBagConstraints.NONE;
236 gbc.anchor = GridBagConstraints.EAST;
237 subPanel.add(
new JButton(
ACTION_BUILDER.createAction(
false,
"mapTilesAttach",
this)), gbc);
239 gbc.gridwidth = GridBagConstraints.REMAINDER;
240 gbc.anchor =
canAttachMaps ? GridBagConstraints.WEST : GridBagConstraints.CENTER;
241 subPanel.add(
new JButton(
ACTION_BUILDER.createAction(
false,
"mapTilesClear",
this)), gbc);
250 final String[] tmpTilePaths =
new String[
tilePaths.length];
251 for (
int i = 0; i < tmpTilePaths.length; i++) {
261 ACTION_BUILDER.showMessageDialog(
this,
"mapErrorFatalWrite", ex.getMessage());
270 for (
int i = 0; i < tmpTilePaths.length; i++) {
281 tilePath.getTilePanel().setText(
"",
true);
290 for (
int i = 0; i <
tilePaths.length; i++) {
300 tilePath.getTilePanel().mapTileRevert();
int getWidth()
Returns the width of the area.
void modifyMapProperties()
Invoke this method if the dialog using this pane is confirmed with OK to write the information from t...
A MapModel reflects the data of a map.
final AttachTiledMaps< G, A, R > attachTiledMaps
This class implements a layout that is similar to {} but implements those directions used in Daimonin...
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
final MapModel< G, A, R > mapModel
The map in context.
A MapManager manages all opened maps.
final TileLink[] tileLinks
The tile links for the attach map algorithm.
Base package of all Gridarta classes.
Defines common UI constants used in different dialogs.
static TileLink newTileLink(@NotNull final String key, @NotNull final MapLink @NotNull[] mapLinks, @NotNull final Direction revLink)
Creates a new TileLink.
String getTilePath(@NotNull Direction direction)
Returns a tile path.
MapTilePanel[] buildComponents(@NotNull final Direction @NotNull[] directionMapping)
Builds the components of this panel.
final MapArchObject< A > mapArchObject
The MapArchObject to show.
void mapTilesClear()
Action method for tiles clearing paths.
Reflects a game object (object on a map).
final boolean canAttachMaps
Whether "attach maps" function is available.
Graphical User Interface of Gridarta.
static final ActionBuilder ACTION_BUILDER
Action Builder.
void mapTilesAttach()
Action method for tiles attaching automatically.
A Panel for managing the tiling of maps.
GameObjects are the objects based on Archetypes found on maps.
int getHeight()
Returns the height of the area.
Size2D getOtherMapSize()
Returns the size of the second map.
MapTilePanel[] createTilePanels(final int directions)
Builds all MapTilePanels for all directions.
Attaches maps to adjacent tiled maps.
void setText(@NotNull final String text, final boolean keepRA)
Sets the text.
Interface for MapArchObjects.
static final long serialVersionUID
Serial Version UID.
File getFile()
Returns a File for this map file.
A MapTilePanel extends a TilePanel with a border and makes focus traversal work within the map tile p...
void restoreMapProperties()
Restores the settings from the map.
final FileFilter mapFileFilter
Swing FileFilter for map files.
Size2D getMapSize()
Returns the size of the first map.
Exception thrown if an operation is attempted on an unsaved map.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
void attachTiledMaps(@NotNull final MapModel< G, A, R > mapModel, @NotNull final String @NotNull[] tilePaths, @NotNull final File mapsDirectory, final boolean performAction)
Updates tile paths of a map.
The location of a map file with a map directory.
void setTilePath(@NotNull Direction direction, @NotNull String tilePath)
Sets a tile path.
Exception thrown if the size of a map file is unexpected.
AbstractMapTilePane(@NotNull final MapManager< G, A, R > mapManager, @NotNull final ProjectSettings projectSettings, @NotNull final MapModel< G, A, R > mapModel, @NotNull final MapLink @NotNull[] @NotNull[] tileLink, @NotNull final Direction @NotNull[] directionMapping, final int @NotNull[] nextFocus, @NotNull final FileFilter mapFileFilter)
Creates a new instance.
Settings that apply to a project.
static Component buildTilePanels(@NotNull final MapTilePanel @NotNull[] tilePanels, @NotNull final Direction @NotNull[] directionMapping)
Builds the tile panel.
MapTilePanel getTilePath(final int direction)
Returns one tile path.
Exception thrown if a map file cannot be saved.
File getMapFile()
Returns the map File of the first map.
final ProjectSettings projectSettings
The project settings instance.
Utility class for ActionBuilder related functions.
File getMapsDirectory()
Returns the default maps directory.
MapFile getMapFile()
Returns the map file.
final int[] nextFocus
Indices of next focus.
String getText()
Returns the text.
String getMapPath()
Returns the map path that could not be loaded.
A tile panel displays exactly one direction for map tiling.
final MapTilePanel[] tilePaths
The JTextFields with the tile paths.
Border DIALOG_BORDER
The Border object to be used when creating dialogs.
Component buildSubPanel()
Creates the sub-panel that holds the buttons to attach maps or clear all paths.
Exception thrown if a map file cannot be loaded.