--- old/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingFXUtils.java 2018-07-06 11:54:54.689164200 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingFXUtils.java 2018-07-06 11:54:53.866559800 +0530 @@ -28,6 +28,9 @@ import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.SampleModel; +import java.awt.image.SinglePixelPackedSampleModel; import java.nio.IntBuffer; import java.util.Set; import java.util.HashSet; @@ -41,7 +44,6 @@ import javafx.scene.paint.Color; import com.sun.javafx.tk.Toolkit; import javax.swing.SwingUtilities; -import sun.awt.image.IntegerComponentRaster; /** * This class provides utility methods for converting data types between @@ -111,10 +113,15 @@ wimg = new WritableImage(bw, bh); } PixelWriter pw = wimg.getPixelWriter(); - IntegerComponentRaster icr = (IntegerComponentRaster) bimg.getRaster(); - int data[] = icr.getDataStorage(); - int offset = icr.getDataOffset(0); - int scan = icr.getScanlineStride(); + DataBufferInt db = (DataBufferInt)bimg.getRaster().getDataBuffer(); + int data[] = db.getData(); + int offset = bimg.getRaster().getDataBuffer().getOffset(); + int scan = 0; + SampleModel sm = bimg.getRaster().getSampleModel(); + if (sm instanceof SinglePixelPackedSampleModel) { + scan = ((SinglePixelPackedSampleModel)sm).getScanlineStride(); + } + PixelFormat pf = (bimg.isAlphaPremultiplied() ? PixelFormat.getIntArgbPreInstance() : PixelFormat.getIntArgbInstance()); @@ -281,10 +288,15 @@ if (bimg == null) { bimg = new BufferedImage(iw, ih, prefBimgType); } - IntegerComponentRaster icr = (IntegerComponentRaster) bimg.getRaster(); - int offset = icr.getDataOffset(0); - int scan = icr.getScanlineStride(); - int data[] = icr.getDataStorage(); + DataBufferInt db = (DataBufferInt)bimg.getRaster().getDataBuffer(); + int data[] = db.getData(); + int offset = bimg.getRaster().getDataBuffer().getOffset(); + int scan = 0; + SampleModel sm = bimg.getRaster().getSampleModel(); + if (sm instanceof SinglePixelPackedSampleModel) { + scan = ((SinglePixelPackedSampleModel)sm).getScanlineStride(); + } + WritablePixelFormat pf = getAssociatedPixelFormat(bimg); pr.getPixels(0, 0, iw, ih, pf, data, offset, scan); return bimg; @@ -295,8 +307,10 @@ * invokes a runnable directly blocking the calling code * Otherwise * uses Platform.runLater without blocking + * + * @param runnable {@code Runnable} to be invoked */ - static void runOnFxThread(Runnable runnable) { + public static void runOnFxThread(Runnable runnable) { if (Platform.isFxApplicationThread()) { runnable.run(); } else { @@ -309,8 +323,10 @@ * invokes a runnable directly blocking the calling code * Otherwise * uses SwingUtilities.invokeLater without blocking + * + * @param r {@code Runnable} to be invoked */ - static void runOnEDT(final Runnable r) { + public static void runOnEDT(final Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run(); } else { @@ -321,9 +337,13 @@ private static final Set eventLoopKeys = new HashSet<>(); /** - * The runnable is responsible for leaving the nested event loop. + * The runnable is responsible for entering the nested event loop. + * + * @param nestedLoopKey the Object that identifies the nested event loop, + * which must not be null + * @param r {@code Runnable} to be invoked */ - static void runOnEDTAndWait(Object nestedLoopKey, Runnable r) { + public static void runOnEDTAndWait(Object nestedLoopKey, Runnable r) { Toolkit.getToolkit().checkFxUserThread(); if (SwingUtilities.isEventDispatchThread()) { @@ -335,7 +355,13 @@ } } - static void leaveFXNestedLoop(Object nestedLoopKey) { + /** + * The runnable is responsible for leaving the nested event loop. + * + * @param nestedLoopKey the Object that identifies the nested event loop, + * which must not be null + */ + public static void leaveFXNestedLoop(Object nestedLoopKey) { if (!eventLoopKeys.contains(nestedLoopKey)) return; if (Platform.isFxApplicationThread()) {