 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.map;
30 import java.awt.Graphics;
31 import java.util.Arrays;
32 import java.util.concurrent.atomic.AtomicBoolean;
33 import javax.swing.ImageIcon;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
87 private static final int @NotNull []
DX = {1, 2, 2, 2, 1, 0, 0, 0,};
92 private static final int @NotNull []
DY = {0, 0, 1, 2, 2, 2, 1, 0,};
145 private final boolean @NotNull []
done =
new boolean[8];
176 public void paintSmooth(@NotNull
final Graphics graphics,
final int x,
final int y,
final int px,
final int py,
final int layer, @NotNull
final CfMap map,
final int tileSize) {
177 for (
int deltaX = 0; deltaX <= 2; deltaX++) {
178 for (
int deltaY = 0; deltaY <= 2; deltaY++) {
179 if (deltaX != 1 || deltaY != 1) {
180 final CfMapSquare mapSquare = map.getMapSquare(x+deltaX-1, y+deltaY-1);
187 final int level = map.
getSmooth(x, y, layer);
189 for (
int i = 0; i < 8; i++) {
196 final int smoothlevel = node.
getSmooth(layer);
197 if (smoothlevel <= level) {
211 Arrays.fill(
done,
false);
214 for (
int i = 0; i < 8; i++) {
224 final int currentSmoothFace =
smoothFace[lowest];
230 for (
int i = 0; i < 8; i++) {
239 if (currentSmoothFace == 0) {
245 map.squarePendingFace(x, y, currentSmoothFace);
248 drawImage(graphics, px, py, tileSize*weight, 0, imageIcon, tileSize);
251 drawImage(graphics, px, py, tileSize*weightC, tileSize, imageIcon, tileSize);
268 private static void drawImage(@NotNull
final Graphics graphics,
final int dstX,
final int dstY,
final int srcX,
final int srcY, @NotNull
final ImageIcon imageIcon,
final int tileSize) {
269 graphics.drawImage(imageIcon.getImage(), dstX, dstY, dstX+tileSize, dstY+tileSize, srcX, srcY, srcX+tileSize, srcY+tileSize,
null);
static final int[] BORDER_CORNER_EXCLUDE
Corner excludes due to borders.
static final int BORDER_EAST
Border weight for east.
final CfMapSquare[][] layerNode
Surrounding map squares having non-zero smooth levels.
final int[] smoothFace
Face index of the smooth face corresponding to layerNode.
static final int[] CORNER_WEIGHT
Weight (x coordinate) in smoothing face of a corner.
Implements the map model which is shown in the map and magic map views.
static void drawImage(@NotNull final Graphics graphics, final int dstX, final int dstY, final int srcX, final int srcY, @NotNull final ImageIcon imageIcon, final int tileSize)
Draws a.
final AtomicBoolean isUnknownImage
Temporary variable.
int getFaceNum()
Returns the unique face id.
final SmoothFaces smoothFaces
The SmoothFaces to use.
static final int[] BORDER_WEIGHT
Weight (x coordinate) in smoothing face of a corner.
Represents a map (as seen by the client).
static final int[] DX
X offset for map coordinate calculation.
Manages image information ("faces") needed to display the map view, items, and spell icons.
ImageIcon getImageIcon(int faceNum, @Nullable AtomicBoolean returnIsUnknownImage)
Returns the face for a face ID.
SmoothingRenderer(@NotNull final SmoothFaces smoothFaces, @NotNull final FacesProvider facesProvider)
Creates a new instance.
Face getFace(final int layer)
Returns the face of a layer.
final int[] smoothValue
Smooth values corresponding to layerNode.
void paintSmooth(@NotNull final Graphics graphics, final int x, final int y, final int px, final int py, final int layer, @NotNull final CfMap map, final int tileSize)
Draw the smoothing information at given position of map, for a given limit smoothlevel,...
static final int CORNER_NORTHWEST
Corner weight for northwest.
static final int BORDER_WEST
Border weight for west.
int getSmooth(final int layer)
Returns the smooth value of this square.
final FacesProvider facesProvider
The FacesProvider for looking up faces.
static final int BORDER_NORTH
Border weight for north.
final boolean[] done
Marks the indexes that have been painted.
static final int CORNER_SOUTHWEST
Corner weight for southwest.
static final int[] DY
Y offset for map coordinate calculation.
Represents a square in a CfMap.
static final int CORNER_SOUTHEAST
Corner weight for southeast.
static final int BORDER_SOUTH
Border weight for south.
Interface for face providers.
Maintains smoothing information received from the Crossfire server.
Renderer for painting smoothed faces into map views.
int getSmoothFace(final int face)
Returns the smoothing face associated with a given face.
static final int CORNER_NORTHEAST
Corner weight for northeast.