org.vizzini.ui.graphics.shape
Class ExtrudedShape

java.lang.Object
  extended by org.vizzini.ui.graphics.shape.AbstractShape
      extended by org.vizzini.ui.graphics.shape.ExtrudedShape
All Implemented Interfaces:
Comparable, IStateful, IShape
Direct Known Subclasses:
BoxExtruded, Cone, Cylinder, Ellipsoid, PieceShape

public abstract class ExtrudedShape
extends AbstractShape

Provides a shape model for an extruded shape. An extruded shape has a spine with multiple stations. Each station can have a symetric cross-section and orientation. Subclasses should call initPoints() in their constructors.

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

Field Summary
protected  boolean _beginCap
          Flag indicating whether to use a begin cap.
protected  boolean _endCap
          Flag indicating whether to use an end cap.
protected  boolean _isHighlighted
          Flag indicating whether to highlight.
protected  ShapeGroup _polygons
          Shape group of generated polygons.
protected  int _spineLength
          The length of the spine.
 
Fields inherited from class org.vizzini.ui.graphics.shape.AbstractShape
_isWireframe, _points, _screenCenter, _screenPoints, _shapeGroup, _zNormal
 
Constructor Summary
ExtrudedShape(double width, double height, double depth)
          Construct this object with the given parameters.
 
Method Summary
protected  void computePolygonShapes()
          Compute the polygons from the screen points.
 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  void initPoints(double width, double height, double depth, Vector[] spine, double[] crossSection, double[] scale, double[] orientation)
          Calculate the points from the given description of an extruded object.
protected  PolygonShape processPolygonShape(Color color, List vector)
          Process a polygon using the given parameters.
protected  void releasePolygonShapes()
          Release all the polygon shapes.
 void setBeginCap(boolean flag)
          Set the begin cap flag.
 void setEndCap(boolean flag)
          Set the end cap flag.
 void setHighlightColor(Color color)
          Set the highlight color.
 void setHighlighted(boolean isHighlighted)
          Set the flag indicating whether highlights are used.
 
Methods inherited from class org.vizzini.ui.graphics.shape.AbstractShape
add, clear, compareTo, 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, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_beginCap

protected boolean _beginCap
Flag indicating whether to use a begin cap.


_endCap

protected boolean _endCap
Flag indicating whether to use an end cap.


_isHighlighted

protected boolean _isHighlighted
Flag indicating whether to highlight.


_polygons

protected ShapeGroup _polygons
Shape group of generated polygons.


_spineLength

protected int _spineLength
The length of the spine.

Constructor Detail

ExtrudedShape

public ExtrudedShape(double width,
                     double height,
                     double depth)
Construct this object with the given parameters.

Parameters:
width - Width.
height - Height.
depth - Depth.
Method Detail

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.

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. Override the super method to draw the polygons first.

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

setBeginCap

public void setBeginCap(boolean flag)
Set the begin cap flag.

Parameters:
flag - The new flag.
Since:
v0.2

setEndCap

public void setEndCap(boolean flag)
Set the end cap flag.

Parameters:
flag - The new flag.
Since:
v0.2

setHighlightColor

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

Since:
v0.2

setHighlighted

public void setHighlighted(boolean isHighlighted)
Set the flag indicating whether highlights are used.

Since:
v0.2

computePolygonShapes

protected void computePolygonShapes()
Compute the polygons from the screen points.

Since:
v0.2

initPoints

protected void initPoints(double width,
                          double height,
                          double depth,
                          Vector[] spine,
                          double[] crossSection,
                          double[] scale,
                          double[] orientation)
Calculate the points from the given description of an extruded object.

Parameters:
width - The width.
height - The height.
depth - The depth.
spine - Array describing the spine, typically in Y.
crossSection - Array describing the cross section in X-Z.
scale - Array describing the scaling factors in X-Z at stations of the spine.
orientation - Array describing the orientation of the cross section at stations of the spine.
Since:
v0.2

processPolygonShape

protected PolygonShape processPolygonShape(Color color,
                                           List vector)
Process a polygon using the given parameters.

Parameters:
color - The polygon color.
vector - Vector of screen points.
Since:
v0.2

releasePolygonShapes

protected void releasePolygonShapes()
Release all the polygon shapes.

Since:
v0.2


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