org.vizzini.ui.graphics.shape
Class PolygonShape

java.lang.Object
  extended by org.vizzini.ui.graphics.shape.AbstractShape
      extended by org.vizzini.ui.graphics.shape.PolygonShape
All Implemented Interfaces:
Comparable, IStateful, IShape

public final class PolygonShape
extends AbstractShape

Provides a polygon shape for the 3D graphics system. For this object the points and screenPoints are interchangeable.

Since:
v0.2
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
 
Fields inherited from class org.vizzini.ui.graphics.shape.AbstractShape
_isWireframe, _points, _screenCenter, _screenPoints, _shapeGroup, _zNormal
 
Constructor Summary
PolygonShape()
          Construct this object.
PolygonShape(Color color, List points)
          Construct this object with the given parameters.
PolygonShape(Color color, List points, boolean isWireframe)
          Construct this object with the given parameters.
 
Method Summary
 int compareTo(Object object)
          Compare this shape to the given object.
 void computeScreenPoints(Quaternion q, Vector v, double magnify, int offsetX, int offsetY, double d)
          Compute the points of this shape in screen coordinates.
 boolean contains(Point point)
          Return true if the given point is within this shape.
 void drawOn(Graphics g, double magnify)
          Draw this shape on the given graphics with the given magnification.
protected  double getScreenZ()
          Compute the Z coordinate in screen coordinates.
 void initPoints(List points)
          Initialize this polygon with the given points.
 void setHighlightColor(Color color)
          Set the highlight color.
 void setHighlightSegment(int node1, int node2)
          Set a segment for highlighting.
 Polygon toPolygon()
          Return a java.awt.Polygon instance of this.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class org.vizzini.ui.graphics.shape.AbstractShape
add, clear, computeCenteredScreenPoints, computeNormalZComponent, computeScreenCenter, createState, createStatefulSupport, drawOn, drawOnSolid, drawOnWireframe, getAbsoluteState, getBounds, getChildren, getColor, getColorForIntensity, getDepth, getDimensions, getHeight, getMinDimension, getName, getScreenCenter, getShapeGroup, getState, getStatefulParent, getTextureFilepath, getWidth, isInFrontOf, isLightSource, isTextureFilepathSet, isVisible, isWireframe, remove, setColor, setLightSource, setName, setStatefulParent, setTextureFilepath, setVisible, setWireframe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PolygonShape

public PolygonShape()
Construct this object.

Since:
v0.2

PolygonShape

public PolygonShape(Color color,
                    List points)
Construct this object with the given parameters.

Since:
v0.2

PolygonShape

public PolygonShape(Color color,
                    List points,
                    boolean isWireframe)
Construct this object with the given parameters.

Since:
v0.2
Method Detail

compareTo

public int compareTo(Object object)
Compare this shape to the given object.

Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class AbstractShape
Since:
v0.2

computeScreenPoints

public void computeScreenPoints(Quaternion q,
                                Vector v,
                                double magnify,
                                int offsetX,
                                int offsetY,
                                double d)
Compute the points of this shape in screen coordinates. Override the super method since this object's points are already in screen coordinates.

Specified by:
computeScreenPoints in interface IShape
Overrides:
computeScreenPoints in class AbstractShape
Parameters:
q - The parent quaternion.
magnify - The magnification.
offsetX - The offset X coordinate.
offsetY - The offset Y coordinate.
d - Perspective constant.
v - The parent position in world coordinates..
Since:
v0.2

contains

public boolean contains(Point point)
Return true if the given point is within this shape.

Specified by:
contains in interface IShape
Overrides:
contains in class AbstractShape
Since:
v0.2

drawOn

public void drawOn(Graphics g,
                   double magnify)
Draw this shape on the given graphics with the given magnification.

Specified by:
drawOn in interface IShape
Overrides:
drawOn in class AbstractShape
Parameters:
g - The graphics.
magnify - The magnification.
Since:
v0.2

initPoints

public void initPoints(List points)
Initialize this polygon with the given points.

Since:
v0.2

setHighlightColor

public void setHighlightColor(Color color)
Set the highlight color.

Since:
v0.2

setHighlightSegment

public void setHighlightSegment(int node1,
                                int node2)
Set a segment for highlighting.

Parameters:
node1 - The index of the start point.
node2 - The index of the end point.
Since:
v0.2

toPolygon

public Polygon toPolygon()
Return a java.awt.Polygon instance of this.

Since:
v0.2

toString

public String toString()
Return a string representation of this object.

Specified by:
toString in interface IShape
Overrides:
toString in class AbstractShape
Since:
v0.2

getScreenZ

protected double getScreenZ()
Compute the Z coordinate in screen coordinates.

Since:
v0.2


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02