Linux program seem to use several different clipboard mechanisms. We implemented two ways to save the MapBean image; to the clipboard and to a file. We disable the clipboard copy on Linux.
Cheers,
David
----- Original Message ----
From: Bart Jourquin <bart.jourquin_at_fucam.ac.be>
To: OpenMap <openmap-users_at_bbn.com>
Sent: Tuesday, May 29, 2007 9:10:11 AM
Subject: [OpenMap Users] Copy map bean to clipboard fails on Linux
Hi all,
I've implemented the following code to put the current displayed map on the map bean into the clipboard. This code works fine on Windows, but not on Linux (I cannot paste into another app). Any idea?
Bart
void copyMapToClipboard() {
// Get image from mapBean
int width = getMapBean().getWidth();
int height = getMapBean().getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Graphics g = ge.createGraphics(image);
g.setClip(0, 0, width, height);
getMapBean().paintAll(g);
ImageSelection imgSel = new ImageSelection(image);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null);
Toolkit.getDefaultToolkit().beep();
}
// This class is used to hold an image while on the clipboard.
public static class ImageSelection implements Transferable {
private Image image;
public ImageSelection(Image image) {
this.image = image;
}
// Returns supported flavors
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] { DataFlavor.imageFlavor };
}
// Returns true if flavor is supported
public boolean isDataFlavorSupported(DataFlavor flavor) {
return DataFlavor.imageFlavor.equals(flavor);
}
// Returns image
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (!DataFlavor.imageFlavor.equals(flavor)) {
throw new UnsupportedFlavorException(flavor);
}
return image;
}
}
--
Prof Dr Bart Jourquin
F.U.Ca.M. - G.T.M.
Chaussée de Binche, 151a
B7000 Mons
Belgium
Tel. : +32 65 323293
Fax. : +32 65 315691
http://www.fucam.ac.be/jourquin
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue May 29 2007 - 13:41:34 EDT