jaige.games.hex.gui
Class Hexagon

java.lang.Object
  extended by java.awt.Polygon
      extended by jaige.games.hex.gui.Hexagon
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable

public class Hexagon
extends java.awt.Polygon

A hexagon.

Author:
Antti Kerminen (original), Rob Taft (modifications)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Polygon
bounds, npoints, xpoints, ypoints
 
Constructor Summary
Hexagon()
           
Hexagon(int x, int y, double radius)
          Create a new hexagon.
Hexagon(java.awt.Point center, double radius)
          Create a new hexagon.
 
Method Summary
 java.awt.Point getCenter()
           
 int halfHeight()
          Get half of the height.
 int halfWidth()
          Get half of the width.
 int height()
          Get the height.
static double radiusForHeight(int height)
          Get the radius for a hexagon with the given height.
static double radiusForWidth(int width)
          Get the radius for a hexagon with the given width.
 void scale(double scale)
          Scale this hexagon.
 void setParameters(int x, int y, double radius)
           
 void setParameters(java.awt.Point center, double radius)
           
 int width()
          Get the width.
 
Methods inherited from class java.awt.Polygon
addPoint, contains, contains, contains, contains, contains, contains, getBoundingBox, getBounds, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, invalidate, reset, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hexagon

public Hexagon()

Hexagon

public Hexagon(int x,
               int y,
               double radius)
Create a new hexagon.

Parameters:
x - the x coordinate of the center point.
y - the y coordinate of the center point.
radius - the radius of the hexagon.

Hexagon

public Hexagon(java.awt.Point center,
               double radius)
Create a new hexagon.

Parameters:
center - the center point.
radius - the radius of the hexagon.
Method Detail

setParameters

public void setParameters(int x,
                          int y,
                          double radius)

setParameters

public void setParameters(java.awt.Point center,
                          double radius)

scale

public void scale(double scale)
Scale this hexagon.

Parameters:
scale - the scaling factor.

halfHeight

public int halfHeight()
Get half of the height.


height

public int height()
Get the height.


halfWidth

public int halfWidth()
Get half of the width.


width

public int width()
Get the width.


getCenter

public java.awt.Point getCenter()

radiusForWidth

public static double radiusForWidth(int width)
Get the radius for a hexagon with the given width.


radiusForHeight

public static double radiusForHeight(int height)
Get the radius for a hexagon with the given height.