Gridarta Editor
ViewAction.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.viewaction;
21 
22 import java.awt.Component;
23 import java.awt.event.ActionEvent;
24 import javax.swing.AbstractAction;
25 import javax.swing.AbstractButton;
26 import javax.swing.JCheckBoxMenuItem;
29 import net.sf.japi.swing.action.ActionBuilder;
30 import net.sf.japi.swing.action.ActionBuilderFactory;
31 import org.jetbrains.annotations.NotNull;
32 
38 public class ViewAction extends AbstractAction {
39 
43  private static final long serialVersionUID = 1L;
44 
48  @NotNull
49  private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta");
50 
54  @NotNull
56 
60  @NotNull
61  private final String name;
62 
66  private final int editType;
67 
71  @NotNull
72  private final AbstractButton checkBoxMenuItem = new JCheckBoxMenuItem(this);
73 
79  public ViewAction(@NotNull final MapViewSettings mapViewSettings, @NotNull final NamedGameObjectMatcher matcher) {
80  super(ACTION_BUILDER.format("show.text", matcher.getName()));
81  this.mapViewSettings = mapViewSettings;
82  name = matcher.getName();
83  editType = matcher.getEditType();
84  updateAction();
85  }
86 
91  @NotNull
92  public String getName() {
93  return name;
94  }
95 
99  public final void updateAction() {
101  }
102 
103  @Override
104  public void actionPerformed(@NotNull final ActionEvent e) {
105  if (!isEnabled()) {
106  return;
107  }
108 
110  }
111 
116  @NotNull
117  public Component getCheckBoxMenuItem() {
118  return checkBoxMenuItem;
119  }
120 
121  @NotNull
122  @Override
123  public ViewAction clone() throws CloneNotSupportedException {
124  return (ViewAction) super.clone();
125  }
126 
127 }
net.sf.gridarta.gui.map.viewaction.ViewAction.getName
String getName()
Returns the name for sorting the menu entries.
Definition: ViewAction.java:92
net.sf.gridarta.gui.map.viewaction.ViewAction
Action to manage one edit type represented by one {}.
Definition: ViewAction.java:38
net.sf.gridarta.gui.map.viewaction.ViewAction.editType
final int editType
The managed edit type.
Definition: ViewAction.java:66
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.mapviewsettings
Definition: AbstractMapViewSettings.java:20
net.sf
net.sf.gridarta.gui.map.viewaction.ViewAction.updateAction
final void updateAction()
Update the action's state to match the current edit type settings.
Definition: ViewAction.java:99
net.sf.gridarta.gui.map.viewaction.ViewAction.actionPerformed
void actionPerformed(@NotNull final ActionEvent e)
Definition: ViewAction.java:104
net.sf.gridarta.model.mapviewsettings.MapViewSettings
Container for settings that affect the rendering of maps.
Definition: MapViewSettings.java:30
net.sf.gridarta.model.match.NamedGameObjectMatcher
Decorates an arbitrary GameObjectMatcher with a localized name that is suitable for the user interfac...
Definition: NamedGameObjectMatcher.java:33
net
net.sf.gridarta.model.match
Classes related to matching {GameObjects}, so called { net.sf.gridarta.model.match....
Definition: AndGameObjectMatcher.java:20
net.sf.gridarta.gui.map.viewaction.ViewAction.ACTION_BUILDER
static final ActionBuilder ACTION_BUILDER
Action Builder to create Actions.
Definition: ViewAction.java:49
net.sf.gridarta.model.mapviewsettings.MapViewSettings.isEditType
boolean isEditType(int editType)
Get information on the current state of edit type.
net.sf.gridarta.gui.map.viewaction.ViewAction.ViewAction
ViewAction(@NotNull final MapViewSettings mapViewSettings, @NotNull final NamedGameObjectMatcher matcher)
Creates a new instance.
Definition: ViewAction.java:79
net.sf.gridarta.gui.map.viewaction.ViewAction.name
final String name
The name for sorting the menu entries.
Definition: ViewAction.java:61
net.sf.gridarta.gui.map.viewaction.ViewAction.getCheckBoxMenuItem
Component getCheckBoxMenuItem()
Returns the menu item for this action.
Definition: ViewAction.java:117
net.sf.gridarta.model
net.sf.gridarta.gui.map.viewaction.ViewAction.checkBoxMenuItem
final AbstractButton checkBoxMenuItem
The menu item for this action.
Definition: ViewAction.java:72
net.sf.gridarta.gui.map.viewaction.ViewAction.mapViewSettings
final MapViewSettings mapViewSettings
The map view settings instance.
Definition: ViewAction.java:55
net.sf.gridarta.gui.map.viewaction.ViewAction.serialVersionUID
static final long serialVersionUID
The serial version UID.
Definition: ViewAction.java:43
net.sf.gridarta.gui.map.viewaction.ViewAction.clone
ViewAction clone()
Definition: ViewAction.java:123
net.sf.gridarta.model.mapviewsettings.MapViewSettings.toggleEditType
void toggleEditType(int editType)
Toggle an edit type.