Note that there are some explanatory texts on larger screens.

plurals
  1. POCopy Image to Clipboard not working on Linux (Java AWT & SWT)
    primarykey
    data
    text
    <p>I am developing an Eclipse RCP Application which includes JFreeChart. One of its features is to copy graphs to the clipboard in order to paste them into other applications but it does not work on Linux,</p> <p>There is a <a href="http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet282.java" rel="nofollow">SWT sample</a> where you can find a snippet that does not work in Linux.</p> <p>On the other hand JFreeChart implemented this on AWT as:</p> <pre><code>Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Insets insets = getInsets(); int w = getWidth() - insets.left - insets.right; int h = getHeight() - insets.top - insets.bottom; ChartTransferable selection = new ChartTransferable(this.chart, w, h, getMinimumDrawWidth(), getMinimumDrawHeight(), getMaximumDrawWidth(), getMaximumDrawHeight(), true); systemClipboard.setContents(selection, null); </code></pre> <p>Howewer both examples fail on Linux 64bit. Is there a way to implement it??</p> <p>Thanks in advance!</p> <p>EDIT:</p> <p>Code that copy the JFreeChart graphic into a file but not into the Clipboard</p> <pre><code>final org.eclipse.swt.dnd.Clipboard clipboard = new org.eclipse.swt.dnd.Clipboard(menu.getDisplay()); Insets insets = source.getInsets(); int w = source.getWidth() - insets.left - insets.right; int h = source.getHeight() - insets.top - insets.bottom; ChartTransferable selection = new ChartTransferable(source .getChart(), w, h, source.getMinimumDrawWidth(), source.getMinimumDrawHeight(), source .getMaximumDrawWidth(), source.getMaximumDrawHeight(), true); Image image = new Image(menu.getDisplay(),ImageUtils.convertToSWT(selection.getBufferedImage())); if (image != null) { ImageLoader imageLoader = new ImageLoader(); imageLoader.data = new ImageData[] { image.getImageData() }; imageLoader.save("/tmp/graph.jpg", SWT.IMAGE_JPEG); // fails ImageTransfer imageTransfer = ImageTransfer.getInstance(); clipboard.setContents(new Object[]{image.getImageData()}, new Transfer[]{imageTransfer}, DND.CLIPBOARD | DND.SELECTION_CLIPBOARD); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload