org.vizzini.ui.game.boardgame
Class BoardShape

java.lang.Object
  extended by org.vizzini.ui.graphics.shape.AbstractShape
      extended by org.vizzini.ui.game.boardgame.BoardShape
All Implemented Interfaces:
Comparable, IStateful, IShape

public class BoardShape
extends AbstractShape

Provides a board for 3D games.

Since:
v0.2
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
protected  ITokenUI[][] _grid
          Collection of token UIs.
protected  int[] _polyX
          Array used by paintSquares() method.
protected  int[] _polyY
          Array used by paintSquares() method.
static double HEIGHT
          The height in centimeters from Star Fleet Technical Manual.
static double SQUARE_SIZE
          Square size in centimeters from Star Fleet Technical Manual.
 
Fields inherited from class org.vizzini.ui.graphics.shape.AbstractShape
_isWireframe, _points, _screenCenter, _screenPoints, _shapeGroup, _zNormal
 
Constructor Summary
BoardShape(int fileCount, int rankCount, int levelOffset)
          Construct this object with the given parameters.
BoardShape(int fileCount, int rankCount, int fileOffset, int rankOffset, int levelOffset)
          Construct this object with the given parameters.
 
Method Summary
 void add(HighlightData highlightData)
          Add the given highlight data.
 void add(ITokenUI shape)
          Add the given shape as a child of this.
 void clearHighlights()
          Clear the highlighted positions.
protected  void computeCenters()
          Compute the centers of the squares so we'll know where to place pieces.
 void computeScreenPoints(Quaternion q, Vector v, double magnify, int offsetX, int offsetY, double d)
          Compute the points of this shape in screen coordinates.
protected  void drawOn(Graphics g, double magnify, boolean wireframe)
          Draw this shape on the given graphics using the given parameters.
protected  Vector[][] getCenters()
          Return the offset.
 HighlightData getCurrentHighlightData()
           
 int getFileOffset()
          Return the file offset.
 Color getLabelColor()
          Return the label color.
 int getLevelOffset()
          Return the level offset.
protected  int[] getOffset()
          Return the offset.
 IntegerPosition getPositionForPoint(Point point)
          Map the screen coordinates to a board position.
 int getRankOffset()
          Return the rank offset.
 ITokenUI getTokenAt(int file, int rank)
          Return the token UI at the given position.
 boolean isLabelPainted()
          Return true if the label painted flag is true.
protected  void paintHighlight(Graphics2D g, HighlightData data)
          Paint the given square highlight.
protected  void paintHighlights(Graphics2D g)
          Paint the square highlights.
protected  void paintLabels(Graphics2D g)
          Paint the labels.
protected  void paintSquares(Graphics2D g)
          Paint the squares.
 void remove(HighlightData highlightData)
          Add the given highlight data.
 void remove(IShape shape)
          Remove the given shape as a child of this.
 void setCurrentHighlightData(HighlightData highlightData)
          Set the current highlight data.
 void setFirstColor(Color color)
          Set the first color, the color of the square at (0,0).
 void setLabelColor(Color color)
          Set the label color.
 void setLabelPainted(boolean isLabelPainted)
          Set the label painted flag.
 void setOffsets(int fileOffset, int rankOffset, int levelOffset)
          Set the offsets.
 void setSecondColor(Color color)
          Set the second color, the color not at (0,0).
 
Methods inherited from class org.vizzini.ui.graphics.shape.AbstractShape
add, clear, compareTo, computeCenteredScreenPoints, computeNormalZComponent, computeScreenCenter, contains, createState, createStatefulSupport, drawOn, drawOnSolid, drawOnWireframe, getAbsoluteState, getBounds, getChildren, getColor, getColorForIntensity, getDepth, getDimensions, getHeight, getMinDimension, getName, getScreenCenter, getShapeGroup, getState, getStatefulParent, getTextureFilepath, getWidth, isInFrontOf, isLightSource, isTextureFilepathSet, isVisible, isWireframe, setColor, setLightSource, setName, setStatefulParent, setTextureFilepath, setVisible, setWireframe, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEIGHT

public static final double HEIGHT
The height in centimeters from Star Fleet Technical Manual.

See Also:
Constant Field Values

SQUARE_SIZE

public static final double SQUARE_SIZE
Square size in centimeters from Star Fleet Technical Manual.

See Also:
Constant Field Values

_grid

protected ITokenUI[][] _grid
Collection of token UIs.


_polyX

protected int[] _polyX
Array used by paintSquares() method.


_polyY

protected int[] _polyY
Array used by paintSquares() method.

Constructor Detail

BoardShape

public BoardShape(int fileCount,
                  int rankCount,
                  int levelOffset)
Construct this object with the given parameters.

Parameters:
fileCount - The number of files.
rankCount - The number of ranks.
levelOffset - The offset of this board from level=0.
Since:
v0.2

BoardShape

public BoardShape(int fileCount,
                  int rankCount,
                  int fileOffset,
                  int rankOffset,
                  int levelOffset)
Construct this object with the given parameters.

Parameters:
fileCount - The number of files.
rankCount - The number of ranks.
fileOffset - The offset of this board from file=0.
rankOffset - The offset of this board from rank=0.
levelOffset - The offset of this board from level=0.
Since:
v0.2
Method Detail

add

public void add(ITokenUI shape)
Add the given shape as a child of this. Override the super method to convert the piece's input center into board coordinates.

Parameters:
shape - The new child shape.
Since:
v0.2

add

public void add(HighlightData highlightData)
Add the given highlight data.

Since:
v0.2

clearHighlights

public void clearHighlights()
Clear the highlighted positions.

Since:
v0.2

computeScreenPoints

public void computeScreenPoints(Quaternion q,
                                Vector v,
                                double magnify,
                                int offsetX,
                                int offsetY,
                                double d)
Compute the points of this shape in screen coordinates. Extends the super method to compute the screen corners in order to paint the squares.

Specified by:
computeScreenPoints in interface IShape
Overrides:
computeScreenPoints in class AbstractShape
Parameters:
q - Rotation of the parent to world coordinates.
v - The parent position in world coordinates..
magnify - The magnification.
offsetX - The offset X coordinate.
offsetY - The offset Y coordinate.
d - Perspective constant.
Since:
v0.2

getCurrentHighlightData

public HighlightData getCurrentHighlightData()
Returns:
Return currentHighlightData.
Since:
v0.3

getFileOffset

public int getFileOffset()
Return the file offset.

Since:
v0.2

getLabelColor

public Color getLabelColor()
Return the label color.

Since:
v0.2

getLevelOffset

public int getLevelOffset()
Return the level offset.

Since:
v0.2

getPositionForPoint

public IntegerPosition getPositionForPoint(Point point)
Map the screen coordinates to a board position.

Parameters:
point - A mouse click point.
Since:
v0.2

getRankOffset

public int getRankOffset()
Return the rank offset.

Since:
v0.2

getTokenAt

public ITokenUI getTokenAt(int file,
                           int rank)
Return the token UI at the given position.

Since:
v0.2

isLabelPainted

public boolean isLabelPainted()
Return true if the label painted flag is true.

Since:
v0.2

remove

public void remove(HighlightData highlightData)
Add the given highlight data.

Since:
v0.3

remove

public void remove(IShape shape)
Remove the given shape as a child of this. Override the super method to convert the piece's input center into board coordinates.

Specified by:
remove in interface IShape
Overrides:
remove in class AbstractShape
Parameters:
shape - The new child shape.
Since:
v0.2

setCurrentHighlightData

public void setCurrentHighlightData(HighlightData highlightData)
Set the current highlight data.

Since:
v0.3

setFirstColor

public void setFirstColor(Color color)
Set the first color, the color of the square at (0,0).

Since:
v0.2

setLabelColor

public void setLabelColor(Color color)
Set the label color.

Since:
v0.2

setLabelPainted

public void setLabelPainted(boolean isLabelPainted)
Set the label painted flag.

Since:
v0.2

setOffsets

public void setOffsets(int fileOffset,
                       int rankOffset,
                       int levelOffset)
Set the offsets.

Since:
v0.2

setSecondColor

public void setSecondColor(Color color)
Set the second color, the color not at (0,0).

Since:
v0.2

computeCenters

protected void computeCenters()
Compute the centers of the squares so we'll know where to place pieces.

Since:
v0.2

drawOn

protected void drawOn(Graphics g,
                      double magnify,
                      boolean wireframe)
Draw this shape on the given graphics using the given parameters.

Overrides:
drawOn in class AbstractShape
Parameters:
g - The graphics on which to draw.
magnify - The magnification.
wireframe - If true, draw this as a wireframe shape. This parameter is not used by this class.
Since:
v0.2

getCenters

protected Vector[][] getCenters()
Return the offset.

Since:
v0.2

getOffset

protected int[] getOffset()
Return the offset.

Since:
v0.2

paintHighlight

protected void paintHighlight(Graphics2D g,
                              HighlightData data)
Paint the given square highlight.

Parameters:
g - The graphics on which to draw.
Since:
v0.3

paintHighlights

protected void paintHighlights(Graphics2D g)
Paint the square highlights.

Parameters:
g - The graphics on which to draw.
Since:
v0.2

paintLabels

protected void paintLabels(Graphics2D g)
Paint the labels.

Parameters:
g - The graphics on which to draw.
Since:
v0.2

paintSquares

protected void paintSquares(Graphics2D g)
Paint the squares.

Parameters:
g - The graphics on which to draw.
Since:
v0.2


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02