20 package net.sf.gridarta.gui.map.renderer;
22 import java.awt.Color;
23 import java.awt.Graphics;
24 import java.awt.Graphics2D;
25 import java.awt.Point;
26 import javax.swing.Icon;
43 import org.jetbrains.annotations.NotNull;
60 private final Color[]
highLightMask = {
new Color(1.0f, 0.0f, 0.0f, 0.33f),
new Color(0.0f, 1.0f, 0.0f, 0.33f),
new Color(0.0f, 1.0f, 1.0f, 0.33f), };
99 private final Point
point =
new Point();
130 public IsoMapRenderer(
final int spawnPointTypeNo, @NotNull
final MapViewSettings mapViewSettings, @NotNull
final FilterControl<G, A, R> filterControl, @NotNull
final MapModel<G, A, R> mapModel, @NotNull
final MapGrid mapGrid, @NotNull
final MultiPositionData multiPositionData, @NotNull
final IsoMapSquareInfo isoMapSquareInfo, @NotNull
final GridMapSquarePainter gridMapSquarePainter, @NotNull
final GameObjectParser<G, A, R> gameObjectParser, @NotNull
final ResourceIcons resourceIcons) {
131 super(spawnPointTypeNo, mapViewSettings, mapModel, mapGrid, isoMapSquareInfo.getXLen(), 2 * isoMapSquareInfo.getYLen(),
multiPositionData,
isoMapSquareInfo,
gridMapSquarePainter, gameObjectParser, resourceIcons.getResourceIcon(
ResourceIcons.
SQUARE_UNKNOWN));
136 this.filterControl.addConfigListener(filterConfigListener);
151 return mapViewSettings.
isEditType(gameObject);
156 point.setLocation(square.getMapX(), square.getMapY());
158 int highestSubLayer = 0;
159 for (
int subLayer = 0; subLayer < yOffsets.length; subLayer++) {
160 if (yOffsets[subLayer] < yOffsets[highestSubLayer]) {
161 highestSubLayer = subLayer;
165 if (square.isEmpty()) {
166 emptySquareIcon.paintIcon(
this, g, x, y + yOffsets[0]);
168 for (
final G node : square) {
170 if (filterControl.
canShow(node)) {
171 final G head = node.getHead();
174 subLayer = highestSubLayer;
182 for (
int subLayer = 0; subLayer < yOffsets.length; subLayer++) {
189 final Color color = g.getColor();
190 g.setColor(highLightMask[i]);
191 xPoints[0] = x + isoMapSquareInfo.
getXLen() / 2;
192 xPoints[1] = x + isoMapSquareInfo.
getXLen() - 1;
193 xPoints[2] = xPoints[0];
195 yPoints[0] = y + yOffsets[subLayer];
196 yPoints[1] = y + yOffsets[subLayer] + isoMapSquareInfo.
getYLen() / 2;
197 yPoints[2] = y + yOffsets[subLayer] + isoMapSquareInfo.
getYLen() - 1;
198 yPoints[3] = yPoints[1];
199 g.fillPolygon(xPoints, yPoints, 4);
IsoMapRenderer(final int spawnPointTypeNo, @NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl< G, A, R > filterControl, @NotNull final MapModel< G, A, R > mapModel, @NotNull final MapGrid mapGrid, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser< G, A, R > gameObjectParser, @NotNull final ResourceIcons resourceIcons)
Creates a new instance.
final Icon emptySquareIcon
int [] tileStretchingOffsets( @NotNull final Point point, final boolean[] foundSubLayers)
Calculates the tile stretching Y offset.
final MultiPositionData multiPositionData
The MultiPositionData instance to query for multi-part objects.
final FilterState filterState
The filter state instance for this map renderer.
A MapRenderer that renders isometric squares.
final IsoMapSquareInfo isoMapSquareInfo
The IsoMapSquareInfo to use.
final int [] xPoints
The x-coordinates for painting highlighted squares.
A MapModel reflects the data of a map.
Graphical User Interface of Gridarta.
Reading and writing of maps, handling of paths.
void newSquare(@NotNull FilterState filterState)
static final String LAYER
The name of the "layer" attribute.
final MapViewSettings mapViewSettings
The map view settings instance.
final MapGrid mapGrid
The MapGrid to render.
final MapModel< G, A, R > mapModel
The MapModel to render.
Interface for classes that read or write GameObject instances.
A AbstractIsoMapRenderer to render map files.
boolean isEditType(int editType)
Get information on the current state of edit type.
int getYLen()
Returns the vertical size of a square.
final int spawnPointTypeNo
The game object type number of spawn points.
Base package of all Gridarta classes.
Paints overlays for map grids.
boolean isGameObjectVisible(@NotNull final G gameObject)
static final String SUB_LAYER
The name of the "sub_layer" attribute.
static final long serialVersionUID
Serial Version UID.
void clearBackground(@NotNull final Graphics g)
Types of FilterConfig change types.
Container for settings that affect the rendering of maps.
GameObjects are the objects based on Archetypes found on maps.
boolean canShow(@NotNull G gameObject)
void paintSquare(@NotNull final Graphics2D g, final int x, final int y, @NotNull final MapSquare< G, A, R > square)
boolean isHighlightedSquare(@NotNull FilterState filterState, int path)
final FilterConfigListener filterConfigListener
The FilterConfigListener attached to filterControl to repaint all after config changes.
static final String SQUARE_UNKNOWN
void paintGameObjectIfVisible( @NotNull final Graphics2D g, final int xStart, final int yStart, @NotNull final G gameObject)
Paints a single game object if it is visible according to current editor settings.
final Color [] highLightMask
The MultiPositionData class stores an array of numbers which is required in order to calculate displa...
2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors.
The filter package contains the classes for Filters.
final Point point
Used for calculations in paintSquare.
final FilterControl< G, A, R > filterControl
Provides information about isometric map squares.
void objectInSquare(@NotNull FilterState filterState, @NotNull G gameObject)
final boolean [] foundSubLayers
Boolean array for tileStretchingOffsets to avoid allocating lots of arrays.
Creates ImageIcon instances from resources.
void removeConfigListener(@NotNull FilterConfigListener listener)
Removes a FilterConfigListener to be notified about changes.
static final String SQUARE_EMPTY
final int [] yPoints
The y-coordinates for painting highlighted squares.
Default implementation for GameObject implementing classes.
Interface for filter configurations.
final GridMapSquarePainter gridMapSquarePainter
The GridMapSquarePainter to use.
int getXLen()
Returns the horizontal size of a square.
Interface for MapArchObjects.
Interface for listeners interested in FilterConfig related changes.
The highlighted state while using a FilterControl instance.