jtge.util.grid.builder
Class FlatHexagonBuilder

java.lang.Object
  extended byjtge.util.grid.builder.AbstractHexagonBuilder
      extended byjtge.util.grid.builder.FlatHexagonBuilder
All Implemented Interfaces:
IHexagonBuilder

public class FlatHexagonBuilder
extends AbstractHexagonBuilder

Utiliy class used to help drawing flat hexagons.

Version:
$Id: FlatHexagonBuilder.java,v 1.1 2005/09/09 18:24:28 mat007 Exp $
Author:
Jean-Laurent

Field Summary
 
Fields inherited from class jtge.util.grid.builder.AbstractHexagonBuilder
A, B, H, R, S, shifted
 
Constructor Summary
FlatHexagonBuilder(int hexagonSideLength, boolean shifted)
          Create a flat hexagon builder.
 
Method Summary
protected  Coordinate approximate(java.awt.Point point)
          Retrieve an approximated coordinate from a given point.
 java.awt.Polygon buildHexagon(Coordinate coordinate)
          Build an hexagon within a map.
 int computeHeight(int height)
          Compute the height in pixels of a map consisting of given number of tiles height.
 int computeWidth(int width)
          Compute the width in pixels of a map consisting of given number of tiles width.
 
Methods inherited from class jtge.util.grid.builder.AbstractHexagonBuilder
buildHexagon, floor, floor, fromPixel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlatHexagonBuilder

public FlatHexagonBuilder(int hexagonSideLength,
                          boolean shifted)
Create a flat hexagon builder.

Parameters:
hexagonSideLength - the length of an hexagon side in pixels
shifted - whether to shift the top left hexagon or not
Method Detail

computeWidth

public final int computeWidth(int width)
Compute the width in pixels of a map consisting of given number of tiles width.

Parameters:
width - a number of tiles
Returns:
the width in pixels

computeHeight

public final int computeHeight(int height)
Compute the height in pixels of a map consisting of given number of tiles height.

Parameters:
height - a number of tiles
Returns:
the height in pixels

buildHexagon

public final java.awt.Polygon buildHexagon(Coordinate coordinate)
Build an hexagon within a map.

Parameters:
coordinate - position of the hexagon
Returns:
the polygon

approximate

protected final Coordinate approximate(java.awt.Point point)
Retrieve an approximated coordinate from a given point.

Specified by:
approximate in class AbstractHexagonBuilder
Parameters:
point - the point
Returns:
an approximated coordinate


Copyright © 2003-2005 . All Rights Reserved.