com.jfimagine.jfgraph.geom
Class Hexagon

java.lang.Object
  |
  +--com.jfimagine.jfgraph.geom.Rect
        |
        +--com.jfimagine.jfgraph.geom.Hexagon
All Implemented Interfaces:
java.lang.Cloneable

public class Hexagon
extends Rect

Hexagon class. A class used to represent a hexagon in the plane with double coordinates.

Attention: Here we used a clockwise quadrant system. And the first quadrant is under right bottom corner.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
static int HEXAGONSIDE_BOTTOM
          A const vertext type represents the bottom side of an hexagon
static int HEXAGONSIDE_LEFTBOTTOM
          A const vertext type represents the left bottom inclined side of an hexagon
static int HEXAGONSIDE_LEFTTOP
          A const vertext type represents the left top inclined side of an hexagon
static int HEXAGONSIDE_RIGHTBOTTOM
          A const vertext type represents the right bottom inclined side of an hexagon
static int HEXAGONSIDE_RIGHTTOP
          A const vertext type represents the right top inclined side of an hexagon
static int HEXAGONSIDE_TOP
          A const vertext type represents the top side of an hexagon
static int HEXAGONVERTEX_LEFTBOTTOM
          A const vertext type represents the left bottom vertex of an hexagon
static int HEXAGONVERTEX_LEFTMIDDLE
          A const vertext type represents the left middle vertex of an hexagon
static int HEXAGONVERTEX_LEFTTOP
          A const vertext type represents the left top vertex of an hexagon
static int HEXAGONVERTEX_RIGHTBOTTOM
          A const vertext type represents the right bottom vertex of an hexagon
static int HEXAGONVERTEX_RIGHTMIDDLE
          A const vertext type represents the right middle vertex of an hexagon
static int HEXAGONVERTEX_RIGHTTOP
          A const vertext type represents the right top vertex of an hexagon
 
Fields inherited from class com.jfimagine.jfgraph.geom.Rect
m_leftBottom, m_leftTop, m_rightBottom, m_rightTop, SIDETYPE_BOTTOM, SIDETYPE_LEFT, SIDETYPE_RIGHT, SIDETYPE_TOP, VERTEXMOVETYPE_ISOSCELESTRAPEZOID, VERTEXMOVETYPE_PARALLEL, VERTEXMOVETYPE_RECTANGLE, VERTEXMOVETYPE_SCALE, VERTEXMOVETYPE_TRAPEZOID, VERTEXTYPE_LEFTBOTTOM, VERTEXTYPE_LEFTTOP, VERTEXTYPE_RIGHTBOTTOM, VERTEXTYPE_RIGHTTOP
 
Constructor Summary
Hexagon()
          Constructor for Hexagon.
Hexagon(Hexagon hexagon)
          Constructor for Hexagon.
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this object.
 boolean contains(double x, double y)
          Test if a point(x, y coordinates for instead) is within this hexagon.
 LineSeg getHexagonSide(int sideType)
          Get a side line of this hexagon.
 JFPoint getHexagonVertex(int vertexType)
          Get a vertex of this hexagon.
 boolean intersects(double x1, double y1, double x2, double y2)
          Tests if the specified line segment intersects the interior of this Hexagon.
 boolean intersects(double x1, double y1, int pickOffset)
          Tests if the specified point intersects any side of this hexagon.
 boolean intersects(LineSeg line)
          Tests if the specified line segment intersects the interior of this Hexagon.
 boolean intersects(Rect rect)
          Tests if the specified rectangle intersects the interior of this Hexagon.
 LineSeg pickLine(double x, double y, double pickOffset)
          Pick a line segment of this triangle by a point with a pickoffset.
 
Methods inherited from class com.jfimagine.jfgraph.geom.Rect
canAddPort, contains, equals, flipBy, flipBy, getBounds, getCenter, getHeight, getSide, getVertex, getWidth, getX, getY, hashCode, intersects, mirrorBy, mirrorBy, moveBy, moveVertex, newScaleCenter, rotateBy, rotateBy, rotateBy, scaleBy, scaleBy, setValue, setValue, setVertex, setVertex, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HEXAGONVERTEX_LEFTTOP

public static final int HEXAGONVERTEX_LEFTTOP
A const vertext type represents the left top vertex of an hexagon

See Also:
Constant Field Values

HEXAGONVERTEX_LEFTMIDDLE

public static final int HEXAGONVERTEX_LEFTMIDDLE
A const vertext type represents the left middle vertex of an hexagon

See Also:
Constant Field Values

HEXAGONVERTEX_LEFTBOTTOM

public static final int HEXAGONVERTEX_LEFTBOTTOM
A const vertext type represents the left bottom vertex of an hexagon

See Also:
Constant Field Values

HEXAGONVERTEX_RIGHTTOP

public static final int HEXAGONVERTEX_RIGHTTOP
A const vertext type represents the right top vertex of an hexagon

See Also:
Constant Field Values

HEXAGONVERTEX_RIGHTMIDDLE

public static final int HEXAGONVERTEX_RIGHTMIDDLE
A const vertext type represents the right middle vertex of an hexagon

See Also:
Constant Field Values

HEXAGONVERTEX_RIGHTBOTTOM

public static final int HEXAGONVERTEX_RIGHTBOTTOM
A const vertext type represents the right bottom vertex of an hexagon

See Also:
Constant Field Values

HEXAGONSIDE_LEFTTOP

public static final int HEXAGONSIDE_LEFTTOP
A const vertext type represents the left top inclined side of an hexagon

See Also:
Constant Field Values

HEXAGONSIDE_TOP

public static final int HEXAGONSIDE_TOP
A const vertext type represents the top side of an hexagon

See Also:
Constant Field Values

HEXAGONSIDE_RIGHTTOP

public static final int HEXAGONSIDE_RIGHTTOP
A const vertext type represents the right top inclined side of an hexagon

See Also:
Constant Field Values

HEXAGONSIDE_RIGHTBOTTOM

public static final int HEXAGONSIDE_RIGHTBOTTOM
A const vertext type represents the right bottom inclined side of an hexagon

See Also:
Constant Field Values

HEXAGONSIDE_BOTTOM

public static final int HEXAGONSIDE_BOTTOM
A const vertext type represents the bottom side of an hexagon

See Also:
Constant Field Values

HEXAGONSIDE_LEFTBOTTOM

public static final int HEXAGONSIDE_LEFTBOTTOM
A const vertext type represents the left bottom inclined side of an hexagon

See Also:
Constant Field Values
Constructor Detail

Hexagon

public Hexagon()
Constructor for Hexagon.


Hexagon

public Hexagon(Hexagon hexagon)
Constructor for Hexagon.

Parameters:
hexagon - A hexagon object.
Method Detail

getHexagonVertex

public JFPoint getHexagonVertex(int vertexType)
Get a vertex of this hexagon.

Parameters:
vertexType - A hexagon vertex type.
Returns:
A hexagon vertex.

getHexagonSide

public LineSeg getHexagonSide(int sideType)
Get a side line of this hexagon.

Parameters:
sideType - A side type of this hexagon.
Returns:
A side line.

contains

public boolean contains(double x,
                        double y)
Test if a point(x, y coordinates for instead) is within this hexagon.

Overrides:
contains in class Rect
Parameters:
x - X coordinate of this point.
y - Y coordinate of this point.
Returns:
True if the point is inside this rectangle, false otherwise.

intersects

public boolean intersects(double x1,
                          double y1,
                          int pickOffset)
Tests if the specified point intersects any side of this hexagon.

Overrides:
intersects in class Rect
Parameters:
pickOffset - An analog offset for 'pick' this line.
Returns:
true if the specified point intersects one side of this rectangle. false otherwise.

pickLine

public LineSeg pickLine(double x,
                        double y,
                        double pickOffset)
Pick a line segment of this triangle by a point with a pickoffset.

Overrides:
pickLine in class Rect
Parameters:
x - X coordinate of this point.
y - Y coordinate of this point.
pickOffset - An analog pick offset that great equal than 0.
Returns:
A line segment picked.

intersects

public boolean intersects(double x1,
                          double y1,
                          double x2,
                          double y2)
Tests if the specified line segment intersects the interior of this Hexagon.

Overrides:
intersects in class Rect
Returns:
true if the specified line segment intersects the interior of this Hexagon; false otherwise.

intersects

public boolean intersects(LineSeg line)
Tests if the specified line segment intersects the interior of this Hexagon.

Overrides:
intersects in class Rect
Parameters:
line - the specified LineSeg to test for intersection with the interior of this Hexagon
Returns:
true if the specified LineSeg intersects the interior of this Hexagon; false otherwise.
Since:
1.2

intersects

public boolean intersects(Rect rect)
Tests if the specified rectangle intersects the interior of this Hexagon.

Overrides:
intersects in class Rect
Parameters:
rect - the specified Hexagon to test for intersection with the interior of this Hexagon
Returns:
true if the specified Hexagon intersects the interior of this Hexagon; false otherwise.
Since:
1.2

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a new object of the same class and with the same contents as this object.

Overrides:
clone in class Rect
Returns:
A clone of this instance.
java.lang.CloneNotSupportedException


Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.