rails.ui.swing.hexmap
Class HexMap

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by rails.ui.swing.hexmap.HexMap
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
EWHexMap, NSHexMap

public abstract class HexMap
extends javax.swing.JComponent
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Base class that stores common info for HexMap independant of Hex orientations.

See Also:
Serialized Form

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
protected  java.util.List<LayTile> allowedTileLays
          A list of all allowed tile lays
protected  java.util.Map<MapHex,LayTile> allowedTilesPerHex
          A Map linking tile allowed tiles to each map hex
protected  java.util.List<LayToken> allowedTokenLays
          A list of all allowed token lays
protected  java.util.Map<MapHex,java.util.List<LayToken>> allowedTokensPerHex
          A Map linking tile allowed tiles to each map hex
protected  boolean bonusTokenLayingEnabled
           
protected  double coordinateFlatMargin
           
protected  double coordinatePeakMargin
           
protected  double coordinateXMargin
           
protected  double coordinateYMargin
           
protected  double flatMargin
           
protected  GUIHex[][] h
           
protected  MapHex[][] hexArray
           
protected  java.util.ArrayList<GUIHex> hexes
           
protected  java.util.Map<java.lang.String,GUIHex> hexesByName
           
protected static org.apache.log4j.Logger log
           
protected  MapManager mapManager
           
protected  int maxCol
           
protected  int maxRow
           
protected  int maxX
           
protected  int maxY
           
protected  int minCol
           
protected  int minRow
           
protected  int minX
           
protected  int minY
           
protected  ORUIManager orUIManager
           
protected  double peakMargin
           
protected  java.awt.Dimension preferredSize
           
protected  int scale
           
protected  GUIHex selectedHex
           
protected  int strokeCap
           
protected  int strokeJoin
           
protected  int strokeWidth
           
protected  double tileXOffset
           
protected  double tileYOffset
           
protected  java.util.List<java.awt.geom.GeneralPath> trainPaths
          list of generalpath elements to indicate train runs
protected  double zoomFactor
           
protected  int zoomStep
           
 
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
HexMap()
           
 
Method Summary
protected abstract  double calcXCoordinates(int col, double offset)
           
protected abstract  double calcYCoordinates(int row, double offset)
           
protected  void drawLabel(java.awt.Graphics2D g2, int index, int xCoordinate, int yCoordinate, boolean letter)
           
 java.util.List<LayBaseToken> getBaseTokenAllowanceForHex(MapHex hex)
           
 java.util.List<LayBonusToken> getBonusTokenAllowanceForHex(MapHex hex)
           
 GUIHex getHexByName(java.lang.String hexName)
           
(package private)  GUIHex getHexContainingPoint(java.awt.Point point)
           
 MapManager getMapManager()
           
 ORUIManager getOrUIManager()
           
 PhaseI getPhase()
          Off-board tiles must be able to retrieve the current phase.
 java.awt.Dimension getPreferredSize()
           
 GUIHex getSelectedHex()
           
 java.util.List<LayTile> getTileAllowancesForHex(MapHex hex)
           
 java.util.List<LayToken> getTokenAllowanceForHex(MapHex hex)
           
 int getZoomStep()
           
 void init(ORUIManager orUIManager, MapManager mapManager)
           
 boolean isAHexSelected()
           
 void mouseClicked(java.awt.event.MouseEvent arg0)
           
 void mouseDragged(java.awt.event.MouseEvent arg0)
           
 void mouseEntered(java.awt.event.MouseEvent arg0)
           
 void mouseExited(java.awt.event.MouseEvent arg0)
           
 void mouseMoved(java.awt.event.MouseEvent arg0)
           
 void mousePressed(java.awt.event.MouseEvent arg0)
           
 void mouseReleased(java.awt.event.MouseEvent arg0)
           
 void paint(java.awt.Graphics g)
           
 void paintComponent(java.awt.Graphics g)
           
protected  void scaleHexesGUI()
           
 void selectHex(GUIHex clickedHex)
           
 void setAllowedTileLays(java.util.List<LayTile> allowedTileLays)
           
<T extends LayToken>
void
setAllowedTokenLays(java.util.List<T> allowedTokenLays)
           
static void setRouteColours()
           
protected  void setScale()
           
 void setSelectedHex(GUIHex hex)
           
protected abstract  void setSize()
           
 void setTrainPaths(java.util.List<java.awt.geom.GeneralPath> trainPaths)
           
 void setupBars()
           
 void setupHexes()
           
protected  void setupHexesGUI()
           
 void updateOffBoardToolTips()
           
protected  void zoom()
           
 void zoomIn()
           
 void zoomOut()
           
 
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, 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, 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, transferFocusBackward, 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, getName, 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, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log

orUIManager

protected ORUIManager orUIManager

mapManager

protected MapManager mapManager

h

protected GUIHex[][] h

hexArray

protected MapHex[][] hexArray

hexesByName

protected java.util.Map<java.lang.String,GUIHex> hexesByName

hexes

protected java.util.ArrayList<GUIHex> hexes

scale

protected int scale

zoomStep

protected int zoomStep

zoomFactor

protected double zoomFactor

peakMargin

protected double peakMargin

flatMargin

protected double flatMargin

coordinatePeakMargin

protected double coordinatePeakMargin

coordinateFlatMargin

protected double coordinateFlatMargin

selectedHex

protected GUIHex selectedHex

preferredSize

protected java.awt.Dimension preferredSize

minX

protected int minX

minY

protected int minY

maxX

protected int maxX

maxY

protected int maxY

minCol

protected int minCol

maxCol

protected int maxCol

minRow

protected int minRow

maxRow

protected int maxRow

allowedTileLays

protected java.util.List<LayTile> allowedTileLays
A list of all allowed tile lays


allowedTilesPerHex

protected java.util.Map<MapHex,LayTile> allowedTilesPerHex
A Map linking tile allowed tiles to each map hex


allowedTokenLays

protected java.util.List<LayToken> allowedTokenLays
A list of all allowed token lays


allowedTokensPerHex

protected java.util.Map<MapHex,java.util.List<LayToken>> allowedTokensPerHex
A Map linking tile allowed tiles to each map hex


bonusTokenLayingEnabled

protected boolean bonusTokenLayingEnabled

trainPaths

protected java.util.List<java.awt.geom.GeneralPath> trainPaths
list of generalpath elements to indicate train runs


strokeWidth

protected int strokeWidth

strokeCap

protected int strokeCap

strokeJoin

protected int strokeJoin

tileXOffset

protected double tileXOffset

tileYOffset

protected double tileYOffset

coordinateXMargin

protected double coordinateXMargin

coordinateYMargin

protected double coordinateYMargin
Constructor Detail

HexMap

public HexMap()
Method Detail

calcXCoordinates

protected abstract double calcXCoordinates(int col,
                                           double offset)

calcYCoordinates

protected abstract double calcYCoordinates(int row,
                                           double offset)

setSize

protected abstract void setSize()

setRouteColours

public static void setRouteColours()

init

public void init(ORUIManager orUIManager,
                 MapManager mapManager)

setupHexesGUI

protected void setupHexesGUI()

scaleHexesGUI

protected void scaleHexesGUI()

drawLabel

protected void drawLabel(java.awt.Graphics2D g2,
                         int index,
                         int xCoordinate,
                         int yCoordinate,
                         boolean letter)

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

setupHexes

public void setupHexes()

setupBars

public void setupBars()

getHexContainingPoint

GUIHex getHexContainingPoint(java.awt.Point point)

getHexByName

public GUIHex getHexByName(java.lang.String hexName)

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

zoomIn

public void zoomIn()

zoomOut

public void zoomOut()

zoom

protected void zoom()

setScale

protected void setScale()

getZoomStep

public int getZoomStep()

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

selectHex

public void selectHex(GUIHex clickedHex)

getSelectedHex

public GUIHex getSelectedHex()

setSelectedHex

public void setSelectedHex(GUIHex hex)

isAHexSelected

public boolean isAHexSelected()

setAllowedTileLays

public void setAllowedTileLays(java.util.List<LayTile> allowedTileLays)

getTileAllowancesForHex

public java.util.List<LayTile> getTileAllowancesForHex(MapHex hex)

setAllowedTokenLays

public <T extends LayToken> void setAllowedTokenLays(java.util.List<T> allowedTokenLays)

getTokenAllowanceForHex

public java.util.List<LayToken> getTokenAllowanceForHex(MapHex hex)

getBaseTokenAllowanceForHex

public java.util.List<LayBaseToken> getBaseTokenAllowanceForHex(MapHex hex)

getBonusTokenAllowanceForHex

public java.util.List<LayBonusToken> getBonusTokenAllowanceForHex(MapHex hex)

setTrainPaths

public void setTrainPaths(java.util.List<java.awt.geom.GeneralPath> trainPaths)

getPhase

public PhaseI getPhase()
Off-board tiles must be able to retrieve the current phase.

Returns:
The current Phase object.

getMapManager

public MapManager getMapManager()

getOrUIManager

public ORUIManager getOrUIManager()

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent arg0)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent arg0)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent arg0)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent arg0)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent arg0)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent arg0)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent arg0)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

updateOffBoardToolTips

public void updateOffBoardToolTips()