20 package net.sf.gridarta.var.crossfire.gui.map.renderer;
22 import java.awt.Graphics;
23 import java.awt.Point;
24 import javax.swing.ImageIcon;
34 import org.jetbrains.annotations.NotNull;
44 private static final int[]
DX = { 1, 2, 2, 2, 1, 0, 0, 0, };
47 private static final int[]
DY = { 0, 0, 1, 2, 2, 2, 1, 0, };
50 private static final int[]
B_WEIGHTS = { 2, 0, 4, 0, 8, 0, 1, 0, };
53 private static final int[]
C_WEIGHTS = { 0, 2, 0, 4, 0, 8, 0, 1, };
115 public void paintSmooth(@NotNull
final Graphics graphics, @NotNull
final Point pos,
final int level,
final int firstLayer,
final boolean allLayers,
final int borderOffsetX,
final int borderOffsetY) {
116 int layer = firstLayer;
119 boolean foundLayer =
false;
120 final Point where =
new Point();
121 for (
int deltaX = -1; deltaX <= 1; deltaX++) {
122 where.x = pos.x + deltaX;
123 for (
int deltaY = -1; deltaY <= 1; deltaY++) {
124 where.y = pos.y + deltaY;
127 layerNode[deltaX + 1][deltaY + 1] = null;
129 int currentLayer = -1;
133 if (currentLayer == layer) {
136 layerNode[deltaX + 1][deltaY + 1] = node;
148 for (
int i = 0; i < 8; i++) {
157 if (smoothlevel <= level) {
163 sLevels[i] = smoothlevel;
173 final boolean[] partDone = {
false,
false,
false,
false,
false,
false,
false,
false, };
176 for (
int i = 0; i < 8; i++) {
177 if (sLevels[i] > 0 && !partDone[i] && (lowest < 0 || sLevels[i] < sLevels[lowest])) {
193 for (
int i = 0; i < 8; i++) {
194 if (sLevels[i] == sLevels[lowest] && sFaces[i] == smoothFace) {
196 weight += B_WEIGHTS[i];
197 weightC &= ~BC_EXCLUDE[i];
200 weightC &= ~C_WEIGHTS[i];
203 if (smoothFace == null) {
211 final ImageIcon img = faceObjectProviders.
getDisplayIcon(smoothFace);
220 if (!allLayers || !foundLayer) {
228 private void drawImage(@NotNull
final Graphics graphics, @NotNull
final Point pos,
final int borderOffsetX,
final int borderOffsetY,
final int srcX,
final int srcY, @NotNull
final ImageIcon img) {
The data package contains classes for handling data that is organized in a tree.
FaceObject getSmoothFace(@NotNull final GameObject<?, ?, ?> gameObject)
Returns the smooth faces for a GameObject.
A MapModel reflects the data of a map.
static final String SMOOTHLEVEL
The name of the "smoothlevel" attribute.
int SQUARE_HEIGHT
The height of a square in pixels.
Common interface for FaceObject.
MapArchObject contains the specific meta data about a map that is stored in the map-arch, at the very beginning of the map file.
static final int [] C_WEIGHTS
Handles the Crossfire variants of GameObjects and Archetypes.
void drawImage(@NotNull final Graphics graphics, @NotNull final Point pos, final int borderOffsetX, final int borderOffsetY, final int srcX, final int srcY, @NotNull final ImageIcon img)
Handles the Crossfire GameObjects.
Renderer for smoothed faces as used by Crossfire.
ImageIcon getDisplayIcon(@NotNull final NamedObject namedObject)
Returns the display icon for a NamedObject.
boolean isPointValid(@Nullable final Point pos)
Checks whether the given coordinate is within map bounds.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
static final int [] B_WEIGHTS
Implements Crossfire archetypes.
Collection of all smoothing information.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
GameObjects are the objects based on Archetypes found on maps.
static final int [] BC_EXCLUDE
Defines common UI constants used in different dialogs and all used icon files.
Main package of Gridarta4Crossfire, contains all classes specific to the Crossfire version of the Gri...
static final String INVISIBLE
The name of the "invisible" attribute.
SmoothingRenderer(@NotNull final MapModel< GameObject, MapArchObject, Archetype > mapModel, @NotNull final SmoothFaces smoothFaces, @NotNull final FaceObjectProviders faceObjectProviders)
Creates a new instance.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
Provider for faces of GameObjects and Archetypes.
The face is the appearance of an object.
final SmoothFaces smoothFaces
The SmoothFaces to use.
final FaceObject [] sFaces
final FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
final MapModel< GameObject, MapArchObject, Archetype > mapModel
The MapModel to render.
int SQUARE_WIDTH
The width of a square in pixels.
void paintSmooth(@NotNull final Graphics graphics, @NotNull final Point pos, final int level, final int firstLayer, final boolean allLayers, final int borderOffsetX, final int borderOffsetY)
Draw the smoothing information at given position of map, for a given limit smoothlevel, at a given layer.
final net.sf.gridarta.model.gameobject.GameObject<?, ?, ?> [][] layerNode