Hello.
Is their in Java any method to know is a line contains or inside an
arbitrary polygon or shape? Or is the any algorithm or mathematics
formula that can solve this problem?
Thanks.
KJ
-----Original Message-----
From: owner-visad-list@xxxxxxxxxxxxx
[mailto:owner-visad-list@xxxxxxxxxxxxx] On Behalf Of Ugo Taddei
Sent: Friday, July 25, 2003 3:47 PM
To: Rakesh Rathod
Subject: Re: printing three display components
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