rails.ui.swing.hexmap
Class GUIHex

java.lang.Object
  extended by rails.ui.swing.hexmap.GUIHex
All Implemented Interfaces:
java.util.Observer, ViewObject

public class GUIHex
extends java.lang.Object
implements ViewObject

Base class that holds common components for GUIHexes of all orientations.


Field Summary
(package private) static boolean antialias
          Globally turns antialiasing on or off for all hexes.
static java.awt.Color BAR_COLOUR
           
static int BAR_WIDTH
           
protected  java.util.List<java.lang.Integer> barStartPoints
           
(package private)  int baseRotation
           
protected  java.awt.Point center
           
static double CITY_SIZE
           
protected  GUITile currentGUITile
           
protected  TileI currentTile
           
protected  int currentTileId
           
protected  int currentTileOrientation
           
(package private)  java.awt.geom.GeneralPath hexagon
           
protected  HexMap hexMap
           
protected  java.lang.String hexName
           
protected static java.awt.Color highlightColor
           
protected  java.awt.geom.GeneralPath innerHexagonSelectable
           
protected  java.awt.geom.GeneralPath innerHexagonSelected
           
protected static org.apache.log4j.Logger log
           
protected  MapHex model
           
static double NORMAL_SCALE
           
static int NORMAL_TOKEN_SIZE
           
protected  java.util.List<TokenI> offStationTokens
           
protected  int originalTileId
           
protected  GUITile provisionalGUITile
           
protected  GUIToken provisionalGUIToken
           
(package private)  java.awt.Rectangle rectBound
           
static double SELECTABLE_SCALE
           
protected static java.awt.Color selectableColor
           
static double SELECTED_SCALE
           
static double SQRT3
           
static double TILE_GRID_SCALE
           
protected  java.lang.String tileFilename
           
protected  double tileScale
           
protected  int tokenDiameter
           
protected  java.lang.String toolTip
           
protected  boolean upgradeMustConnect
           
(package private) static boolean useOverlay
          Globally turns overlay on or off for all hexes
protected  int x
          x and y coordinates on the map
(package private)  double[] xVertex
           
protected  int y
          x and y coordinates on the map
(package private)  double[] yVertex
           
protected  double zoomFactor
           
 
Constructor Summary
GUIHex(HexMap hexMap, double cx, double cy, int scale, int xCoord, int yCoord)
           
 
Method Summary
 void addBar(int orientation)
           
 boolean canFixTile()
           
 boolean contains(java.awt.Point point)
           
 boolean contains(java.awt.geom.Point2D.Double point)
           
 void deRegister()
          Needed to satisfy the ViewObject interface.
protected  void drawBar(java.awt.Graphics2D g2d, int x1, int y1, int x2, int y2)
           
 boolean dropTile(int tileId, boolean upgradeMustConnect)
           
 void fixTile()
           
 void fixToken()
           
 void forcedDropTile(int tileId, int orientation)
          forces the tile to drop
 void forcedRotateTile()
           
(package private) static boolean getAntialias()
           
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Point2D getCenterPoint2D()
           
 java.awt.geom.Point2D getCityPoint2D(City city)
           
 TileI getCurrentTile()
           
 HexMap getHexMap()
           
 MapHex getHexModel()
           
 java.awt.Point getHexPoint(int side)
          returns point that corresponds to the definition as networkvertex
 ModelObject getModel()
           
 java.lang.String getName()
           
(package private) static boolean getOverlay()
           
 TileI getProvisionalTile()
           
 int getProvisionalTileRotation()
           
 java.awt.geom.Point2D getSidePoint2D(int side)
           
 java.lang.String getToolTip()
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
 boolean isSelectable()
           
 boolean isSelected()
           
(package private) static java.awt.geom.GeneralPath makePolygon(int sides, double[] x, double[] y, boolean closed)
          Return a GeneralPath polygon, with the passed number of sides, and the passed x and y coordinates.
 void paint(java.awt.Graphics g)
           
 void paintBars(java.awt.Graphics g)
           
 void removeTile()
           
 void removeToken()
           
 void rotateTile()
           
 void scaleHex(double cx, double cy, int scale, double zoomFactor)
           
(package private) static void setAntialias(boolean enabled)
           
 void setBounds(java.awt.Rectangle rectBound)
           
 void setHexModel(MapHex model)
           
static void setOverlay(boolean enabled)
           
static void setScale(double scale)
           
 void setSelectable(boolean selectable)
           
 void setSelected(boolean selected)
           
 void setTileOrientation(int tileOrientation)
           
 java.lang.String toString()
           
 void update(java.util.Observable observable, java.lang.Object notificationObject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SQRT3

public static final double SQRT3

NORMAL_SCALE

public static double NORMAL_SCALE

SELECTABLE_SCALE

public static double SELECTABLE_SCALE

SELECTED_SCALE

public static double SELECTED_SCALE

NORMAL_TOKEN_SIZE

public static int NORMAL_TOKEN_SIZE

TILE_GRID_SCALE

public static double TILE_GRID_SCALE

CITY_SIZE

public static double CITY_SIZE

BAR_COLOUR

public static java.awt.Color BAR_COLOUR

BAR_WIDTH

public static int BAR_WIDTH

model

protected MapHex model

innerHexagonSelected

protected java.awt.geom.GeneralPath innerHexagonSelected

innerHexagonSelectable

protected java.awt.geom.GeneralPath innerHexagonSelectable

highlightColor

protected static final java.awt.Color highlightColor

selectableColor

protected static final java.awt.Color selectableColor

center

protected java.awt.Point center

x

protected int x
x and y coordinates on the map


y

protected int y
x and y coordinates on the map


zoomFactor

protected double zoomFactor

tokenDiameter

protected int tokenDiameter

hexMap

protected HexMap hexMap

hexName

protected java.lang.String hexName

currentTileId

protected int currentTileId

originalTileId

protected int originalTileId

currentTileOrientation

protected int currentTileOrientation

tileFilename

protected java.lang.String tileFilename

currentTile

protected TileI currentTile

currentGUITile

protected GUITile currentGUITile

provisionalGUITile

protected GUITile provisionalGUITile

upgradeMustConnect

protected boolean upgradeMustConnect

offStationTokens

protected java.util.List<TokenI> offStationTokens

barStartPoints

protected java.util.List<java.lang.Integer> barStartPoints

provisionalGUIToken

protected GUIToken provisionalGUIToken

tileScale

protected double tileScale

toolTip

protected java.lang.String toolTip

xVertex

double[] xVertex

yVertex

double[] yVertex

hexagon

java.awt.geom.GeneralPath hexagon

rectBound

java.awt.Rectangle rectBound

baseRotation

int baseRotation

antialias

static boolean antialias
Globally turns antialiasing on or off for all hexes.


useOverlay

static boolean useOverlay
Globally turns overlay on or off for all hexes


log

protected static org.apache.log4j.Logger log
Constructor Detail

GUIHex

public GUIHex(HexMap hexMap,
              double cx,
              double cy,
              int scale,
              int xCoord,
              int yCoord)
Method Detail

setScale

public static void setScale(double scale)

scaleHex

public void scaleHex(double cx,
                     double cy,
                     int scale,
                     double zoomFactor)

getHexPoint

public java.awt.Point getHexPoint(int side)
returns point that corresponds to the definition as networkvertex


getHexModel

public MapHex getHexModel()

getHexMap

public HexMap getHexMap()

getCityPoint2D

public java.awt.geom.Point2D getCityPoint2D(City city)

getSidePoint2D

public java.awt.geom.Point2D getSidePoint2D(int side)

getCenterPoint2D

public java.awt.geom.Point2D getCenterPoint2D()

setHexModel

public void setHexModel(MapHex model)

addBar

public void addBar(int orientation)

getBounds

public java.awt.Rectangle getBounds()

setBounds

public void setBounds(java.awt.Rectangle rectBound)

contains

public boolean contains(java.awt.geom.Point2D.Double point)

contains

public boolean contains(java.awt.Point point)

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)

setSelected

public void setSelected(boolean selected)

isSelected

public boolean isSelected()

setSelectable

public void setSelectable(boolean selectable)

isSelectable

public boolean isSelectable()

getAntialias

static boolean getAntialias()

setAntialias

static void setAntialias(boolean enabled)

getOverlay

static boolean getOverlay()

setOverlay

public static void setOverlay(boolean enabled)

makePolygon

static java.awt.geom.GeneralPath makePolygon(int sides,
                                             double[] x,
                                             double[] y,
                                             boolean closed)
Return a GeneralPath polygon, with the passed number of sides, and the passed x and y coordinates. Close the polygon if the argument closed is true.


paint

public void paint(java.awt.Graphics g)

paintBars

public void paintBars(java.awt.Graphics g)

drawBar

protected void drawBar(java.awt.Graphics2D g2d,
                       int x1,
                       int y1,
                       int x2,
                       int y2)

rotateTile

public void rotateTile()

forcedRotateTile

public void forcedRotateTile()

getName

public java.lang.String getName()
Returns:
Returns the name.

getCurrentTile

public TileI getCurrentTile()
Returns:
Returns the currentTile.

setTileOrientation

public void setTileOrientation(int tileOrientation)
Parameters:
currentTileOrientation - The currentTileOrientation to set.

getToolTip

public java.lang.String getToolTip()

dropTile

public boolean dropTile(int tileId,
                        boolean upgradeMustConnect)

forcedDropTile

public void forcedDropTile(int tileId,
                           int orientation)
forces the tile to drop


removeTile

public void removeTile()

canFixTile

public boolean canFixTile()

getProvisionalTile

public TileI getProvisionalTile()

getProvisionalTileRotation

public int getProvisionalTileRotation()

fixTile

public void fixTile()

removeToken

public void removeToken()

fixToken

public void fixToken()

deRegister

public void deRegister()
Needed to satisfy the ViewObject interface. Currently not used.

Specified by:
deRegister in interface ViewObject

getModel

public ModelObject getModel()
Specified by:
getModel in interface ViewObject

update

public void update(java.util.Observable observable,
                   java.lang.Object notificationObject)
Specified by:
update in interface java.util.Observer

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object