< prev index next >
modules/swing/src/main/java/javafx/embed/swing/JFXPanel.java
Print this page
rev 9568 : 8149967: Cannot compile JFXPanel with JDK 9: SurfaceData::getDefaultScale not found
*** 77,86 ****
--- 77,87 ----
import java.util.concurrent.atomic.AtomicInteger;
import sun.awt.AppContext;
import sun.awt.CausedFocusEvent;
import sun.awt.SunToolkit;
import sun.java2d.SunGraphics2D;
+ import sun.java2d.SurfaceData;
import sun.util.logging.PlatformLogger;
import sun.util.logging.PlatformLogger.Level;
/**
* {@code JFXPanel} is a component to embed JavaFX content into
*** 646,655 ****
--- 647,673 ----
InputMethodSupport.inputMethodEventComposed(t, e.getCommittedCharacterCount()),
t.substring(0, e.getCommittedCharacterCount()),
e.getCaret().getInsertionIndex());
}
+ // FIXME: once we move to JDK 9 as the boot JDK we should remove the
+ // reflection code from this method, consider changing it to
+ // use double rather than int, and account for the possibility of
+ // a different scale factor in X and Y.
+ private int getDefaultScale(SurfaceData surfaceData) {
+ /*
+ double scale = surfaceData.getDefaultScaleX();
+ */
+ double scale = 1;
+ try {
+ Method meth = SurfaceData.class.getMethod("getDefaultScaleX");
+ scale = (Double)meth.invoke(surfaceData);
+ } catch (Exception ex) {
+ }
+
+ return (int)Math.round(scale);
+ }
/**
* Overrides the {@link javax.swing.JComponent#paintComponent(Graphics)}
* method to paint the content of the JavaFX scene attached to this
* {@code JFXpanel}.
*** 687,697 ****
}
gg.drawImage(pixelsIm, 0, 0, pWidth, pHeight, null);
int newScaleFactor = scaleFactor;
if (g instanceof SunGraphics2D) {
! newScaleFactor = ((SunGraphics2D)g).surfaceData.getDefaultScale();
}
if (scaleFactor != newScaleFactor) {
createResizePixelBuffer(newScaleFactor);
// The scene will request repaint.
scenePeer.setPixelScaleFactor(newScaleFactor);
--- 705,715 ----
}
gg.drawImage(pixelsIm, 0, 0, pWidth, pHeight, null);
int newScaleFactor = scaleFactor;
if (g instanceof SunGraphics2D) {
! newScaleFactor = getDefaultScale(((SunGraphics2D)g).surfaceData);
}
if (scaleFactor != newScaleFactor) {
createResizePixelBuffer(newScaleFactor);
// The scene will request repaint.
scenePeer.setPixelScaleFactor(newScaleFactor);
< prev index next >