339 try {
340 bb.rewind();
341 int width = bb.getInt();
342 int height = bb.getInt();
343 pixels = Application.GetApplication().createPixels(
344 width, height, bb.slice());
345 } catch (Exception e) {
346 //ignore incorrect sized arrays
347 //not a client problem
348 return null;
349 }
350 } else if (obj instanceof Pixels) {
351 pixels = (Pixels)obj;
352 } else {
353 return null;
354 }
355 com.sun.prism.Image platformImage = PixelUtils.pixelsToImage(
356 pixels);
357 ImageLoader il = Toolkit.getToolkit().loadPlatformImage(
358 platformImage);
359 return Image.impl_fromPlatformImage(il);
360 }
361 }
362
363 private Image readImage() {
364 ClipboardAssistance assistant =
365 (currentDragboard != null) ? currentDragboard : systemAssistant;
366
367 Object rawData = assistant.getData(Clipboard.RAW_IMAGE_TYPE);
368 if (rawData == null) {
369 Object htmlData = assistant.getData(Clipboard.HTML_TYPE);
370 if (htmlData != null) {
371 String url = parseIMG(htmlData);
372 if (url != null) {
373 try {
374 SecurityManager sm = System.getSecurityManager();
375 if (sm != null) {
376 AccessControlContext context = getAccessControlContext();
377 URL u = new URL(url);
378 String protocol = u.getProtocol();
379 if (protocol.equalsIgnoreCase("jar")) {
421 if ((data instanceof String) == false) {
422 return null;
423 }
424 String str = (String)data;
425 Matcher matcher = findTagIMG.matcher(str);
426 if (matcher.find()) {
427 return (matcher.group(1));
428 } else {
429 return null;
430 }
431 }
432
433 private boolean placeImage(final Image image) {
434 if (image == null) {
435 return false;
436 }
437
438 String url = image.getUrl();
439 if (url == null || PixelUtils.supportedFormatType(url)) {
440 com.sun.prism.Image prismImage =
441 (com.sun.prism.Image)image.impl_getPlatformImage();
442 Pixels pixels = PixelUtils.imageToPixels(prismImage);
443 if (pixels != null) {
444 systemAssistant.setData(Clipboard.RAW_IMAGE_TYPE, pixels);
445 return true;
446 } else {
447 return false;
448 }
449 } else {
450 systemAssistant.setData(Clipboard.URI_TYPE, url);
451 return true;
452 }
453 }
454
455 @Override public Set<DataFormat> getContentTypes() {
456 Set<DataFormat> set = new HashSet<DataFormat>();
457
458 if (dataCache != null) {
459 for (Pair<DataFormat, Object> pair : dataCache) {
460 set.add(pair.getKey());
461 }
|
339 try {
340 bb.rewind();
341 int width = bb.getInt();
342 int height = bb.getInt();
343 pixels = Application.GetApplication().createPixels(
344 width, height, bb.slice());
345 } catch (Exception e) {
346 //ignore incorrect sized arrays
347 //not a client problem
348 return null;
349 }
350 } else if (obj instanceof Pixels) {
351 pixels = (Pixels)obj;
352 } else {
353 return null;
354 }
355 com.sun.prism.Image platformImage = PixelUtils.pixelsToImage(
356 pixels);
357 ImageLoader il = Toolkit.getToolkit().loadPlatformImage(
358 platformImage);
359 return Toolkit.getImageAccessor().fromPlatformImage(il);
360 }
361 }
362
363 private Image readImage() {
364 ClipboardAssistance assistant =
365 (currentDragboard != null) ? currentDragboard : systemAssistant;
366
367 Object rawData = assistant.getData(Clipboard.RAW_IMAGE_TYPE);
368 if (rawData == null) {
369 Object htmlData = assistant.getData(Clipboard.HTML_TYPE);
370 if (htmlData != null) {
371 String url = parseIMG(htmlData);
372 if (url != null) {
373 try {
374 SecurityManager sm = System.getSecurityManager();
375 if (sm != null) {
376 AccessControlContext context = getAccessControlContext();
377 URL u = new URL(url);
378 String protocol = u.getProtocol();
379 if (protocol.equalsIgnoreCase("jar")) {
421 if ((data instanceof String) == false) {
422 return null;
423 }
424 String str = (String)data;
425 Matcher matcher = findTagIMG.matcher(str);
426 if (matcher.find()) {
427 return (matcher.group(1));
428 } else {
429 return null;
430 }
431 }
432
433 private boolean placeImage(final Image image) {
434 if (image == null) {
435 return false;
436 }
437
438 String url = image.getUrl();
439 if (url == null || PixelUtils.supportedFormatType(url)) {
440 com.sun.prism.Image prismImage =
441 (com.sun.prism.Image) Toolkit.getImageAccessor().getPlatformImage(image);
442 Pixels pixels = PixelUtils.imageToPixels(prismImage);
443 if (pixels != null) {
444 systemAssistant.setData(Clipboard.RAW_IMAGE_TYPE, pixels);
445 return true;
446 } else {
447 return false;
448 }
449 } else {
450 systemAssistant.setData(Clipboard.URI_TYPE, url);
451 return true;
452 }
453 }
454
455 @Override public Set<DataFormat> getContentTypes() {
456 Set<DataFormat> set = new HashSet<DataFormat>();
457
458 if (dataCache != null) {
459 for (Pair<DataFormat, Object> pair : dataCache) {
460 set.add(pair.getKey());
461 }
|