Hello,
Curtis Rueden wrote:
Hi Rakesh,
I don't know that much about printing in Java, but looking at
the DisplayImpl.getPrintable() method, it appears you could
construct a Printable object in whose print() method you create
a BufferedImage consisting of a synthesis of the three displays
(in whatever orientation you desire). Use DisplayImpl.getImage()
to grab a BufferedImage with the contents of a VisAD Display.
See DisplayImpl.getPrintable() for an example of using the
Printable interface to send BufferedImages to the printer.
There could be an easier way, but that's really more of a Java
programming question, rather than a VisAD question.
Definitely a Java programming question. Nevertheless, I found code
snippet lying around on my disk. Feel free to try it (I don't even now
if it works; it might have worked, some time ago ;-) then let us know
when you improved it.
NB: Follow Curtis' suggestions, and you'll also need to change
final JPanel gp = this.getCentralPanel();
to match the panel where all your displays live.
public Printable getPrintable()
{
Printable printer=null;
final JPanel gp = this.getCentralPanel();
if (printer == null)
printer
new Printable() {
public int print(Graphics g, PageFormat pf, int pi)
throws PrinterException
{
if (pi >= 1)
{
return Printable.NO_SUCH_PAGE;
}
pf.setOrientation(PageFormat.LANDSCAPE);
// or: LANDSCAPE
//JPanel gp = getcentralPanel();
Image image = (Image) gp.createImage(gp.getWidth ()
,gp.getHeight());
Graphics gg = image.getGraphics();
gp.paint(gg);
BufferedImage bufImage = (BufferedImage)image;
//BufferedImage image = DisplayImpl.this.getImage();
g.drawImage(
bufImage,
(int) pf.getImageableX(),
(int) pf.getImageableY(),
gp);
return Printable.PAGE_EXISTS;
}
};
return printer;
}
Cheers,
Ugo