hexIT
Class Hexagon

java.lang.Object
  extended byhexIT.Hexagon
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Hexagon
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A hexagon object represents a particular tile on a board of hexagons. The board type is independent of the implementation found here: hexagons have 6 sides no matter what arrangement they are placed in.

See Also:
Serialized Form

Field Summary
static int COORDNUM_BOTTOM
           
static int COORDNUM_BOTTOMLEFT
           
static int COORDNUM_BOTTOMRIGHT
           
static int COORDNUM_TOP
           
static int COORDNUM_TOPLEFT
           
static int COORDNUM_TOPRIGHT
           
 
Constructor Summary
Hexagon(int new_hexX, int new_hexY)
          Creates a hexagon with hexagonal coordinates (new_hexX, new_hexY).
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns true if the object that's passed-in is a Hexagon and has the same hexagonal coordinates as this Hexagon.
 java.awt.Color getBorderColor()
          Returns the current border color of this hexagon.
 java.awt.Color getFillColor()
          Gets the fill color of this hexagon.
 int getHexX()
          Get this hexagon's hexagonal X coordinate, where the coordinate system is defined by the board that created this hexagon.
 int getHexY()
          Get this hexagon's hexagonal Y coordinate, where the coordinate system is defined by the board that created this hexagon.
 int getMidPixelX()
          Get the x coordinate of the pixel at the center of this hexagon.
 int getMidPixelY()
          Get the y coordinate of the pixel at the center of this hexagon.
 Drawable getObj()
          Return the object on this hexagon, or null if there is none.
 java.awt.Color getOutlineColor()
          Gets the outline line color of this hexagon.
 int getPixelX(int coord_num)
          Get the x coordinate of the pixel attached to the coordinate number of the vertex of this hexagon.
 int getPixelY(int coord_num)
          Get the y coordinate of the pixel attached to the coordinate number of the vertex of this hexagon.
 boolean hasFill()
          Returns true if this hexagon has a fill color, false otherwise.
 boolean hasOutline()
          Returns true if this hexagon has an outline, false otherwise.
 boolean isOccupied()
          Returns true if there is an object on this hexagon, false otherwise.
 boolean isVisible()
          Returns true if this hexagon is visible, false otherwise.
 void putObj(Drawable newObj)
          Places the specified drawable object onto this hex.
 void removeFill()
          Removes the fill from this hexagon.
 void removeObj()
          Remove the object on this hexagon.
 void removeOutline()
          Remove the outline from this hexagon.
 void scaleObjImage(int new_width, int new_height)
          Scales the object on this hexagon to the specified new pixel values.
 void setBorderColor(java.awt.Color new_color)
          Set the border line color of this hexagon.
 void setVisible(boolean new_visible)
          Toggles the visibility of this hexagon.
 boolean surroundsPixel(int x, int y)
          Returns true if the specified pixel with coordinates (x,y) lie inside this hexagon.
 java.lang.String toString()
          Returns the coordinates string of this hexagon.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COORDNUM_TOP

public static final int COORDNUM_TOP
See Also:
Constant Field Values

COORDNUM_TOPRIGHT

public static final int COORDNUM_TOPRIGHT
See Also:
Constant Field Values

COORDNUM_BOTTOMRIGHT

public static final int COORDNUM_BOTTOMRIGHT
See Also:
Constant Field Values

COORDNUM_BOTTOM

public static final int COORDNUM_BOTTOM
See Also:
Constant Field Values

COORDNUM_BOTTOMLEFT

public static final int COORDNUM_BOTTOMLEFT
See Also:
Constant Field Values

COORDNUM_TOPLEFT

public static final int COORDNUM_TOPLEFT
See Also:
Constant Field Values
Constructor Detail

Hexagon

public Hexagon(int new_hexX,
               int new_hexY)
Creates a hexagon with hexagonal coordinates (new_hexX, new_hexY). Note that these coordinates are in the coordinate system defined by the board. Constructing a hexagon object does not place it on any board. These coordinates are merely convenient records store in the hexagon object.

Method Detail

getHexX

public int getHexX()
Get this hexagon's hexagonal X coordinate, where the coordinate system is defined by the board that created this hexagon.


getHexY

public int getHexY()
Get this hexagon's hexagonal Y coordinate, where the coordinate system is defined by the board that created this hexagon.


getPixelX

public int getPixelX(int coord_num)
Get the x coordinate of the pixel attached to the coordinate number of the vertex of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


getPixelY

public int getPixelY(int coord_num)
Get the y coordinate of the pixel attached to the coordinate number of the vertex of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


getMidPixelX

public int getMidPixelX()
Get the x coordinate of the pixel at the center of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


getMidPixelY

public int getMidPixelY()
Get the y coordinate of the pixel at the center of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


putObj

public void putObj(Drawable newObj)
Places the specified drawable object onto this hex. Only 1 object is currently allowed on a hexagon. If you call this function while another object is currently on this hexagon, the old object will be replaced.


getObj

public Drawable getObj()
Return the object on this hexagon, or null if there is none.


isOccupied

public boolean isOccupied()
Returns true if there is an object on this hexagon, false otherwise.


scaleObjImage

public void scaleObjImage(int new_width,
                          int new_height)
Scales the object on this hexagon to the specified new pixel values.


removeObj

public void removeObj()
Remove the object on this hexagon. If there is none, this method does nothing.


setBorderColor

public void setBorderColor(java.awt.Color new_color)
Set the border line color of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


getBorderColor

public java.awt.Color getBorderColor()
Returns the current border color of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


getOutlineColor

public java.awt.Color getOutlineColor()
Gets the outline line color of this hexagon. The outline color is a line that surrounds the interior edge of the hexagon, so it is not coincident with the border.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


hasOutline

public boolean hasOutline()
Returns true if this hexagon has an outline, false otherwise.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


removeOutline

public void removeOutline()
Remove the outline from this hexagon. If the hexagon does not currently have an outline, this method does nothing.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


surroundsPixel

public boolean surroundsPixel(int x,
                              int y)
Returns true if the specified pixel with coordinates (x,y) lie inside this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


getFillColor

public java.awt.Color getFillColor()
Gets the fill color of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


hasFill

public boolean hasFill()
Returns true if this hexagon has a fill color, false otherwise.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


removeFill

public void removeFill()
Removes the fill from this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


setVisible

public void setVisible(boolean new_visible)
Toggles the visibility of this hexagon.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


isVisible

public boolean isVisible()
Returns true if this hexagon is visible, false otherwise.

Note: this function will only does something meaningful if the hexagon in question is part of a board which is a part of a hex panel.


equals

public boolean equals(java.lang.Object o)
Returns true if the object that's passed-in is a Hexagon and has the same hexagonal coordinates as this Hexagon.


toString

public java.lang.String toString()
Returns the coordinates string of this hexagon.