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

PiscesCache

public final class PiscesCache extends Object
An object used to cache pre-rendered complex paths.
see
PiscesRenderer#render

Fields Summary
boolean
isValid
int
bboxX0
int
bboxY0
int
bboxX1
int
bboxY1
byte[]
rowAARLE
int
alphaRLELength
int[]
rowOffsetsRLE
int
alphaWidth
int
alphaHeight
int[]
minTouched
private static final float
ROWAA_RLE_FACTOR
private static final float
TOUCHED_FACTOR
private static final int
MIN_TOUCHED_LEN
Constructors Summary
private PiscesCache()

    
      
Methods Summary
voidaddRLERun(byte val, int runLen)

        reallocRowAARLE(alphaRLELength + 2);
        rowAARLE[alphaRLELength++] = val;
        rowAARLE[alphaRLELength++] = (byte)runLen;
    
voidaddRow(int minX, int offset)

        reallocRowInfo(alphaHeight + 1);
        minTouched[alphaHeight] = minX;
        rowOffsetsRLE[alphaHeight] = offset;
        ++alphaHeight;
    
public static com.sun.pisces.PiscesCachecreateInstance()

        return new PiscesCache();
    
public synchronized voiddispose()

        alphaWidth = alphaHeight = 0;

        rowAARLE = null;
        alphaRLELength = 0;

        minTouched = null;
        rowOffsetsRLE = null;

        isValid = false;
    
public synchronized booleanisValid()

        return isValid;
    
private voidreallocRowAARLE(int newLength)


        
        if (rowAARLE == null) {
            rowAARLE = new byte[newLength];
        } else if (rowAARLE.length < newLength) {
            int len = Math.max(newLength,
                               (int)(rowAARLE.length*ROWAA_RLE_FACTOR));
            byte[] newRowAARLE = new byte[len];
            System.arraycopy(rowAARLE, 0, newRowAARLE, 0, rowAARLE.length);
            rowAARLE = newRowAARLE;
        }
    
private voidreallocRowInfo(int newHeight)

        if (minTouched == null) {
            int len = Math.max(newHeight, MIN_TOUCHED_LEN);
            minTouched = new int[len];
            rowOffsetsRLE = new int[len];
        } else if (minTouched.length < newHeight) {
            int len = Math.max(newHeight,
                               (int)(minTouched.length*TOUCHED_FACTOR));
            int[] newMinTouched = new int[len];
            int[] newRowOffsetsRLE = new int[len];
            System.arraycopy(minTouched, 0, newMinTouched, 0,
                             minTouched.length);
            System.arraycopy(rowOffsetsRLE, 0, newRowOffsetsRLE, 0,
                             rowOffsetsRLE.length);
            minTouched = newMinTouched;
            rowOffsetsRLE = newRowOffsetsRLE;
        }