public interface ImagePainter
Subclasses can redefine it and use third-party libraries for actual rendering, for example, Bitmaps can be rendered using javax.imageio.* , WMF can be rendered using Apache Batik, PICT can be rendered using Apple QuickTime API for Java, etc.
A typical usage is as follows:
public WMFPaiter implements ImagePainter{
public void paint(Graphics2D graphics, PictureData pict, Picture parent){
DataInputStream is = new DataInputStream(new ByteArrayInputStream(pict.getData()));
org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =
new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();
try {
wmfStore.read(is);
} catch (IOException e){
return;
}
Rectangle anchor = parent.getAnchor();
float scale = (float)anchor.width/wmfStore.getWidthPixels();
org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =
new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 0, 0, scale);
graphics.translate(anchor.x, anchor.y);
painter.paint(graphics);
}
}
PictureData.setImagePainter(Picture.WMF, new WMFPaiter());
...
Subsequent calls of Slide.draw(Graphics gr) will use WMFPaiter for WMF images.Modifier and Type | Method and Description |
---|---|
void |
paint(Graphics2D graphics,
PictureData pict,
Picture parent)
Paints the specified picture data
|
void paint(Graphics2D graphics, PictureData pict, Picture parent)
graphics
- the graphics to paintb intopict
- the data to paintparent
- the shapes that owns the picture dataCopyright © 2020. All rights reserved.