modules/graphics/src/main/java/com/sun/javafx/stage/WindowHelper.java

Print this page




  39 
  40     static {
  41         forceInit(Window.class);
  42     }
  43 
  44     private WindowHelper() {
  45     }
  46 
  47     public static void notifyLocationChanged(final Window window,
  48                                              final double x,
  49                                              final double y) {
  50         windowAccessor.notifyLocationChanged(window, x, y);
  51     }
  52 
  53     public static void notifySizeChanged(final Window window,
  54                                          final double width,
  55                                          final double height) {
  56         windowAccessor.notifySizeChanged(window, width, height);
  57     }
  58 






  59     static AccessControlContext getAccessControlContext(Window window) {
  60         return windowAccessor.getAccessControlContext(window);
  61     }
  62 
  63     public static void setWindowAccessor(final WindowAccessor newAccessor) {
  64         if (windowAccessor != null) {
  65             throw new IllegalStateException();
  66         }
  67 
  68         windowAccessor = newAccessor;
  69     }
  70 
  71     public static WindowAccessor getWindowAccessor() {
  72         return windowAccessor;
  73     }
  74 
  75     public interface WindowAccessor {
  76         void notifyLocationChanged(Window window, double x, double y);
  77 
  78         void notifySizeChanged(Window window, double width, double height);
  79 
  80         void notifyScreenChanged(Window window, Object from, Object to);
  81 
  82         float getUIScale(Window window);
  83         float getRenderScale(Window window);


  84 
  85         ReadOnlyObjectProperty<Screen> screenProperty(Window window);
  86 
  87         AccessControlContext getAccessControlContext(Window window);
  88     }
  89 
  90     private static void forceInit(final Class<?> classToInit) {
  91         try {
  92             Class.forName(classToInit.getName(), true,
  93                           classToInit.getClassLoader());
  94         } catch (final ClassNotFoundException e) {
  95             throw new AssertionError(e);  // Can't happen
  96         }
  97     }
  98 }


  39 
  40     static {
  41         forceInit(Window.class);
  42     }
  43 
  44     private WindowHelper() {
  45     }
  46 
  47     public static void notifyLocationChanged(final Window window,
  48                                              final double x,
  49                                              final double y) {
  50         windowAccessor.notifyLocationChanged(window, x, y);
  51     }
  52 
  53     public static void notifySizeChanged(final Window window,
  54                                          final double width,
  55                                          final double height) {
  56         windowAccessor.notifySizeChanged(window, width, height);
  57     }
  58 
  59     public static void notifyScaleChanged(final Window window,
  60                                           final double newOutputScaleX,
  61                                           final double newOutputScaleY) {
  62         windowAccessor.notifyScaleChanged(window, newOutputScaleX, newOutputScaleY);
  63     }
  64 
  65     static AccessControlContext getAccessControlContext(Window window) {
  66         return windowAccessor.getAccessControlContext(window);
  67     }
  68 
  69     public static void setWindowAccessor(final WindowAccessor newAccessor) {
  70         if (windowAccessor != null) {
  71             throw new IllegalStateException();
  72         }
  73 
  74         windowAccessor = newAccessor;
  75     }
  76 
  77     public static WindowAccessor getWindowAccessor() {
  78         return windowAccessor;
  79     }
  80 
  81     public interface WindowAccessor {
  82         void notifyLocationChanged(Window window, double x, double y);
  83 
  84         void notifySizeChanged(Window window, double width, double height);
  85 
  86         void notifyScreenChanged(Window window, Object from, Object to);
  87 
  88         float getPlatformScaleX(Window window);
  89         float getPlatformScaleY(Window window);
  90 
  91         void notifyScaleChanged(Window window, double newOutputScaleX, double newOutputScaleY);
  92 
  93         ReadOnlyObjectProperty<Screen> screenProperty(Window window);
  94 
  95         AccessControlContext getAccessControlContext(Window window);
  96     }
  97 
  98     private static void forceInit(final Class<?> classToInit) {
  99         try {
 100             Class.forName(classToInit.getName(), true,
 101                           classToInit.getClassLoader());
 102         } catch (final ClassNotFoundException e) {
 103             throw new AssertionError(e);  // Can't happen
 104         }
 105     }
 106 }