package eg.utils;

import java.awt.Dimension;
import java.awt.Toolkit;

/**
 * Static methods to obtain quantities that depend on the screen resolution
 */
public class ScreenParams {
   
  /**
   * The screen size */
   public final static Dimension SCREEN_SIZE
        = Toolkit.getDefaultToolkit().getScreenSize();
   
   /**
    * Returns the Dimension with the specified width and height scaled
    * to the ratio between screen resolution and graphic resolution
    *
    * @param width  the width in pt
    * @param height  the height in pt
    * @return   a new scaled Dimension
    */
   public static Dimension scaledDimension(int width, int height) {
      width = scaledSize(width);
      height = scaledSize(height);
      return new Dimension(width, height);
   }
  
   /**
    * Returns an integer that is the rounded product of the specified
    * size and the ratio between the screen resolution and the resolution
    * assumed by Java's Graphics2D
    *
    * @param size  the size
    * @return  the rounded rescaled size
    */
   public static int scaledSize(double size) {
      if (IS_JAVA_9) {
         return (int) (Math.round(size * 96/72));
      }
      else {
         return (int) (Math.round(size * SCREEN_RES_RATIO));
      }
   }
   
   public final static boolean IS_JAVA_9 = System.getProperty("java.version").startsWith("9");
   
   private final static int SCREEN_RES
        = Toolkit.getDefaultToolkit().getScreenResolution();

   private final static double SCREEN_RES_RATIO = SCREEN_RES / 72.0;
}

@@ -79,16 +79,30 @@
  Static 
+constants and 
 methods 
@@ -139,32 +139,44 @@
 nd on the screen
+ size and%0A *
  resolution%0A */%0A
@@ -207,16 +207,402 @@
 s %7B%0A   %0A
+   public final static boolean IS_WINDOWS%0A         = System.getProperty(%22os.name%22).toLowerCase().contains(%22win%22);%0A   private final static boolean IS_JAVA_9 = System.getProperty(%22java.version%22).startsWith(%229%22);  %0A   private final static int SCREEN_RES%0A         = Toolkit.getDefaultToolkit().getScreenResolution();%0A   private final static double SCREEN_RES_RATIO = SCREEN_RES / 72.0;%0A   %0A
   /**%0A  
@@ -1262,22 +1262,16 @@
 pecified
-%0A    *
  size an
@@ -1271,34 +1271,68 @@
 size and
- the ratio between
+%0A    * the resolution ratio.%3Cbr%3E%0A    * This ratio is
  the scr
@@ -1346,19 +1346,26 @@
 olution 
-and
+divided by
  the res
@@ -1371,22 +1371,16 @@
 solution
-%0A    *
  assumed
@@ -1389,16 +1389,22 @@
 y Java's
+%0A    *
  Graphic
@@ -1406,16 +1406,173 @@
 aphics2D
+ (72 dpi). However, when the program is run using Java 9 the resolution%0A    * ratio is constantly 96/72 when the operating system is Windows and 1 otherwise.
 %0A    *%0A 
@@ -1712,24 +1712,54 @@
 S_JAVA_9) %7B%0A
+         if (IS_WINDOWS) %7B%0A   
          ret
@@ -1802,18 +1802,24 @@
 ;%0A      
+ 
-%7D%0A
+  %7D%0A   
       el
@@ -1824,32 +1824,35 @@
 else %7B%0A         
+   
 return (int) (Ma
@@ -1852,53 +1852,20 @@
 nt) 
-(Math.round(size * SCREEN_RES_RATIO))
+size
 ;%0A      
 %7D%0A  
@@ -1864,18 +1864,16 @@
     
-%7D%0A
    %7D%0A   
 %0A   
@@ -1872,276 +1872,98 @@
 %0A   
-%0A
    
-public final static boolean IS_JAVA_9 = System.getProperty(%22java.version%22).startsWith(%229%22);
+%7D
 %0A   
-%0A
    
-private final static int SCREEN_RES%0A        = Toolkit.getDefaultToolkit().getScreenResolution();%0A%0A   private final static double SCREEN_RES_RATIO = SCREEN_RES / 72.0;
+else %7B%0A         return (int) (Math.round(size * SCREEN_RES_RATIO));%0A      %7D%0A   %7D
 %0A%7D%0A

modify scaling when java 9 is used