java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.realtime.crossfire.jxclient.gui.gui.GUIElement
com.realtime.crossfire.jxclient.gui.map.AbstractGUIMap
public abstract class AbstractGUIMap
Abstract base class for GUIElements that display map
views.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
private int |
displayMaxOffsetX
The number of pixels that are visible in the rightmost visible tile. |
private int |
displayMaxOffsetY
The number of pixels that are visible in the bottommost visible tile. |
private int |
displayMaxX
The tile x coordinate where map drawing ends. |
private int |
displayMaxY
The tile y coordinate where map drawing ends. |
private int |
displayMinOffsetX
The distance the leftmost visible tile reaches outside the map window. |
private int |
displayMinOffsetY
The distance the topmost visible tile reaches outside the map window. |
private int |
displayMinX
The tile x coordinate where map drawing starts. |
private int |
displayMinY
The tile y coordinate where map drawing starts. |
private FacesProvider |
facesProvider
The FacesProvider for looking up faces. |
private java.util.Map<java.awt.Color,java.awt.Image> |
images
Maps Color to an image filled with this color with a size of one
square. |
private int |
mapHeight
The map height in squares. |
private MapListener |
mapListener
The MapListener registered to receive map updates. |
private MapScrollListener |
mapscrollListener
The MapScrollListener registered to receive map_scroll commands. |
private MapSizeListener |
mapSizeListener
The MapSizeListener registered to detect map size changes. |
private CfMapUpdater |
mapUpdater
The CfMapUpdater instance to display. |
private int |
mapWidth
The map width in squares. |
private NewmapListener |
newmapListener
The NewmapListener registered to receive newmap commands. |
private int |
offsetX
The x offset for drawing the square at coordinate 0 of the map. |
private int |
offsetY
The y offset for drawing the square at coordinate 0 of the map. |
private int |
playerX
The x offset of the tile representing the player. |
private int |
playerY
The y offset of the tile representing the player. |
private static long |
serialVersionUID
The serial version UID. |
private int |
tileSize
The size of one tile. |
| Fields inherited from class com.realtime.crossfire.jxclient.gui.gui.GUIElement |
|---|
bufferedImageSync |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
protected |
AbstractGUIMap(TooltipManager tooltipManager,
GUIElementListener elementListener,
java.lang.String name,
Extent extent,
CfMapUpdater mapUpdater,
FacesProvider facesProvider)
Creates a new instance. |
| Method Summary | |
|---|---|
void |
dispose()
Releases all allocated resources. |
protected int |
getMapHeight()
Returns the map height in squares. |
protected int |
getMapWidth()
Returns the map width in squares. |
int |
getOffsetX()
Returns the x offset for drawing the square at coordinate 0 of the map. |
int |
getOffsetY()
Returns the y offset for drawing the square at coordinate 0 of the map. |
int |
getPlayerX()
Returns the x offset of the tile representing the player. |
int |
getPlayerY()
Returns the y offset of the tile representing the player. |
protected abstract void |
markPlayer(java.awt.Graphics g,
int dx,
int dy)
Paints the player location. |
protected void |
paintColoredSquare(java.awt.Graphics g,
java.awt.Color color,
int x,
int y)
Fills a square with one Color. |
private void |
paintImage(java.awt.Graphics g,
Face face,
int px,
int py,
int offsetX,
int offsetY)
Paints a face into a tile. |
protected abstract void |
paintSquareBackground(java.awt.Graphics g,
int px,
int py,
boolean hasImage,
CfMapSquare mapSquare)
Paints the background of a map square. |
private void |
redrawAll()
Redraws the complete map view. |
private void |
redrawAllUnlessDirty(java.awt.Graphics g,
CfMap map)
Redraws all non-dirty tiles. |
protected void |
redrawSquare(java.awt.Graphics g,
CfMapSquare mapSquare,
int x,
int y)
Redraws one square. |
private void |
redrawSquare(java.awt.Graphics g,
int x,
int y,
CfMapSquare mapSquare)
Redraws one layer of a square. |
private void |
redrawSquareUnlessDirty(java.awt.Graphics g,
CfMap map,
int x,
int y)
Redraws one square if it is not dirty. |
private void |
redrawTiles(java.awt.Graphics g,
CfMap map,
int x0,
int y0,
int x1,
int y1)
Redraws a rectangular area of tiles. |
private void |
redrawTilesUnlessDirty(java.awt.Graphics g,
CfMap map,
int x0,
int y0,
int x1,
int y1)
Redraws a rectangular area of non-dirty tiles. |
protected void |
render(java.awt.Graphics2D g2)
Paints the element's contents into the passed graphics. |
private void |
setMapSize(int mapWidth,
int mapHeight)
Sets the map size. |
void |
updateResolution(int screenWidth,
int screenHeight)
Updates the location and size to a new screen resolution. |
private void |
updateScrolledMap(java.awt.Graphics g,
int dx,
int dy)
Updates the map display after the map contents have scrolled. |
| Methods inherited from class com.realtime.crossfire.jxclient.gui.gui.GUIElement |
|---|
createBufferGraphics, getElementX, getElementY, getGui, getName, getTooltipText, hasBufferedImage, isChanged, isDefault, isElementAtPoint, isElementVisible, isIgnore, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paintComponent, resetChanged, setChanged, setChangedListener, setChangedNoListeners, setDefault, setElementLocation, setElementSize, setElementVisible, setGui, setIgnore, setTooltipText, setTooltipText, toString, updateResolutionConstant |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
|---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private int displayMaxOffsetX
0<=displayMaxOffsetX<tileSize.
private int displayMaxOffsetY
0<=displayMaxOffsetY<tileSize.
private int displayMaxX
mapWidth if the map view is larger than the gui's area.
private int displayMaxY
mapWidth if the map view is larger than the gui's area.
private int displayMinOffsetX
-tileSize.
private int displayMinOffsetY
-tileSize.
private int displayMinX
private int displayMinY
@NotNull private final FacesProvider facesProvider
FacesProvider for looking up faces.
@NotNull private final java.util.Map<java.awt.Color,java.awt.Image> images
Color to an image filled with this color with a size of one
square.
private int mapHeight
@NotNull private final MapListener mapListener
MapListener registered to receive map updates.
@NotNull private final MapScrollListener mapscrollListener
MapScrollListener registered to receive map_scroll commands.
@NotNull private final MapSizeListener mapSizeListener
MapSizeListener registered to detect map size changes.
@NotNull private final CfMapUpdater mapUpdater
CfMapUpdater instance to display.
private int mapWidth
@NotNull private final NewmapListener newmapListener
NewmapListener registered to receive newmap commands.
private int offsetX
private int offsetY
private int playerX
private int playerY
private static final long serialVersionUID
private final int tileSize
| Constructor Detail |
|---|
protected AbstractGUIMap(@NotNull
TooltipManager tooltipManager,
@NotNull
GUIElementListener elementListener,
@NotNull
java.lang.String name,
@NotNull
Extent extent,
@NotNull
CfMapUpdater mapUpdater,
@NotNull
FacesProvider facesProvider)
tooltipManager - the tooltip manager to updateelementListener - the element listener to notifyname - the name of this elementextent - the extent of this elementmapUpdater - the map updater instance to usefacesProvider - the faces provider for looking up faces| Method Detail |
|---|
public void dispose()
dispose in class GUIElementprotected int getMapHeight()
protected int getMapWidth()
public int getOffsetX()
public int getOffsetY()
public int getPlayerX()
public int getPlayerY()
protected abstract void markPlayer(@NotNull
java.awt.Graphics g,
int dx,
int dy)
g - the graphics to paint todx - the x distance to map has just scrolleddy - the y distance to map has just scrolled
protected void paintColoredSquare(@NotNull
java.awt.Graphics g,
@NotNull
java.awt.Color color,
int x,
int y)
Color.
g - the graphics to paint intocolor - the colorx - the x-coordinatey - the y-coordinate
private void paintImage(@NotNull
java.awt.Graphics g,
@NotNull
Face face,
int px,
int py,
int offsetX,
int offsetY)
g - the graphics to draw intoface - the face to drawpx - the x coordinate of the square to redrawpy - the y coordinate of the square to redrawoffsetX - the x-offset for shifting the original faceoffsetY - the y-offset for shifting the original face
protected abstract void paintSquareBackground(@NotNull
java.awt.Graphics g,
int px,
int py,
boolean hasImage,
@NotNull
CfMapSquare mapSquare)
g - the graphics to paint intopx - the x-offset for paintingpy - the y-offset for paintinghasImage - whether the square contains at least one imagemapSquare - the map squareprivate void redrawAll()
private void redrawAllUnlessDirty(@NotNull
java.awt.Graphics g,
@NotNull
CfMap map)
g - the graphics to draw intomap - the map
protected void redrawSquare(@NotNull
java.awt.Graphics g,
@NotNull
CfMapSquare mapSquare,
int x,
int y)
g - the graphics to draw intomapSquare - the map square to drawx - the x-coordinate of the map tile to redrawy - the y-coordinate of the map tile to redraw
private void redrawSquare(@NotNull
java.awt.Graphics g,
int x,
int y,
@NotNull
CfMapSquare mapSquare)
g - the graphics to draw intox - the x coordinate of the square to redrawy - the y coordinate of the square to redrawmapSquare - the map square
private void redrawSquareUnlessDirty(@NotNull
java.awt.Graphics g,
@NotNull
CfMap map,
int x,
int y)
g - the graphics to draw intomap - the map to drawx - the x-coordinate of the square to cleary - the y-coordinate of the square to clear
private void redrawTiles(@NotNull
java.awt.Graphics g,
@NotNull
CfMap map,
int x0,
int y0,
int x1,
int y1)
g - the graphics to draw intomap - the map to drawx0 - the left edge to redraw (inclusive)y0 - the top edge to redraw (inclusive)x1 - the right edge to redraw (exclusive)y1 - the bottom edge to redraw (exclusive)
private void redrawTilesUnlessDirty(@NotNull
java.awt.Graphics g,
@NotNull
CfMap map,
int x0,
int y0,
int x1,
int y1)
g - the graphics to draw intomap - the map to drawx0 - the left edge to redraw (inclusive)y0 - the top edge to redraw (inclusive)x1 - the right edge to redraw (exclusive)y1 - the bottom edge to redraw (exclusive)
protected void render(@NotNull
java.awt.Graphics2D g2)
render in class GUIElementg2 - the graphics to paint to
private void setMapSize(int mapWidth,
int mapHeight)
mapWidth - the map width in squaresmapHeight - the map height in squares
public void updateResolution(int screenWidth,
int screenHeight)
updateResolution in class GUIElementscreenWidth - the new screen widthscreenHeight - the new screen height
private void updateScrolledMap(@NotNull
java.awt.Graphics g,
int dx,
int dy)
g - the graphics to updatedx - the x-distancedy - the y-distance