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

PiscesShapeRenderer

public class PiscesShapeRenderer extends Object implements com.sun.me.gci.renderer.GCIShapeRenderer
PiscesShapeRenderer

Fields Summary
protected PiscesRenderer
piscesRenderer
static final float
FIXED_1_0
com.sun.me.gci.renderer.GCIRenderContext
context
int[]
clip
private static final int[]
GCI_TO_PISCES_COMPOSITE
Constructors Summary
protected PiscesShapeRenderer(com.sun.me.gci.surface.GCIDrawingSurface surface)
Creates a new instance of PiscesShapeRenderer

        piscesRenderer = new PiscesRenderer(new PiscesGCISurface(surface));    
        
        this.clip[0] = 0;
        this.clip[1] = 0;
        this.clip[2] = surface.getWidth();
        this.clip[3] = surface.getHeight();
    
Methods Summary
voidacquireSurface()

        ((PiscesGCISurface)piscesRenderer.surface).acquireSurface();       
    
public voidattributesModified(int attribute)
Notifies the renderer that some of the attribute[s] in the render context has been modified.

param
attribute one of the constant specified in the see also section should be passed.
see
com.sun.me.gci.renderer.GCIRenderContext#ATTRIBUTE_CLIP

        if ( (attribute & GCIRenderContext.ATTRIBUTE_CLIP) != 0 ){
            this.clipModified();
        }
        if ( (attribute & GCIRenderContext.ATTRIBUTE_PAINT) != 0 ){
            this.paintModified();
        }
        if ( (attribute & GCIRenderContext.ATTRIBUTE_COMPOSITE) != 0 ){
            this.compositeModified();
        }
        if ( (attribute & GCIRenderContext.ATTRIBUTE_STROKE) != 0 ){
            this.strokeModified();
        }
    
public voidclipModified()

        context.getClip(this.clip);
        piscesRenderer.setClip(this.clip[0], this.clip[1],this.clip[2], this.clip[3]);
    
public voidcompositeModified()

        piscesRenderer.setComposite(
                GCI_TO_PISCES_COMPOSITE[this.context.getCompositeRule()],
                this.context.getCompositeAlpha());
    
public voidcontextCreated(com.sun.me.gci.renderer.GCIRenderContext context)
Notifies the renderer that a render context is created for this renderer. The context must be initialized with all the attributes when this method is invoked.

        GCIDrawingSurface surface = context.getDrawingSurface();
        this.context = context;
        clipModified();
        paintModified();
        strokeModified();
        compositeModified();
        transformModified();
    
public voidcontextDisposed()
Notifies the renderer that the render context is disposed. The renderer implementation can free any resources allocated for servicing the context.

        releaseSurface();
        this.context = null;
    
public com.sun.me.gci.renderer.GCIRenderercreate()

        return new PiscesShapeRenderer(this.context.getDrawingSurface());
    
public voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.drawArc(x<<16,y<<16,width<<16,height<<16,
            startAngle<<16,arcAngle<<16,
            PiscesRenderer.ARC_OPEN );
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voiddrawLine(int x0, int y0, int x1, int y1)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.drawLine(x0<<16, y0<<16, x1<<16, y1<<16);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voiddrawOval(int x, int y, int w, int h)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.drawOval(x<<16, y<<16, w<<16, h<<16);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints, boolean close)

        fillOrDrawPolyline(xPoints, yPoints, nPoints, close,
            true /* stroke the polyline */
            );
    
public voiddrawRect(int x, int y, int w, int h)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.drawRect(x<<16, y<<16, w<<16, h<<16);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voiddrawRoundRect(int x, int y, int w, int h, int aw, int ah)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.drawRoundRect(x<<16, y<<16, w<<16, h<<16, aw<<16, ah<<16);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.fillArc(x<<16,y<<16,width<<16,height<<16,
            startAngle<<16,arcAngle<<16,
            PiscesRenderer.ARC_PIE);
        this.context.getDrawingSurface().renderingEnd(this.clip);
        
    
private voidfillOrDrawPolyline(int[] xPoints, int[] yPoints, int nPoints, boolean close, boolean stroke)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.beginRendering(RendererBase.WIND_NON_ZERO);

        // path begin
        if ( !stroke )
            piscesRenderer.setFill();
        piscesRenderer.moveTo((xPoints[0]<<16), (yPoints[0]<<16));
        for (int i = 1; i < nPoints; i++) {
            piscesRenderer.lineTo((xPoints[i]<<16), (yPoints[i]<<16));
        }
        if (close) {
            piscesRenderer.close();
        }
        piscesRenderer.end(); // path end
        piscesRenderer.endRendering();
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voidfillOval(int x, int y, int w, int h)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.fillOval(x<<16, y<<16, w<<16, h<<16);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints)

        fillOrDrawPolyline(xPoints, yPoints, nPoints,
            true, /* close the path */
            false /* fill the polyline */
            );
    
public voidfillRect(int x, int y, int w, int h)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.fillRect(x<<16, y<<16, w<<16, h<<16);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voidfillRect2(int x, int y, int w, int h)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.fillRect(x, y, w, h);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public voidfillRoundRect(int x, int y, int w, int h, int aw, int ah)

        this.context.getDrawingSurface().renderingBegin();
        piscesRenderer.fillRoundRect(x<<16, y<<16, w<<16, h<<16, aw<<16, ah<<16);
        this.context.getDrawingSurface().renderingEnd(this.clip);
    
public final voidfontModified()

    
protected static intgetByteShiftForPixelArrayCount(int arrayType)

        int denom = 1;
         switch (arrayType){
            case GCISurfaceInfo.TYPE_JAVA_ARRAY_BYTE:
                denom = 0;
            break;
            case GCISurfaceInfo.TYPE_JAVA_ARRAY_SHORT:
                denom = 1;
            break;
            default:
                denom = 2;
            break;    
         }
         return denom;
    
public voidhintsModified()

        piscesRenderer.setAntialiasing(this.context.isAntiAliasingOn());
    
public static com.sun.me.gci.renderer.GCIAdvancedShapeRenderernewAdvancedInstance(com.sun.me.gci.surface.GCIDrawingSurface surface)
Factory method as mandated by GCI.

        if ( surface.isSurfaceInfoDynamic() ) {
            return new PiscesAdvancedShapeRenderer.DynamicSurface(surface);
        } else {
            return new PiscesAdvancedShapeRenderer(surface);
        }
    
public static com.sun.me.gci.renderer.GCIShapeRenderernewInstance(com.sun.me.gci.surface.GCIDrawingSurface surface, boolean lcduiGraphics, boolean useContextTransform)
Factory method as mandated by GCI.

    
               
        
         
          
        if ( surface.isSurfaceInfoDynamic() ) {
            return new PiscesShapeRenderer.DynamicSurface(surface);
        } else {
            return new PiscesShapeRenderer(surface);
        }
    
public voidpaintModified()

        int paintMode = context.getPaintMode();
        if ( paintMode == GCIRenderContext.PAINT_MODE_COLOR ){
            int color = context.getPaintColor();
            piscesRenderer.setColor((color>>16) & 0xFF, // red
                (color>>8) & 0xFF,             // green
                (color) & 0xFF,                // blue
                (color>>24) & 0xFF );          // alpha
        }
        else
        if ( paintMode == GCIRenderContext.PAINT_MODE_XOR ){

        }
        else
        if ( paintMode == GCIRenderContext.PAINT_MODE_LINEAR_GRADIENT ){
             // for agui
        }
    
voidreleaseSurface()

       ((PiscesGCISurface)piscesRenderer.surface).releaseSurface();
    
public voidstrokeModified()

        float[] floatDash = this.context.getDashPattern();
        int dashPhase = 0;
        int[] fpDash = null;
        
        if ( floatDash != null ) {
            fpDash = new int[floatDash.length];
            for ( int i = 0 ; i < fpDash.length ; i++ ){
                fpDash[i] = (int)(floatDash[i]*FIXED_1_0);
            }
            dashPhase = (int)(this.context.getDashPhase()*FIXED_1_0);
        }
        piscesRenderer.setStroke((int)(this.context.getLineWidth()*FIXED_1_0),
            this.context.getCapStyle(),
            this.context.getJoinStyle(),
            (int)(this.context.getMiterLimit()*FIXED_1_0),
            fpDash,
            dashPhase);
    
public voidtransformModified()