APIdia Launch Partner
Top Description Fields Constructors Methods
sun.java2d.pipe

public final Class ShapeSpanIterator

extends Object
implements SpanIterator, PathConsumer2D
Class Inheritance
All Implemented Interfaces
sun.awt.geom.PathConsumer2D, sun.java2d.pipe.SpanIterator
Imports
java.awt.geom.PathIterator, java.awt.Rectangle, sun.awt.geom.PathConsumer2D

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 comparatively 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(); } }

Field Summary

Modifier and TypeField and Description
pack-priv long

Constructor Summary

AccessConstructor and Description
public
ShapeSpanIterator(boolean adjust)

Method Summary

Modifier and TypeMethod and Description
public native void
addSegment(int type, float[] coords)

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

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

Implements sun.awt.geom.PathConsumer2D.curveTo.

public native void
public native long
getNativeConsumer()

Implements sun.awt.geom.PathConsumer2D.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.

public native long
getNativeIterator()

Implements sun.java2d.pipe.SpanIterator.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.

public native void
getPathBox(int[] pathbox)

Implements sun.java2d.pipe.SpanIterator.getPathBox.

This method returns the bounding box of the spans that the iterator will be returning.

public static native void
public native void
intersectClipBox(int lox, int loy, int hix, int hiy)

Implements sun.java2d.pipe.SpanIterator.intersectClipBox.

This method constrains the spans returned by nextSpan() to the rectangle whose bounds are given.

public native void
lineTo(float x, float y)

Implements sun.awt.geom.PathConsumer2D.lineTo.

public native void
moveTo(float x, float y)

Implements sun.awt.geom.PathConsumer2D.moveTo.

public native boolean
nextSpan(int[] spanbox)

Implements sun.java2d.pipe.SpanIterator.nextSpan.

This method returns the next span in the shape being iterated.

public native void
pathDone()

Implements sun.awt.geom.PathConsumer2D.pathDone.

Called after the last segment of the last subpath when the iteration of the path segments is completely done.

public native void
quadTo(float x1, float y1, float x2, float y2)

Implements sun.awt.geom.PathConsumer2D.quadTo.

private native void
setNormalize(boolean adjust)

public void
public void
public void
setOutputAreaXYWH(int x, int y, int w, int h)

public native void
setOutputAreaXYXY(int lox, int loy, int hix, int hiy)

public native void
setRule(int rule)

public native void
skipDownTo(int y)

Implements sun.java2d.pipe.SpanIterator.skipDownTo.

This method tells the iterator that it may skip all spans whose Y range is completely above the indicated Y coordinate.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pDataback to summary
pack-priv long pData

Constructor Detail

ShapeSpanIteratorback to summary
public ShapeSpanIterator(boolean adjust)

Method Detail

addSegmentback to summary
public native void addSegment(int type, float[] coords)
appendPathback to summary
public void appendPath(PathIterator pi)
appendPolyback to summary
public native void appendPoly(int[] xPoints, int[] yPoints, int nPoints, int xoff, int yoff)
closePathback to summary
public native void closePath()

Implements sun.awt.geom.PathConsumer2D.closePath.

curveToback to summary
public native void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)

Implements sun.awt.geom.PathConsumer2D.curveTo.

disposeback to summary
public native void dispose()
getNativeConsumerback to summary
public native long getNativeConsumer()

Implements sun.awt.geom.PathConsumer2D.getNativeConsumer.

Doc from sun.awt.geom.PathConsumer2D.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

getNativeIteratorback to summary
public native long getNativeIterator()

Implements sun.java2d.pipe.SpanIterator.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
getPathBoxback to summary
public native void getPathBox(int[] pathbox)

Implements sun.java2d.pipe.SpanIterator.getPathBox.

Doc from sun.java2d.pipe.SpanIterator.getPathBox.

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}.
initIDsback to summary
public static native void initIDs()
intersectClipBoxback to summary
public native void intersectClipBox(int lox, int loy, int hix, int hiy)

Implements sun.java2d.pipe.SpanIterator.intersectClipBox.

Doc from sun.java2d.pipe.SpanIterator.intersectClipBox.

This method constrains the spans returned by nextSpan() to the rectangle whose bounds are given.

lineToback to summary
public native void lineTo(float x, float y)

Implements sun.awt.geom.PathConsumer2D.lineTo.

moveToback to summary
public native void moveTo(float x, float y)

Implements sun.awt.geom.PathConsumer2D.moveTo.

nextSpanback to summary
public native boolean nextSpan(int[] spanbox)

Implements sun.java2d.pipe.SpanIterator.nextSpan.

Doc from sun.java2d.pipe.SpanIterator.nextSpan.

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}.
pathDoneback to summary
public native void pathDone()

Implements sun.awt.geom.PathConsumer2D.pathDone.

Doc from sun.awt.geom.PathConsumer2D.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.

quadToback to summary
public native void quadTo(float x1, float y1, float x2, float y2)

Implements sun.awt.geom.PathConsumer2D.quadTo.

setNormalizeback to summary
private native void setNormalize(boolean adjust)
setOutputAreaback to summary
public void setOutputArea(Rectangle r)
setOutputAreaback to summary
public void setOutputArea(Region r)
setOutputAreaXYWHback to summary
public void setOutputAreaXYWH(int x, int y, int w, int h)
setOutputAreaXYXYback to summary
public native void setOutputAreaXYXY(int lox, int loy, int hix, int hiy)
setRuleback to summary
public native void setRule(int rule)
skipDownToback to summary
public native void skipDownTo(int y)

Implements sun.java2d.pipe.SpanIterator.skipDownTo.

This method tells the iterator that it may skip all spans whose Y range is completely above the indicated Y coordinate.