public final class

ShapeSpanIterator

extends Object
implements PathConsumer2D SpanIterator
java.lang.Object
   ↳ sun.java2d.pipe.ShapeSpanIterator

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 Constructors
ShapeSpanIterator(boolean adjust)
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
From interface sun.awt.geom.PathConsumer2D
From interface sun.java2d.pipe.SpanIterator

Public Constructors

public ShapeSpanIterator (boolean adjust)

Public Methods

public void addSegment (int type, float[] coords)

public void appendPath (PathIterator pi)

public void appendPoly (int[] xPoints, int[] yPoints, int nPoints, int xoff, int yoff)

public void closePath ()

public void curveTo (float x1, float y1, float x2, float y2, float x3, float y3)

public void dispose ()

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 (Rectangle r)

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.