test/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java

Print this page

        

*** 30,45 **** import java.awt.Image; import java.awt.Label; import java.awt.Point; import java.awt.TextArea; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.util.LinkedList; import java.util.List; import javax.swing.JApplet; import sun.awt.OSInfo; ! import sun.awt.image.MultiResolutionImage; /** * @test * @bug 8028212 * @summary [macosx] Custom Cursor HiDPI support --- 30,50 ---- import java.awt.Image; import java.awt.Label; import java.awt.Point; import java.awt.TextArea; import java.awt.Toolkit; + import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.util.LinkedList; import java.util.List; import javax.swing.JApplet; import sun.awt.OSInfo; ! import java.awt.image.MultiResolutionImage; ! import sun.awt.image.ImageResolutionHelper; ! import sun.awt.image.ImageResolutionHelperType; ! import static sun.awt.image.ImageResolutionHelperType.DPI_AWARE; ! import static sun.awt.image.ImageResolutionHelperType.TRANSFORM_AWARE; /** * @test * @bug 8028212 * @summary [macosx] Custom Cursor HiDPI support
*** 117,127 **** highResolutionImages.add(highResolutionImage); } } @Override ! public Image getResolutionVariant(int width, int height) { for (int i = 0; i < sizes.length; i++) { Image image = highResolutionImages.get(i); int w = image.getWidth(null); int h = image.getHeight(null); --- 122,140 ---- highResolutionImages.add(highResolutionImage); } } @Override ! public Image getResolutionVariant(float logicalDPIX, float logicalDPIY, ! float baseWidth, float baseHeight, float destWidth, float destHeight) { ! ImageResolutionHelper helper = getPlatformHelper(); ! float w = helper.getHiDPISize(logicalDPIX, baseWidth, destWidth); ! float h = helper.getHiDPISize(logicalDPIY, baseHeight, destHeight); ! return getResolutionVariant(w, h); ! } ! ! private Image getResolutionVariant(float width, float height) { for (int i = 0; i < sizes.length; i++) { Image image = highResolutionImages.get(i); int w = image.getWidth(null); int h = image.getHeight(null);
*** 143,152 **** --- 156,171 ---- @Override public List<Image> getResolutionVariants() { return highResolutionImages; } + + static ImageResolutionHelper getPlatformHelper() { + return OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) + ? DPI_AWARE : TRANSFORM_AWARE; + } + } }// class BlockedWindowTest /* Place other classes related to the test after this line */ /**