Gridarta Editor
FlatPickmapRenderer.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.var.crossfire.gui.map.renderer;
21 
22 import java.awt.Dimension;
23 import java.awt.Graphics;
24 import java.awt.Point;
25 import java.awt.Rectangle;
26 import javax.swing.ImageIcon;
39 import org.jetbrains.annotations.NotNull;
40 
46 
50  private static final long serialVersionUID = 1L;
51 
62  super(mapViewSettings, mapModel, mapGrid, 0, gridMapSquarePainter, gameObjectParser);
63  setBackground(CommonConstants.BG_COLOR);
64  init();
65  }
66 
67  @Override
68  protected void updateSquare(@NotNull final Point point) {
69  // nothing to do
70  }
71 
72  @Override
73  protected void updateSquares(@NotNull final Rectangle rectangle) {
74  // nothing to do
75  }
76 
77  @Override
78  protected void updateAll() {
79  // nothing to do
80  }
81 
82  @Override
83  public void paintComponent(@NotNull final Graphics g) {
84  paintComponent(g, false, true);
85  }
86 
87  @Override
88  protected void resizeBackBuffer(@NotNull final Dimension size) {
89  }
90 
91  @Override
92  protected void paintSquare(@NotNull final Graphics g, final int x, final int y, @NotNull final MapSquare<GameObject, MapArchObject, Archetype> square) {
93  g.setColor(getBackground());
95  if (square.isEmpty()) {
96  return;
97  }
98 
99  for (final BaseObject<?, ?, ?, ?> node : square) {
100  final ImageIcon img = node.getNormalImage();
101  final int xx;
102  final int yy;
103  if (!node.isMulti() || (img.getIconWidth() == IGUIConstants.SQUARE_WIDTH && img.getIconHeight() == IGUIConstants.SQUARE_HEIGHT)) {
104  xx = 0;
105  yy = 0;
106  } else {
107  // this is an oversized image, so it must be shifted
108  xx = IGUIConstants.SQUARE_WIDTH * (node.getArchetype().getMultiX() - node.getMinX());
109  yy = IGUIConstants.SQUARE_HEIGHT * (node.getArchetype().getMultiY() - node.getMinY());
110  }
111  g.drawImage(img.getImage(), x, y, x + IGUIConstants.SQUARE_WIDTH, y + IGUIConstants.SQUARE_HEIGHT, xx, yy, xx + IGUIConstants.SQUARE_WIDTH, yy + IGUIConstants.SQUARE_HEIGHT, this);
112  }
113  }
114 
115 }
A MapModel reflects the data of a map.
Definition: MapModel.java:75
Graphical User Interface of Gridarta.
Reading and writing of maps, handling of paths.
final MapModel< GameObject, MapArchObject, Archetype > mapModel
The MapModel to render.
int SQUARE_HEIGHT
The height of a square in pixels.
MapArchObject contains the specific meta data about a map that is stored in the map-arch, at the very beginning of the map file.
Handles the Crossfire variants of GameObjects and Archetypes.
Interface for classes that read or write GameObject instances.
FlatPickmapRenderer(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapModel< GameObject, MapArchObject, Archetype > mapModel, @NotNull final MapGrid mapGrid, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser< GameObject, MapArchObject, Archetype > gameObjectParser)
Creates a new instance.
Class with constants used in Gridarta and derivates.
static final Color BG_COLOR
Background Color (for the Panels).
Base package of all Gridarta classes.
void paintSquare(@NotNull final Graphics g, final int x, final int y, @NotNull final MapSquare< GameObject, MapArchObject, Archetype > square)
Container for settings that affect the rendering of maps.
final MapViewSettings mapViewSettings
The MapViewSettings instance to use.
2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors.
Definition: MapGrid.java:45
Defines common UI constants used in different dialogs and all used icon files.
final GameObjectParser< G, A, R > gameObjectParser
The GameObjectParser for creating tooltip information or.
Base classes for rendering maps.
Main package of Gridarta4Crossfire, contains all classes specific to the Crossfire version of the Gri...
final GridMapSquarePainter gridMapSquarePainter
The GridMapSquarePainter to use.
int SQUARE_WIDTH
The width of a square in pixels.