 |
Gridarta Editor
|
Go to the documentation of this file.
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 java.awt.Rectangle;
27 import java.awt.image.BufferedImage;
35 import org.jetbrains.annotations.NotNull;
70 private final Point
origin =
new Point();
89 final Rectangle rec =
new Rectangle(0, 0, mapSize.
getWidth(), mapSize.
getHeight());
90 final Point pos =
new Point();
91 final Point endPos = rec.getLocation();
92 endPos.translate(rec.width, rec.height);
93 for (pos.y = rec.y; pos.y < endPos.y; pos.y++) {
96 for (pos.x = rec.x; pos.x < endPos.x; pos.x++) {
104 for (
final G node : square) {
105 paint(graphics, xStart, yStart, node);
122 protected abstract void paint(@NotNull Graphics2D graphics2D,
int xStart,
int yStart, @NotNull G gameObject);
135 throw new IllegalStateException(
"operation not supported");
141 throw new IllegalStateException(
"operation not supported");
155 final BufferedImage image =
new BufferedImage(viewWidth, viewHeight, BufferedImage.TYPE_INT_ARGB);
156 final Graphics2D graphics = image.createGraphics();
158 graphics.fillRect(0, 0, viewWidth, viewHeight);
167 throw new IllegalStateException(
"operation not supported");
178 throw new IllegalStateException(
"unsupported operation");
int getWidth()
Returns the width of the area.
Abstract base class for ISO MapRenderers.
A MapModel reflects the data of a map.
final MapModel< G, A, R > mapModel
The MapModel to render.
static final long serialVersionUID
The serial version UID.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
Base package of all Gridarta classes.
void paintComponent2(@NotNull final Graphics2D graphics)
Paints this component.
Provides information about isometric map squares.
boolean getSquareLocationAt(@NotNull final Point point, @NotNull final Point retPoint)
Reflects a game object (object on a map).
void paintComponent(@NotNull final Graphics g)
int getXLen()
Returns the horizontal size of a square.
Abstract base class for classes implementing MapRenderer.
GameObjects are the objects based on Archetypes found on maps.
int getHeight()
Returns the height of the area.
int getXLen2()
Returns the horizontal center of a square.
Interface for MapArchObjects.
AbstractSimpleIsoMapRenderer(@NotNull final MapModel< G, A, R > mapModel, @NotNull final IsoMapSquareInfo isoMapSquareInfo)
Creates a new instance.
final Point origin
The origin is the point in the north-west corner.
int getYLen()
Returns the vertical size of a square.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
Rectangle getSquareBounds(@NotNull final Point p)
BufferedImage getFullImage()
boolean isEmpty()
Check whether this square is empty.
final IsoMapSquareInfo isoMapSquareInfo
The IsoMapSquareInfo to use.
int getYLen2()
Returns the vertical center of a square.
static final Color BACKGROUND_COLOR
The background Color for created images.
abstract void paint(@NotNull Graphics2D graphics2D, int xStart, int yStart, @NotNull G gameObject)
Paints a single GameObject.
Base class for classes that contain GameObjects as children in the sense of containment.
void calculateOrigin()
The origin which is located in the NORTH_WEST-corner of the map is calculated.
The class Size2D represents a 2d rectangular area.