FileDocCategorySizeDatePackage
PiscesRenderer.javaAPI DocphoneME MR2 API (J2ME)13932Wed May 02 18:00:36 BST 2007com.sun.pisces

PiscesRenderer

public final class PiscesRenderer extends PathSink implements NativeFinalization

Fields Summary
private static boolean
messageShown
public static final int
ARC_OPEN
public static final int
ARC_CHORD
public static final int
ARC_PIE
long
nativePtr
final AbstractSurface
surface
private final NativeFinalizer
finalizer
int[]
gcm_fractions
int[]
gcm_rgba
int
gcm_cycleMethod
GradientColorMap
gradientColorMap
Constructors Summary
public PiscesRenderer(Object data, int width, int height, int offset, int scanlineStride, int pixelStride, int type)
Creates a renderer that will write into a given pixel array.

param
data the destination surface where pixel data should be written.
param
width the width of the pixel array.
param
height the height of the pixel array.
param
offset the starting offset of the pixel array.
param
scanlineStride the scanline stride of the pixel array, in array entries.
param
pixelStride the pixel stride of the pixel array, in array entries.
param
type the pixel format, one of the RendererBase.TYPE_* constants.

        this((AbstractSurface)data);
    
public PiscesRenderer(AbstractSurface surface)

        if (!messageShown) {
            System.out.println("Using Pisces Renderer (native version)");
        }

        this.finalizer = NativeFinalizer.createInstance(this);
        this.surface = surface;
        initialize();
        messageShown = true;
    
Methods Summary
private booleanarraysDiffer(int[] a, int[] b)

    
          
        if (a == null) {
            return true;
        }
        int len = b.length;
        if (a.length != len) {
            return true;
        }
        for (int i = 0; i < len; i++) {
            if (a[i] != b[i]) {
                return true;
            }
        }
        
        return false;
    
public native voidbeginRendering(int windingRule)

public native voidbeginRendering(int minX, int minY, int width, int height, int windingRule)
Begins the rendering of path data. The supplied clipping bounds are intersected against the current clip rectangle and the destination image bounds; only pixels within the resulting rectangle may be written to.

public native voidclearRect(int x, int y, int w, int h)

private int[]cloneArray(int[] src)

        int len = src.length;
        int[] dst = new int[len];
        System.arraycopy(src, 0, dst, 0, len);
        return dst;
    
public native voidclose()

public native voidcubicTo(int x1, int y1, int x2, int y2, int x3, int y3)

public native voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle, int arcType)

public native voiddrawLine(int x0, int y0, int x1, int y1)

public native voiddrawOval(int x, int y, int w, int h)

public native voiddrawRect(int x, int y, int w, int h)

public native voiddrawRoundRect(int x, int y, int w, int h, int aw, int ah)

public native voidend()

public native voidendRendering()
Completes the rendering of path data. Destination pixels will be written at this time.

public native voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle, int arcType)

public native voidfillOval(int x, int y, int w, int h)

public native voidfillRect(int x, int y, int w, int h)

param
x the X coordinate in S15.16 format.
param
y the Y coordinate in S15.16 format.
param
w the width in S15.16 format.
param
h the height in S15.16 format.

public native voidfillRoundRect(int x, int y, int w, int h, int aw, int ah)

public native booleangetAntialiasing()

public native voidgetBoundingBox(int[] bbox)
Returns a bounding box containing all pixels drawn during the rendering of the most recent primitive (beginRendering/endRendering pair). The bounding box is returned in the form (x, y, width, height).

public PathSinkgetFiller()

        notImplemented();
        return null;
    
public voidgetImageData()

        notImplemented();
    
public PathSinkgetStroker()

        notImplemented();
        return null;
    
public PathSinkgetTextFiller()

        notImplemented();
        return null;
    
public Transform6getTransform()

        Transform6 transform = new Transform6();
        getTransformImpl(transform);
        return transform;
    
private native voidgetTransformImpl(Transform6 transform)

private native voidinitialize()

public native voidlineJoin()

public native voidlineTo(int x1, int y1)

public native voidmoveTo(int x0, int y0)

public native voidnativeFinalize()

private voidnotImplemented()

        
     
        String strValue;
        int strokeXBias = 0; // default x bias
        int strokeYBias = 0; // default y bias

        strValue = Configuration.getProperty("pisces.stroke.xbias");
        if (strValue != null) {
            try {
                strokeXBias = Integer.parseInt(strValue);
            } catch (NumberFormatException e) {
            }
        }
        
        strValue = Configuration.getProperty("pisces.stroke.ybias");
        if (strValue != null) {
            try {
                strokeYBias = Integer.parseInt(strValue);
            } catch (NumberFormatException e) {
            }
        }

        staticInitialize(strokeXBias, strokeYBias);
    
        new RuntimeException().printStackTrace();
        System.out.println("not implemented");

//         throw new RuntimeException("PiscesRendererNativeImpl: " +
//                 "Not implemented!");
    
public native voidquadTo(int x1, int y1, int x2, int y2)

public native voidresetClip()
Resets the clip rectangle. Each primitive will be clipped only to the destination image bounds.

public native voidsetAntialiasing(boolean antialiasingOn)

public native voidsetClip(int minX, int minY, int width, int height)
Sets a clip rectangle for all primitives. Each primitive will be clipped to the intersection of this rectangle and the destination image bounds.

public native voidsetColor(int red, int green, int blue, int alpha)
Sets the current paint color.

param
red a value between 0 and 255.
param
green a value between 0 and 255.
param
blue a value between 0 and 255.
param
alpha a value between 0 and 255.

public voidsetColor(int red, int green, int blue)
Sets the current paint color. An alpha value of 255 is used.

param
red a value between 0 and 255.
param
green a value between 0 and 255.
param
blue a value between 0 and 255.

        setColor(red, green, blue, 255);
    
public native voidsetComposite(int compositeRule, float alpha)

public native voidsetCompositeRule(int compositeRule)

public native voidsetFill()

private voidsetGradientColorMap(int[] fractions, int[] rgba, int cycleMethod)

        if (fractions.length != rgba.length) {
            throw new IllegalArgumentException("fractions.length != rgba.length!");
        }
        
        if (gradientColorMap == null ||
            gcm_cycleMethod != cycleMethod ||
            arraysDiffer(gcm_fractions, fractions) ||
            arraysDiffer(gcm_rgba, rgba)) {
            this.gradientColorMap =
                new GradientColorMap(fractions, rgba, cycleMethod);
            this.gcm_cycleMethod = cycleMethod;
            this.gcm_fractions = cloneArray(fractions);
            this.gcm_rgba = cloneArray(rgba);
        }
    
public voidsetLinearGradient(int x0, int y0, int x1, int y1, int[] fractions, int[] rgba, int cycleMethod, Transform6 gradientTransform)

        setGradientColorMap(fractions, rgba, cycleMethod);
        setLinearGradientImpl(x0, y0, x1, y1,
                              gradientColorMap.colors, cycleMethod,
                              gradientTransform);
    
public voidsetLinearGradient(int x0, int y0, int color0, int x1, int y1, int color1, int cycleMethod)
Java2D-style linear gradient creation. The color changes proportionally between point P0 (color0) nad P1 (color1). Cycle method constants are defined in GradientColorMap (CYCLE_*).

param
x0 x coordinate of point P0
param
y0 y coordinate of point P0
param
color0 color of P0
param
x1 x coordinate of point P1
param
y1 y coordinate of point P1
param
color1 color of P1
param
cycleMethod type of cycling of the gradient (NONE, REFLECT, REPEAT)

      int[] fractions = {0x0000, 0x10000};
      int[] rgba = {color0, color1};
      Transform6 ident = new Transform6(1 << 16, 0, 0, 1 << 16, 0, 0);
      setLinearGradient(x0, y0, x1, y1, fractions, rgba, cycleMethod, ident);
    
private native voidsetLinearGradientImpl(int x0, int y0, int x1, int y1, int[] colors, int cycleMethod, Transform6 gradientTransform)

public native voidsetPathData(float[] data, byte[] commands, int nCommands)

public voidsetRadialGradient(int cx, int cy, int fx, int fy, int radius, int[] fractions, int[] rgba, int cycleMethod, Transform6 gradientTransform)

        setGradientColorMap(fractions, rgba, cycleMethod);
        setRadialGradientImpl(cx, cy, fx, fy, radius,
                              gradientColorMap.colors, cycleMethod,
                              gradientTransform);
    
private native voidsetRadialGradientImpl(int cx, int cy, int fx, int fy, int radius, int[] colors, int cycleMethod, Transform6 gradientTransform)

public native voidsetStroke(int lineWidth, int capStyle, int joinStyle, int miterLimit, int[] dashArray, int dashPhase)
Sets the current stroke parameters.

param
lineWidth the sroke width, in S15.16 format.
param
capStyle the line cap style, one of Stroker.CAP_*.
param
joinStyle the line cap style, one of Stroker.JOIN_*.
param
miterLimit the stroke miter limit, in S15.16 format.
param
dashArray an int array containing the dash segment lengths in S15.16 format, or null.
param
dashPhase the starting dash offset, in S15.16 format.

public native voidsetStroke()

public voidsetTextFill()

        notImplemented();
    
public voidsetTexture(int imageType, java.lang.Object imageData, int width, int height, int offset, int stride, Transform6 textureTransform, boolean repeat)

        if (imageData instanceof int[]) {
            setTextureImpl(imageType, (int[])imageData, width, height, offset, 
                    stride, textureTransform, repeat);
        }
    
private native voidsetTextureImpl(int imageType, int[] imageData, int width, int height, int offset, int stride, Transform6 textureTransform, boolean repeat)

public voidsetTextureOpacity(float opacity)

	notImplemented();
    
public native voidsetTransform(Transform6 transform)
Sets the current transform from user to window coordinates.

param
transform an Transform6 object.

private static native voidstaticInitialize(int strokeXBias, int strokeYBias)