codeblocks.rendering
Class BevelIterator

java.lang.Object
  extended by codeblocks.rendering.BevelIterator

public class BevelIterator
extends java.lang.Object

The BevelIterator class handles the geometry calculations involved in creating a bevel effect around the edge of a shape. Like a FlatteningPathIterator, it iterates over a set of line segments that follows the shape's boundary. For each segment it provides four points, of which the 2nd and 3rd are the endpoints of the current segment, and the 1st and 4th are the endpoints of the neighboring segments. From these four points relevant vectors for drawing a bevel are automatically calculated and provided.

Points and vectors are specified by (x,y) coordinates in an array.

See Also:
PathIterator

Field Summary
 float[] inset2
          a vector pointing inwards from pt2, bisecting the angle at that point, scaled to have a length appropriate for a bevel of thickness 1.0 (in other words, lying on the line that is parallel to the current segment and a distance of 1.0 inwards).
 float[] inset3
          a vector pointing inwards from pt3, bisecting the angle at that point, scaled to have a length appropriate for a bevel of thickness 1.0 (in other words, lying on the line that is parallel to the current segment and a distance of 1.0 inwards).
 float[] perpVec
          a unit vector perpendicular to the current segment, pointing outwards
 float[] pt1
          the point that comes before the current segment's start-point
 float[] pt2
          the start-point of the current segment
 float[] pt3
          the end-point of the current segment
 float[] pt4
          the point that comes after the current segment's end-point
 
Constructor Summary
BevelIterator(java.awt.Shape area, double flatness)
          Constructs a BevelIterator for a given shape.
 
Method Summary
 float[] insetPoint2(float scalar, float[] f)
          Scales the vector inset2 by the factor scalar and adds it to pt2.
 float[] insetPoint3(float scalar, float[] f)
          Scales the vector inset3 by the factor scalar and adds it to pt3.
 boolean isDone()
          Returns true if a call to nextSegment will move to a new segment.
 void nextSegment()
          Fills in this class's fields with information about the next segment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pt1

public float[] pt1
the point that comes before the current segment's start-point


pt2

public float[] pt2
the start-point of the current segment


pt3

public float[] pt3
the end-point of the current segment


pt4

public float[] pt4
the point that comes after the current segment's end-point


inset2

public float[] inset2
a vector pointing inwards from pt2, bisecting the angle at that point, scaled to have a length appropriate for a bevel of thickness 1.0 (in other words, lying on the line that is parallel to the current segment and a distance of 1.0 inwards).


inset3

public float[] inset3
a vector pointing inwards from pt3, bisecting the angle at that point, scaled to have a length appropriate for a bevel of thickness 1.0 (in other words, lying on the line that is parallel to the current segment and a distance of 1.0 inwards).


perpVec

public float[] perpVec
a unit vector perpendicular to the current segment, pointing outwards

Constructor Detail

BevelIterator

public BevelIterator(java.awt.Shape area,
                     double flatness)
Constructs a BevelIterator for a given shape. The shape should be simply-connected and have a boundary that does not intersect itself. The flatness parameter has the same meaning as in the constructor of FlatteningPathIterator. The fields of this class are undefined until nextSegment is first called.

Parameters:
area - the region whose boundary is to be beveled
flatness - the maximum allowable distance by which the segments can deviate from the actual boundary
Method Detail

nextSegment

public void nextSegment()
Fills in this class's fields with information about the next segment. Has no effect if all segments have been encountered.


isDone

public boolean isDone()
Returns true if a call to nextSegment will move to a new segment.

Returns:
whether all segments have been encountered

insetPoint2

public float[] insetPoint2(float scalar,
                           float[] f)
Scales the vector inset2 by the factor scalar and adds it to pt2. The returned point is pt2 inset by an amount appropriate for a bevel of thickness scalar.

Parameters:
scalar - amount to scale inset2 by
f - receives the new point
Returns:
the argument f

insetPoint3

public float[] insetPoint3(float scalar,
                           float[] f)
Scales the vector inset3 by the factor scalar and adds it to pt3. The returned point is pt3 inset by an amount appropriate for a bevel of thickness scalar.

Parameters:
scalar - amount to scale inset3 by
f - receives the new point
Returns:
the argument f