Gridarta Editor
ZoomAction.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 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.action;
21 
22 import java.awt.Component;
23 import javax.swing.Action;
24 import javax.swing.JOptionPane;
33 import net.sf.japi.swing.action.ActionMethod;
34 import org.jetbrains.annotations.NotNull;
35 
39 public class ZoomAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction {
40 
41  @NotNull
43 
44  @NotNull
46 
47  @NotNull
48  private final Component parent;
49 
53  public ZoomAction(@NotNull final MapManager<G, A, R> mapManager, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final Component parent) {
54  this.mapManager = mapManager;
55  this.rendererFactory = rendererFactory;
56  this.parent = parent;
57  }
58 
63  @ActionMethod
64  public void zoom() {
65  final MapControl<G, A, R> mapControl = mapManager.getCurrentMap();
66  if (mapControl == null) {
67  JOptionPane.showMessageDialog(parent, "No map loaded! Please load a map!!", "Error", JOptionPane.ERROR_MESSAGE);
68  return;
69  }
70  new MapPreview(rendererFactory.newSimpleMapRenderer(mapControl.getMapModel()).getFullImage());
71  }
72 
73  @Override
74  public void setAction(@NotNull final Action action, @NotNull final String name) {
75  }
76 
77 }
A MapManager manages all opened maps.
Definition: MapManager.java:37
Graphical User Interface of Gridarta.
MapRenderer newSimpleMapRenderer(@NotNull MapModel< G, A, R > mapModel)
Creates a new map renderer instance which paints only squares but no grid, cursor, selection, or errors.
MapModel< G, A, R > getMapModel()
Returns the map model.
final MapManager< G, A, R > mapManager
Definition: ZoomAction.java:42
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Definition: GameObject.java:36
A global editor action.
final RendererFactory< G, A, R > rendererFactory
Definition: ZoomAction.java:45
GameObjects are the objects based on Archetypes found on maps.
ZoomAction(@NotNull final MapManager< G, A, R > mapManager, @NotNull final RendererFactory< G, A, R > rendererFactory, @NotNull final Component parent)
Creates a new instance.
Definition: ZoomAction.java:53
Base classes for rendering maps.
MapControl< G, A, R > getCurrentMap()
Returns the current map.
Factory for creating MapRenderer instances.
Currently nothing more than a marker interface for unification.
Definition: MapControl.java:35
The map preview of the level editor.
Definition: MapPreview.java:51
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
Definition: ZoomAction.java:74
void zoom()
The action method for "zoom".
Definition: ZoomAction.java:64