jtge.util.grid.builder
Class AbstractHexagonBuilder

java.lang.Object
  extended byjtge.util.grid.builder.AbstractHexagonBuilder
All Implemented Interfaces:
IHexagonBuilder
Direct Known Subclasses:
FlatHexagonBuilder, PeakHexagonBuilder

public abstract class AbstractHexagonBuilder
extends java.lang.Object
implements IHexagonBuilder

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

Field Summary
protected  double A
           | A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _
protected  double B
           | A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _
protected  double H
           | A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _
protected  double R
           | A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _
protected  double S
           | A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _
protected  boolean shifted
          Whether the map is shifted or not.
 
Constructor Summary
AbstractHexagonBuilder(int hexagonSideLength, boolean shifted)
          Create an abstract hexagon builder.
 
Method Summary
protected abstract  Coordinate approximate(java.awt.Point point)
          Retrieve an approximated coordinate from a given point.
 java.awt.Polygon buildHexagon()
          Build a single hexagon.
protected  int floor(double value)
          Floor a number.
protected  int[] floor(double[] array)
          Floor an array of numbers.
 Coordinate fromPixel(java.awt.Point point, IGrid grid)
          Picks the coordinate at a given screen coordinate in a grid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jtge.util.grid.builder.IHexagonBuilder
buildHexagon, computeHeight, computeWidth
 

Field Detail

S

protected final double S
| A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _


R

protected final double R
| A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _


H

protected final double H
| A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _


A

protected final double A
| A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _


B

protected final double B
| A | |R| _ _ /\ H / \ _ | | S B | | _ \ / \/ _ | B | |H||S| ___ _ _ / \ R / \ _ A \ / \___/ _


shifted

protected final boolean shifted
Whether the map is shifted or not.

Constructor Detail

AbstractHexagonBuilder

public AbstractHexagonBuilder(int hexagonSideLength,
                              boolean shifted)
Create an abstract hexagon builder.

Parameters:
hexagonSideLength - the length of the side of an hexagon in pixels
shifted - whether to shift the first hexagon (therefore the whole map) or not
Method Detail

buildHexagon

public final java.awt.Polygon buildHexagon()
Build a single hexagon.

Specified by:
buildHexagon in interface IHexagonBuilder
Returns:
the polygon

fromPixel

public final Coordinate fromPixel(java.awt.Point point,
                                  IGrid grid)
Picks the coordinate at a given screen coordinate in a grid.

Specified by:
fromPixel in interface IHexagonBuilder
Parameters:
point - the screen coordinate in pixels
grid - the grid to look into
Returns:
the corresponding coordinate or null if outside the grid

approximate

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

Parameters:
point - the point
Returns:
an approximated coordinate

floor

protected final int[] floor(double[] array)
Floor an array of numbers.

Parameters:
array - the array to floor
Returns:
an integer array

floor

protected final int floor(double value)
Floor a number.

Parameters:
value - the double value to floor.
Returns:
floor value


Copyright © 2003-2005 . All Rights Reserved.