ScalableGraphicspublic class ScalableGraphics extends Object
Fields Summary |
---|
static final com.sun.perseus.j2d.RGB | CLEAR_PAINTPaint used to clear offscreens. | javax.microedition.lcdui.Graphics | gThe Graphics object bound to this class | com.sun.pisces.GraphicsSurfaceDestination | gsdThe GraphicsSurfaceDestination used to blit the native surface to the
Graphics. | int | qualityModeThe current quality mode. | com.sun.perseus.model.DirtyAreaManager | dirtyAreaManagerThe DirtyAreaManager used to minimize renderings. | float | alphaThe current transparency for rendering images. | com.sun.pisces.NativeSurface | offscreenThe offscreen buffer, used for temporary rendering of the
image. | com.sun.pisces.PiscesRenderer | prThe PiscesRenderer associated with the offscreen. | int | offscreenWidthThe offscreen width. | int | offscreenHeightThe offscreen height. | com.sun.perseus.j2d.RenderGraphics | rgThe RenderGraphics used to draw to the PiscesRenderer | public static final int | RENDERING_QUALITY_LOW | public static final int | RENDERING_QUALITY_HIGH |
Constructors Summary |
---|
private ScalableGraphics()Constructor
|
Methods Summary |
---|
public void | bindTarget(java.lang.Object target)
if (target == null) {
throw new NullPointerException();
}
if (!(target instanceof Graphics)) {
throw new IllegalArgumentException();
}
if (g != null) {
throw new IllegalStateException("bindTarget(" + target + ") with g : " + g);
}
g = (Graphics) target;
gsd = new GraphicsSurfaceDestination(g);
| void | checkOffscreen(int width, int height)Get an offscreen buffer big enough to draw a widht by height
image.
int w = width;
int h = height;
if (w <= 0) {
w = 1;
}
if (h <= 0) {
h = 1;
}
if (offscreen == null
||
offscreenWidth != w
||
offscreenHeight != h) {
offscreen = new NativeSurface(w, h);
offscreenWidth = w;
offscreenHeight = h;
pr = new PiscesRenderer(offscreen, w, h, 0, w, 1,
RendererBase.TYPE_INT_ARGB);
rg = new RenderGraphics(pr, offscreenWidth, offscreenHeight);
}
| public static javax.microedition.m2g.ScalableGraphics | createInstance()
return new ScalableGraphics();
| public void | releaseTarget()
if (g == null) {
throw new IllegalStateException("releaseTarget() with null current target");
}
g = null;
gsd = null;
| public void | render(int x, int y, ScalableImage image)
if (image == null) {
throw new NullPointerException();
}
if (g == null) {
throw new IllegalStateException();
}
DocumentNode documentNode =
(DocumentNode) ((SVGImage) image).getDocument();
int vpw = image.getViewportWidth();
int vph = image.getViewportHeight();
checkOffscreen(vpw, vph);
if (DirtyAreaManager.ON) {
dirtyAreaManager.setViewport(documentNode);
documentNode.setUpdateListener(dirtyAreaManager);
}
rg.setRenderingQuality(qualityMode == RENDERING_QUALITY_HIGH);
documentNode.sample(documentNode.getCurrentTime());
documentNode.applyAnimations();
if (DirtyAreaManager.ON) {
dirtyAreaManager.refresh(documentNode, rg, CLEAR_PAINT);
} else {
// Clear offscreen and paint
pr.setColor(0, 0, 0, 0);
pr.setClip(0, 0, offscreenWidth, offscreenHeight);
pr.clearRect(0, 0, offscreenWidth, offscreenHeight);
documentNode.paint(rg);
}
// Now, render the image with alpha.
gsd.drawSurface(offscreen, 0, 0, x, y, offscreenWidth, offscreenHeight, alpha);
| public void | setRenderingQuality(int mode)
if (mode != RENDERING_QUALITY_LOW && mode != RENDERING_QUALITY_HIGH) {
throw new IllegalArgumentException("" + mode);
}
this.qualityMode = mode;
| public void | setTransparency(float alpha)
if (alpha < 0f || alpha > 1f) {
throw new IllegalArgumentException();
}
this.alpha = alpha;
|
|