72 public static final int CF_TIFF = 3; |
74 public static final int CF_TIFF = 3; |
73 public static final int CF_RICH_TEXT = 4; |
75 public static final int CF_RICH_TEXT = 4; |
74 public static final int CF_HTML = 5; |
76 public static final int CF_HTML = 5; |
75 public static final int CF_PDF = 6; |
77 public static final int CF_PDF = 6; |
76 public static final int CF_URL = 7; |
78 public static final int CF_URL = 7; |
77 public static final int CF_PNG = 10; |
79 public static final int CF_PNG = 8; |
78 public static final int CF_JPEG = 11; |
80 public static final int CF_JPEG = 9; |
79 |
81 |
80 private CDataTransferer() {} |
82 private CDataTransferer() {} |
81 |
83 |
82 private static CDataTransferer fTransferer; |
84 private static CDataTransferer fTransferer; |
83 |
85 |
202 @Override |
204 @Override |
203 public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() { |
205 public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() { |
204 return handler; |
206 return handler; |
205 } |
207 } |
206 |
208 |
207 private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH); |
|
208 @Override |
209 @Override |
209 protected byte[] imageToPlatformBytes(Image image, long format) { |
210 protected byte[] imageToPlatformBytes(Image image, long format) { |
210 int w = image.getWidth(null); |
211 return CImage.getCreator().getPlatformImageBytes(image); |
211 int h = image.getHeight(null); |
|
212 BufferedImage bimage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); |
|
213 Graphics g = bimage.getGraphics(); |
|
214 g.drawImage(image, 0, 0, w, h, null); |
|
215 g.dispose(); |
|
216 Raster raster = bimage.getRaster(); |
|
217 DataBuffer buffer = raster.getDataBuffer(); |
|
218 return imageDataToPlatformImageBytes(((DataBufferInt)buffer).getData(), |
|
219 raster.getWidth(), |
|
220 raster.getHeight()); |
|
221 } |
212 } |
222 |
213 |
223 private static native String[] nativeDragQueryFile(final byte[] bytes); |
214 private static native String[] nativeDragQueryFile(final byte[] bytes); |
224 @Override |
215 @Override |
225 protected String[] dragQueryFile(final byte[] bytes) { |
216 protected String[] dragQueryFile(final byte[] bytes) { |
226 if (bytes == null) return null; |
217 if (bytes == null) return null; |
227 if (new String(bytes).startsWith("Unsupported type")) return null; |
218 if (new String(bytes).startsWith("Unsupported type")) return null; |
228 return nativeDragQueryFile(bytes); |
219 return nativeDragQueryFile(bytes); |
229 } |
220 } |
230 |
221 |
231 private native Image getImageForByteStream(byte[] bytes); |
|
232 /** |
|
233 * Translates a byte array which contains |
|
234 * platform-specific image data in the given format into an Image. |
|
235 */ |
|
236 @Override |
222 @Override |
237 protected Image platformImageBytesToImage(byte[] bytes, long format) throws IOException { |
223 protected Image platformImageBytesToImage(byte[] bytes, long format) throws IOException { |
238 return getImageForByteStream(bytes); |
224 return CImage.getCreator().createImageFromPlatformImageBytes(bytes); |
239 } |
225 } |
240 |
226 |
241 @Override |
227 @Override |
242 protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException { |
228 protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException { |
243 ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
229 ByteArrayOutputStream bos = new ByteArrayOutputStream(); |