Java Reference
In-Depth Information
public SVGImageItem( String l, InputStream in, ExternalResourceHandler h ) {
super(l);
sg = ScalableGraphics.createInstance();
if (in != null) {
try {
image = (SVGImage)ScalableImage.createImage(in, h);
} catch( IOException e) { e.printStackTrace(); };
} else {
image = (SVGImage)SVGImage.createEmptyImage(h);
}
SVGAnimator animator = SVGAnimator.createAnimator(image);
Canvas svgCanvas = (Canvas)animator.getTargetComponent();
prefWidth = svgCanvas.getWidth();
prefHeight = svgCanvas.getHeight();
image.setViewportWidth(prefWidth);
image.setViewportHeight(prefHeight);
}
protected int getPrefContentHeight(int w) {
return minContentHeight();
}
protected int getPrefContentWidth(int h) {
return minContentWidth();
}
protected int getMinContentHeight() {
return prefHeight;
}
protected int getMinContentWidth() {
return prefWidth;
}
public void paint(Graphics g, int w, int h) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, w, h);
sg.bindTarget(g);
image.setViewportWidth(w);
image.setViewportHeight(h);
sg.render(0, 0, image);
sg.releaseTarget();
}
}
 
Search WWH ::




Custom Search