|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.client.gui.GUI
public final class GUI
This class is responsible for drawing the map/background on the
Canvas. In addition, the graphical state of the map (focus,
active unit..) is also a responsibility of this class.
| Nested Class Summary | |
|---|---|
(package private) static class |
GUI.GrayLayer
Custom component to paint turn progress. |
private class |
GUI.IndicatorImageKey
For performance reason, indicator images are rendered once and cached for reuse. |
private class |
GUI.StringImageKey
For performance reason, string images are rendered once and cached for reuse. |
| Field Summary | |
|---|---|
private Unit |
activeUnit
|
static int |
ALARM_OFFSET_X
|
static int |
ALARM_OFFSET_Y
|
private boolean |
blinkingMarqueeEnabled
|
private java.util.EnumMap<Map.Direction,java.awt.Dimension> |
borderPoints
|
private java.awt.Stroke |
borderStroke
|
private int |
bottomRow
|
private int |
bottomRows
|
private int |
bottomRowY
|
private java.util.EnumMap<Map.Direction,java.awt.Dimension> |
controlPoints
|
private PathNode |
currentPath
A path to be displayed on the map. |
private TerrainCursor |
cursor
|
private java.awt.Image |
cursorImage
|
boolean |
debugShowMission
|
boolean |
debugShowMissionInfo
|
boolean |
displayColonyValue
|
Player |
displayColonyValuePlayer
|
boolean |
displayCoordinates
|
private int |
displayTileText
|
private Map.Position |
focus
|
static int |
FOREST_INDEX
|
private FreeColClient |
freeColClient
|
private PathNode |
gotoPath
|
private boolean |
gotoStarted
|
private GUI.GrayLayer |
greyLayer
|
private java.awt.geom.GeneralPath |
gridPath
|
private java.util.HashMap<GUI.IndicatorImageKey,java.awt.image.BufferedImage> |
indicatorImageCache
|
private boolean |
inGame
Indicates if the game has started, has nothing to do with whether or not the client is logged in. |
private int |
leftColumn
|
private int |
leftColumnX
|
private int |
leftSpace
|
private ImageLibrary |
lib
Scaled ImageLibrary only used for map painting. |
private static java.util.logging.Logger |
logger
|
static int |
MAX_OTHER_UNITS
|
static int |
MESSAGE_AGE
|
static int |
MESSAGE_COUNT
|
private java.util.Vector<GUIMessage> |
messages
|
static int |
MISSION_OFFSET_X
|
static int |
MISSION_OFFSET_Y
|
static int |
OTHER_UNITS_OFFSET_X
|
static int |
OTHER_UNITS_OFFSET_Y
|
static int |
OTHER_UNITS_WIDTH
|
static int |
OVERLAY_INDEX
|
private int |
rightColumn
|
private int |
rightSpace
|
static int |
RUMOUR_OFFSET_X
|
static int |
RUMOUR_OFFSET_Y
|
private Map.Position |
selectedTile
|
private java.awt.Dimension |
size
|
static int |
STATE_OFFSET_X
|
static int |
STATE_OFFSET_Y
|
private java.util.HashMap<GUI.StringImageKey,java.awt.image.BufferedImage> |
stringImageCache
|
static int |
TEXT_OFFSET_X
|
static int |
TEXT_OFFSET_Y
|
private int |
tileHeight
|
private int |
tileWidth
|
private int |
topRow
|
private int |
topRows
|
private int |
topRowY
|
private int |
topSpace
|
static int |
UNIT_OFFSET
|
private java.util.Map<Unit,java.lang.Integer> |
unitsOutForAnimation
|
private java.util.Map<Unit,javax.swing.JLabel> |
unitsOutForAnimationLabels
|
private ViewMode |
viewMode
|
| Constructor Summary | |
|---|---|
GUI(FreeColClient freeColClient,
java.awt.Dimension size,
ImageLibrary lib)
The constructor to use. |
|
| Method Summary | |
|---|---|
void |
addMessage(GUIMessage message)
Adds a message to the list of messages that need to be displayed on the GUI. |
Map.Position |
convertToMapCoordinates(int x,
int y)
Converts the given screen coordinates to Map coordinates. |
private java.awt.image.BufferedImage |
createSettlementNameImage(java.awt.Graphics g,
Settlement settlement,
int maxWidth,
int preferredFontSize)
|
java.awt.image.BufferedImage |
createStringImage(java.awt.Graphics2D g,
java.lang.String nameString,
java.awt.Color color,
int maxWidth,
int preferredFontSize)
Creates an image with a string of a given color and with a black border around the glyphs. |
private java.awt.image.BufferedImage |
createStringImage(javax.swing.JComponent c,
java.awt.Graphics g,
java.lang.String nameString,
java.awt.Color color,
int maxWidth,
int preferredFontSize)
Creates an image with a string of a given color and with a black border around the glyphs. |
java.awt.image.BufferedImage |
createStringImage(javax.swing.JComponent c,
java.lang.String nameString,
java.awt.Color color,
int maxWidth,
int preferredFontSize)
Creates an image with a string of a given color and with a black border around the glyphs. |
void |
display(java.awt.Graphics2D g)
Displays this GUI onto the given Graphics2D. |
private void |
displayBaseTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean drawUnexploredBorders)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
void |
displayColonyTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
Colony colony)
Displays the given Tile onto the given
Graphics2D object at the location specified by the
coordinates. |
private void |
displayFogOfWar(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
private void |
displayGotoPath(java.awt.Graphics2D g,
PathNode gotoPath)
|
private void |
displayMap(java.awt.Graphics2D g)
Displays the Map onto the given Graphics2D object. |
void |
displayOccupationIndicator(java.awt.Graphics g,
Unit unit,
int x,
int y)
|
private void |
displayOptionalValues(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
private void |
displaySettlement(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean withNumber)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
void |
displayTerrain(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
void |
displayTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
void |
displayTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean drawUnexploredBorders)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
private void |
displayTileItems(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
private void |
displayTileOverlays(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean drawUnexploredBorders,
boolean withNumber)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
private void |
displayUnexploredBorders(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
Displays the given Tile onto the given Graphics2D object at the location specified by the coordinates. |
private void |
displayUnit(java.awt.Graphics2D g,
Unit unit,
int x,
int y)
Displays the given Unit onto the given Graphics2D object at the location specified by the coordinates. |
private void |
drawCursor(java.awt.Graphics2D g,
int x,
int y)
|
private void |
drawItem(java.awt.Graphics2D g,
Tile tile,
TileItem item,
int x,
int y)
|
void |
drawRoad(java.awt.Graphics2D g,
long seed,
int x1,
int y1,
int x2,
int y2)
Draws a road, between the given points, on the provided Graphics. |
private javax.swing.JLabel |
enterUnitOutForAnimation(Unit unit,
Tile sourceTile)
|
void |
executeWithUnitOutForAnimation(Unit unit,
Tile sourceTile,
OutForAnimationCallback r)
Run some code with the given unit made invisible. |
void |
forceReposition()
Force the next screen repaint to reposition the tiles on the window. |
Unit |
getActiveUnit()
Gets the active unit. |
int |
getBreakingPoint(java.lang.String string)
Breaks a line between two words. |
TerrainCursor |
getCursor()
|
Map.Position |
getFocus()
Gets the focus of the map. |
private java.awt.Color |
getForegroundColor(java.awt.Color background)
|
PathNode |
getGotoPath()
Gets the path to be drawn on the map. |
int |
getHeight()
Returns the height of this GUI. |
private int |
getLeftColumns()
Returns the amount of columns that are to the left of the Tile that is displayed in the center of the Map. |
private int |
getLeftColumns(int y)
Returns the amount of columns that are to the left of the Tile with the given y-coordinate. |
float |
getMapScale()
Get the current scale of the map. |
GUIMessage |
getMessage(int index)
Gets the message at position 'index'. |
int |
getMessageCount()
Gets the amount of message that are currently being displayed on this GUI. |
private java.awt.Image |
getOccupationIndicatorImage(Unit unit)
|
private java.awt.Image |
getPathImage(Unit u)
Gets an image to represent the path of the given Unit. |
private java.awt.Image |
getPathNextTurnImage(Unit u)
Gets an image to represent the path of the given Unit. |
private int |
getRightColumns()
Returns the amount of columns that are to the right of the Tile that is displayed in the center of the Map. |
private int |
getRightColumns(int y)
Returns the amount of columns that are to the right of the Tile with the given y-coordinate. |
Map.Position |
getSelectedTile()
Gets the selected tile. |
private java.awt.Color |
getStringBorderColor(java.awt.Color color)
|
java.awt.Rectangle |
getTileBounds(int x,
int y)
Calculate the bounds of the rectangle containing a Tile on the screen, and return it. |
java.awt.Rectangle |
getTileBounds(Tile tile)
Calculate the bounds of the rectangle containing a Tile on the screen, and return it. |
int |
getTileHeight()
|
java.awt.Point |
getTilePosition(Tile t)
Gets the position of the given Tile on the drawn map. |
int |
getTileWidth()
|
private java.awt.Point |
getUnitImagePositionInTile(java.awt.Image unitImage,
int tileX,
int tileY)
Gets the coordinates to draw a unit in a given tile. |
private java.awt.Point |
getUnitImagePositionInTile(int unitImageWidth,
int unitImageHeight,
int tileX,
int tileY)
Gets the coordinates to draw a unit in a given tile. |
Unit |
getUnitInFront(Tile unitTile)
Gets the unit that should be displayed on the given tile. |
private javax.swing.JLabel |
getUnitLabel(Unit unit)
Draw the unit's image and occupation indicator in one JLabel object. |
java.awt.Point |
getUnitLabelPositionInTile(javax.swing.JLabel unitLabel,
java.awt.Point tileP)
Gets the position where a unitLabel located at tile should be drawn. |
java.awt.Point |
getUnitLabelPositionInTile(javax.swing.JLabel unitLabel,
Tile tile)
Gets the position where a unitLabel located at tile should be drawn. |
ViewMode |
getViewMode()
Get the View Mode object |
int |
getWidth()
Returns the width of this GUI. |
private int |
getXOffset(int clipLeftX,
int tileY)
|
boolean |
isGotoStarted()
Checks if there is currently a goto operation on the mapboard. |
boolean |
isInGame()
Checks if the game has started. |
boolean |
isMapNearBottom(int y)
Returns 'true' if the Tile is near the bottom. |
boolean |
isMapNearLeft(int x,
int y)
Returns 'true' if the Tile is near the left. |
boolean |
isMapNearRight(int x,
int y)
Returns 'true' if the Tile is near the right. |
boolean |
isMapNearTop(int y)
Returns 'true' if the Tile is near the top. |
private boolean |
isOutForAnimation(Unit unit)
|
void |
moveTileCursor(Map.Direction direction)
|
boolean |
onScreen(int x,
int y)
Checks if the Tile/Units at the given coordinates are displayed on the screen (or, if the map is already displayed and the focus has been changed, whether they will be displayed on the screen the next time it'll be redrawn). |
boolean |
onScreen(Map.Position position)
Checks if the Tile/Units at the given coordinates are displayed on the screen (or, if the map is already displayed and the focus has been changed, whether they will be displayed on the screen the next time it'll be redrawn). |
private void |
paintBorders(java.awt.Graphics2D g,
Tile tile,
int x,
int y,
boolean opaque)
|
private void |
positionMap()
Position the map so that the Tile at the focus location is displayed at the center. |
private void |
releaseUnitOutForAnimation(Unit unit)
|
boolean |
removeOldMessages()
Removes all the message that are older than MESSAGE_AGE. |
void |
restartBlinking()
|
void |
scaleMap(float delta)
Change the scale of the map by delta. |
void |
setActiveUnit(Unit activeUnit)
Sets the active unit. |
void |
setDisplayTileText(DisplayTileTextAction.DisplayText tileTextType)
Set the type of text drawn in the tiles. |
void |
setFocus(int x,
int y)
Sets the focus of the map. |
void |
setFocus(Map.Position focus)
Sets the focus of the map. |
void |
setFocusImmediately(Map.Position focus)
Sets the focus of the map and repaints the screen immediately. |
void |
setGotoPath(PathNode gotoPath)
Sets the path to be drawn on the map. |
private void |
setImageLibrary(ImageLibrary lib)
|
void |
setInGame(boolean inGame)
Notifies this GUI that the game has started or ended. |
void |
setSelectedTile(Map.Position selectedTile)
Selects the tile at the specified position, without clearing the orders of the first unit contained. |
void |
setSelectedTile(Map.Position selectedTile,
boolean clearGoToOrders)
Selects the tile at the specified position. |
void |
setSize(java.awt.Dimension size)
|
void |
showColonyPanel(Map.Position selectedTile)
|
void |
startCursorBlinking()
Starts the unit-selection-cursor blinking animation. |
void |
startGoto()
Starts a goto operation on the mapboard. |
void |
stopBlinking()
|
void |
stopGoto()
Stops any ongoing goto operation on the mapboard. |
void |
updateGotoPathForActiveUnit()
Sets the path of the active unit to display it. |
private void |
updateMapDisplayVariables()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private final FreeColClient freeColClient
private java.awt.Dimension size
private ImageLibrary lib
private TerrainCursor cursor
private ViewMode viewMode
private boolean inGame
private final java.util.Vector<GUIMessage> messages
private Map.Position selectedTile
private Map.Position focus
private Unit activeUnit
private PathNode currentPath
private PathNode gotoPath
private boolean gotoStarted
private int tileHeight
private int tileWidth
private int topSpace
private int topRows
private int bottomRows
private int leftSpace
private int rightSpace
private int bottomRow
private int topRow
private int bottomRowY
private int topRowY
private int leftColumn
private int rightColumn
private int leftColumnX
public static final int UNIT_OFFSET
public static final int TEXT_OFFSET_X
public static final int TEXT_OFFSET_Y
public static final int STATE_OFFSET_X
public static final int STATE_OFFSET_Y
public static final int ALARM_OFFSET_X
public static final int ALARM_OFFSET_Y
public static final int RUMOUR_OFFSET_X
public static final int RUMOUR_OFFSET_Y
public static final int MISSION_OFFSET_X
public static final int MISSION_OFFSET_Y
public static final int OTHER_UNITS_OFFSET_X
public static final int OTHER_UNITS_OFFSET_Y
public static final int OTHER_UNITS_WIDTH
public static final int MAX_OTHER_UNITS
public static final int MESSAGE_COUNT
public static final int MESSAGE_AGE
public static final int OVERLAY_INDEX
public static final int FOREST_INDEX
private int displayTileText
private java.awt.geom.GeneralPath gridPath
public boolean displayCoordinates
public boolean displayColonyValue
public Player displayColonyValuePlayer
public boolean debugShowMission
public boolean debugShowMissionInfo
private volatile boolean blinkingMarqueeEnabled
private java.awt.Image cursorImage
private GUI.GrayLayer greyLayer
private java.util.Map<Unit,java.lang.Integer> unitsOutForAnimation
private java.util.Map<Unit,javax.swing.JLabel> unitsOutForAnimationLabels
private java.util.EnumMap<Map.Direction,java.awt.Dimension> borderPoints
private java.util.EnumMap<Map.Direction,java.awt.Dimension> controlPoints
private java.awt.Stroke borderStroke
private java.util.HashMap<GUI.StringImageKey,java.awt.image.BufferedImage> stringImageCache
private java.util.HashMap<GUI.IndicatorImageKey,java.awt.image.BufferedImage> indicatorImageCache
| Constructor Detail |
|---|
public GUI(FreeColClient freeColClient,
java.awt.Dimension size,
ImageLibrary lib)
freeColClient - The main control class.size - The size of the GUI (= the entire screen if the app is
displayed in full-screen).lib - The library of images needed to display certain things
visually.| Method Detail |
|---|
private void setImageLibrary(ImageLibrary lib)
private boolean isOutForAnimation(Unit unit)
public void executeWithUnitOutForAnimation(Unit unit,
Tile sourceTile,
OutForAnimationCallback r)
unit - The unit to be hidden.r - The code to be executed.
private javax.swing.JLabel enterUnitOutForAnimation(Unit unit,
Tile sourceTile)
private void releaseUnitOutForAnimation(Unit unit)
private javax.swing.JLabel getUnitLabel(Unit unit)
unit - The unit to be drawn
private void updateMapDisplayVariables()
public ViewMode getViewMode()
View Mode object
public void startCursorBlinking()
public TerrainCursor getCursor()
public void setSize(java.awt.Dimension size)
public void moveTileCursor(Map.Direction direction)
public void setSelectedTile(Map.Position selectedTile)
selectedTile - The Position of the tile to be
selected.setSelectedTile(Map.Position, boolean)
public void setSelectedTile(Map.Position selectedTile,
boolean clearGoToOrders)
Colony on the Tile the
Canvas.showColonyPanel(net.sf.freecol.common.model.Colony) will be invoked.
true
selectedTile will become the map focus.
selectedTile - The Position of the tile to be
selected.clearGoToOrders - Use true to clear goto orders of
the unit which is activated.getSelectedTile(),
setActiveUnit(net.sf.freecol.common.model.Unit),
setFocus(Map.Position)public void showColonyPanel(Map.Position selectedTile)
public void restartBlinking()
public void stopBlinking()
public Unit getUnitInFront(Tile unitTile)
unitTile - The Tile.
Unit or null if no unit applies.public Map.Position getSelectedTile()
Position of that tile.setSelectedTile(Map.Position)public Unit getActiveUnit()
Unit.setActiveUnit(net.sf.freecol.common.model.Unit)public void setActiveUnit(Unit activeUnit)
setSelectedTile(Map.Position) if
the selected tile is another tile than where the activeUnit
is located.
activeUnit - The new active unit.setSelectedTile(Map.Position)public Map.Position getFocus()
Position of the center tile of the displayed
mapsetFocus(Map.Position)public void setFocus(Map.Position focus)
focus - The Position of the center tile of the
displayed map.getFocus()public void setFocusImmediately(Map.Position focus)
focus - The Position of the center tile of the
displayed map.getFocus()
public void setFocus(int x,
int y)
x - The x-coordinate of the center tile of the displayed map.y - The x-coordinate of the center tile of the displayed map.getFocus()public int getMessageCount()
public GUIMessage getMessage(int index)
index - The index of the message to return.
public void addMessage(GUIMessage message)
message - The message to add.public boolean removeOldMessages()
public int getWidth()
public int getHeight()
public void display(java.awt.Graphics2D g)
g - The Graphics2D on which to display this GUI.private int getLeftColumns()
private int getLeftColumns(int y)
y - The y-coordinate of the Tile in question.
private int getRightColumns()
private int getRightColumns(int y)
y - The y-coordinate of the Tile in question.
private void positionMap()
private void displayGotoPath(java.awt.Graphics2D g,
PathNode gotoPath)
private int getXOffset(int clipLeftX,
int tileY)
private void displayMap(java.awt.Graphics2D g)
g - The Graphics2D object on which to draw the Map.private java.awt.Image getPathImage(Unit u)
Unit.
u - The Unit
Image.private java.awt.Image getPathNextTurnImage(Unit u)
Unit.
u - The Unit
Image.
public java.awt.image.BufferedImage createStringImage(java.awt.Graphics2D g,
java.lang.String nameString,
java.awt.Color color,
int maxWidth,
int preferredFontSize)
g - A Graphics-object for getting a
Font.nameString - The String to make an image of.color - The Color to use when displaying the
nameString.maxWidth - The maximum width of the image. The size of the
Font will be adjusted if the image gets larger
than this value.preferredFontSize - The preferred font size.
public java.awt.image.BufferedImage createStringImage(javax.swing.JComponent c,
java.lang.String nameString,
java.awt.Color color,
int maxWidth,
int preferredFontSize)
c - A JComponent-object for getting a
Font.nameString - The String to make an image of.color - The Color to use when displaying the
nameString.maxWidth - The maximum width of the image. The size of the
Font will be adjusted if the image gets larger
than this value.preferredFontSize - The preferred font size.
private java.awt.image.BufferedImage createStringImage(javax.swing.JComponent c,
java.awt.Graphics g,
java.lang.String nameString,
java.awt.Color color,
int maxWidth,
int preferredFontSize)
c - A JComponent-object for getting a
Font.g - A Graphics-object for getting a
Font.nameString - The String to make an image of.color - The Color to use when displaying the
nameString.maxWidth - The maximum width of the image. The size of the
Font will be adjusted if the image gets larger
than this value.preferredFontSize - The preferred font size.
private java.awt.image.BufferedImage createSettlementNameImage(java.awt.Graphics g,
Settlement settlement,
int maxWidth,
int preferredFontSize)
public void drawRoad(java.awt.Graphics2D g,
long seed,
int x1,
int y1,
int x2,
int y2)
Graphics. When you provide the same seed
you will get the same road.
g - The Graphics to draw the road upon.seed - The seed of the random generator that is creating the road.x1 - The x-component of the first coordinate.y1 - The y-component of the first coordinate.x2 - The x-component of the second coordinate.y2 - The y-component of the second coordinate.
public void displayColonyTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
Colony colony)
Tile onto the given
Graphics2D object at the location specified by the
coordinates. The visualization of the Tile also includes
information from the corresponding ColonyTile from the
given Colony.
g - The Graphics2D object on which to draw the
Tile.map - The Map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).colony - The Colony to create the visualization of
the Tile for. This object is also used to get
the ColonyTile for the given Tile.
public void displayTerrain(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
displayTile(g, map, tile, x, y, true);.
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).
public void displayTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
displayTile(g, map, tile, x, y, true);.
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).
public void displayTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean drawUnexploredBorders)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).drawUnexploredBorders - If true; draws border between explored and
unexplored terrain.
private void displayBaseTile(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean drawUnexploredBorders)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).drawUnexploredBorders - If true; draws border between explored and
unexplored terrain.
private void paintBorders(java.awt.Graphics2D g,
Tile tile,
int x,
int y,
boolean opaque)
private void displayTileOverlays(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean drawUnexploredBorders,
boolean withNumber)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).drawUnexploredBorders - If true; draws border between explored and
unexplored terrain.withNumber - indicates if the number of inhabitants should be drawn
too.
private void displayTileItems(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).
private void drawItem(java.awt.Graphics2D g,
Tile tile,
TileItem item,
int x,
int y)
private void displaySettlement(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y,
boolean withNumber)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).
private void displayFogOfWar(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).
private void displayUnexploredBorders(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).
private void displayOptionalValues(java.awt.Graphics2D g,
Map map,
Tile tile,
int x,
int y)
g - The Graphics2D object on which to draw the Tile.map - The map.tile - The Tile to draw.x - The x-coordinate of the location where to draw the Tile (in
pixels).y - The y-coordinate of the location where to draw the Tile (in
pixels).public void stopGoto()
public void startGoto()
public boolean isGotoStarted()
true if a goto operation is in progress.public void updateGotoPathForActiveUnit()
public void setGotoPath(PathNode gotoPath)
gotoPath - The path that should be drawn on the map or
null if no path should be drawn.public PathNode getGotoPath()
null
if no path should be drawn.public void setDisplayTileText(DisplayTileTextAction.DisplayText tileTextType)
tileTextType - a DisplayText valuepublic int getBreakingPoint(java.lang.String string)
string - The line for which we should determine a breaking point.
-1 if there are none.private java.awt.Image getOccupationIndicatorImage(Unit unit)
private java.awt.Color getForegroundColor(java.awt.Color background)
private java.awt.Color getStringBorderColor(java.awt.Color color)
public void displayOccupationIndicator(java.awt.Graphics g,
Unit unit,
int x,
int y)
private void displayUnit(java.awt.Graphics2D g,
Unit unit,
int x,
int y)
g - The Graphics2D object on which to draw the Unit.unit - The Unit to draw.x - The x-coordinate of the location where to draw the Unit (in
pixels). These are the coordinates of the Tile on which the
Unit is located.y - The y-coordinate of the location where to draw the Unit (in
pixels). These are the coordinates of the Tile on which the
Unit is located.
private java.awt.Point getUnitImagePositionInTile(java.awt.Image unitImage,
int tileX,
int tileY)
unitImage - The unit's imagetileX - The X coordinate of the tiletileY - The Y coordinate of the tile
private java.awt.Point getUnitImagePositionInTile(int unitImageWidth,
int unitImageHeight,
int tileX,
int tileY)
unitImageWidth - The unit image's widthunitImageHeight - The unit image's heighttileX - The X coordinate of the tiletileY - The Y coordinate of the tile
public java.awt.Point getUnitLabelPositionInTile(javax.swing.JLabel unitLabel,
Tile tile)
unitLabel - The unit label with the unit's image and occupation
indicator drawn.tile - The tile where the unitLabel will be drawn over
public java.awt.Point getUnitLabelPositionInTile(javax.swing.JLabel unitLabel,
java.awt.Point tileP)
unitLabel - The unit label with the unit's image and occupation
indicator drawn.tileP - The position of the Tile on the screen.
private void drawCursor(java.awt.Graphics2D g,
int x,
int y)
public void setInGame(boolean inGame)
inGame - Indicates whether or not the game has started.public boolean isInGame()
setInGame(boolean)
public boolean onScreen(int x,
int y)
x - The x-coordinate of the Tile in question.y - The y-coordinate of the Tile in question.
public boolean onScreen(Map.Position position)
position - The position of the Tile in question.
public Map.Position convertToMapCoordinates(int x,
int y)
x - The x-coordinate in pixels.y - The y-coordinate in pixels.
public boolean isMapNearTop(int y)
y - The y-coordinate of a Tile.
public boolean isMapNearBottom(int y)
y - The y-coordinate of a Tile.
public boolean isMapNearLeft(int x,
int y)
x - The x-coordinate of a Tile.y - The y-coordinate of a Tile.
public boolean isMapNearRight(int x,
int y)
x - The x-coordinate of a Tile.y - The y-coordinate of a Tile.
public float getMapScale()
float valuepublic void scaleMap(float delta)
delta - a float valuepublic java.awt.Point getTilePosition(Tile t)
Tile on the drawn map.
t - The Tile.
Tile, or
null if the Tile is not drawn on
the mapboard.public java.awt.Rectangle getTileBounds(Tile tile)
tile - The tile on the screen.
public java.awt.Rectangle getTileBounds(int x,
int y)
x - The x-coordinate of the Tiley - The y-coordinate of the Tile
public void forceReposition()
public int getTileHeight()
public int getTileWidth()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||