Class Overview
This class can iterate individual span elements generated by scan
converting a Shape.
This particular implementation flattens the incoming path and then
performs simple polygon tracing to calculate the spans.
Note that this class holds pointers to native data which must be
disposed. It is not marked as finalizable since it is intended
to be very lightweight and finalization is a comparitively expensive
procedure. The caller must specifically use try{} finally{} to
manually ensure that the object is disposed after use, otherwise
native data structures might be leaked.
Here is a code sample for using this class:
public void fillShape(Shape s, Rectangle clipRect) {
ShapeSpanIterator ssi = new ShapeSpanIterator(false);
try {
ssi.setOutputArea(clipRect);
ssi.appendPath(s.getPathIterator(null));
int spanbox[] = new int[4];
while (ssi.nextSpan(spanbox)) {
int x = spanbox[0];
int y = spanbox[1];
int w = spanbox[2] - x;
int h = spanbox[3] - y;
fillRect(x, y, w, h);
}
} finally {
ssi.dispose();
}
}
Summary
Public Methods |
void
|
addSegment(int type, float[] coords)
|
void
|
appendPath(PathIterator pi)
|
void
|
appendPoly(int[] xPoints, int[] yPoints, int nPoints, int xoff, int yoff)
|
void
|
closePath()
|
void
|
curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
|
void
|
dispose()
|
long
|
getNativeConsumer()
If a given PathConsumer performs all or most of its work
natively then it can return a (non-zero) pointer to a
native function vector that defines C functions for all
of the above methods.
|
long
|
getNativeIterator()
This method returns a native pointer to a function block that
can be used by a native method to perform the same iteration
cycle that the above methods provide while avoiding upcalls to
the Java object.
|
void
|
getPathBox(int[] pathbox)
This method returns the bounding box of the spans that the
iterator will be returning.
|
static
void
|
initIDs()
|
void
|
intersectClipBox(int lox, int loy, int hix, int hiy)
This method constrains the spans returned by nextSpan() to the
rectangle whose bounds are given.
|
void
|
lineTo(float x, float y)
|
void
|
moveTo(float x, float y)
|
boolean
|
nextSpan(int[] spanbox)
This method returns the next span in the shape being iterated.
|
void
|
pathDone()
Called after the last segment of the last subpath when the
iteration of the path segments is completely done.
|
void
|
quadTo(float x1, float y1, float x2, float y2)
|
void
|
setOutputArea(Rectangle r)
|
void
|
setOutputArea(Region r)
|
void
|
setOutputAreaXYWH(int x, int y, int w, int h)
|
void
|
setOutputAreaXYXY(int lox, int loy, int hix, int hiy)
|
void
|
setRule(int rule)
|
void
|
skipDownTo(int y)
This method tells the iterator that it may skip all spans
whose Y range is completely above the indicated Y coordinate.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
From interface
sun.awt.geom.PathConsumer2D
abstract
void
|
closePath()
|
abstract
void
|
curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
|
abstract
long
|
getNativeConsumer()
If a given PathConsumer performs all or most of its work
natively then it can return a (non-zero) pointer to a
native function vector that defines C functions for all
of the above methods.
|
abstract
void
|
lineTo(float x, float y)
|
abstract
void
|
moveTo(float x, float y)
|
abstract
void
|
pathDone()
Called after the last segment of the last subpath when the
iteration of the path segments is completely done.
|
abstract
void
|
quadTo(float x1, float y1, float x2, float y2)
|
|
From interface
sun.java2d.pipe.SpanIterator
abstract
long
|
getNativeIterator()
This method returns a native pointer to a function block that
can be used by a native method to perform the same iteration
cycle that the above methods provide while avoiding upcalls to
the Java object.
|
abstract
void
|
getPathBox(int[] pathbox)
This method returns the bounding box of the spans that the
iterator will be returning.
|
abstract
void
|
intersectClipBox(int lox, int loy, int hix, int hiy)
This method constrains the spans returned by nextSpan() to the
rectangle whose bounds are given.
|
abstract
boolean
|
nextSpan(int[] spanbox)
This method returns the next span in the shape being iterated.
|
abstract
void
|
skipDownTo(int y)
This method tells the iterator that it may skip all spans
whose Y range is completely above the indicated Y coordinate.
|
|
Public Constructors
public
ShapeSpanIterator
(boolean adjust)
Public Methods
public
void
addSegment
(int type, float[] coords)
public
void
appendPoly
(int[] xPoints, int[] yPoints, int nPoints, int xoff, int yoff)
public
void
curveTo
(float x1, float y1, float x2, float y2, float x3, float y3)
public
long
getNativeConsumer
()
If a given PathConsumer performs all or most of its work
natively then it can return a (non-zero) pointer to a
native function vector that defines C functions for all
of the above methods.
The specific pointer it returns is a pointer to a
PathConsumerVec structure as defined in the include file
src/share/native/sun/java2d/pipe/PathConsumer2D.h
Returns
- a native pointer to a PathConsumerVec structure.
public
long
getNativeIterator
()
This method returns a native pointer to a function block that
can be used by a native method to perform the same iteration
cycle that the above methods provide while avoiding upcalls to
the Java object.
The definition of the structure whose pointer is returned by
this method is defined in:
src/share/native/sun/java2d/pipe/SpanIterator.h
public
void
getPathBox
(int[] pathbox)
This method returns the bounding box of the spans that the
iterator will be returning.
The array must be of length at least 4 and upon return, it
will be filled with the values:
{PathMinX, PathMinY, PathMaxX, PathMaxY}.
public
static
void
initIDs
()
public
void
intersectClipBox
(int lox, int loy, int hix, int hiy)
This method constrains the spans returned by nextSpan() to the
rectangle whose bounds are given.
public
void
lineTo
(float x, float y)
public
void
moveTo
(float x, float y)
public
boolean
nextSpan
(int[] spanbox)
This method returns the next span in the shape being iterated.
The array must be of length at least 4 and upon return, it
will be filled with the values:
{SpanMinX, SpanMinY, SpanMaxX, SpanMaxY}.
public
void
pathDone
()
Called after the last segment of the last subpath when the
iteration of the path segments is completely done. This
method serves to trigger the end of path processing in the
consumer that would normally be triggered when a
PathIterator
returns true
from its done
method.
public
void
quadTo
(float x1, float y1, float x2, float y2)
public
void
setOutputArea
(Region r)
public
void
setOutputAreaXYWH
(int x, int y, int w, int h)
public
void
setOutputAreaXYXY
(int lox, int loy, int hix, int hiy)
public
void
setRule
(int rule)
public
void
skipDownTo
(int y)
This method tells the iterator that it may skip all spans
whose Y range is completely above the indicated Y coordinate.