public static boolean hasRetinaDisplay() { Object obj = Toolkit.getDefaultToolkit() .getDesktopProperty("apple.awt.contentScaleFactor"); if (obj instanceof Float) { Float f = (Float) obj; int scale = f.intValue(); return (scale == 2); } return false; } }
getDesktopProperty("awt.multiClickInterval");
/** * Returns the rendering hints for text that will most accurately reflect * those of the native windowing system. * * @return The rendering hints, or <code>null</code> if they cannot be * determined. */ public static Map<?,?> getDesktopAntiAliasHints() { return (Map<?,?>)Toolkit.getDefaultToolkit(). getDesktopProperty("awt.font.desktophints"); }
public static final boolean gtkShouldAntialias() { if (gtkAA == null) { Object o = Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/Antialias"); //NOI18N gtkAA = new Integer(1).equals(o) ? Boolean.TRUE : Boolean.FALSE; } return gtkAA.booleanValue(); } }
@SuppressWarnings("unchecked") static final Map<?,?> getHints() { //XXX We REALLY need to put this in a graphics utils lib if (hintsMap == null) { //Thanks to Phil Race for making this possible hintsMap = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N if (hintsMap == null) { hintsMap = new HashMap<Object,Object>(); if (antialias) { hintsMap.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } } } Map<?,?> ret = hintsMap; assert ret != null; // does this method need to be synchronized? return ret; }
private void configureGraphics(Graphics2D g) { Map<?, ?> desktopHints = (Map<?, ?>) Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); if(desktopHints != null) { g.setRenderingHints(desktopHints); } g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); }
private static boolean isWindowsXPLaF() { Boolean isXP = (Boolean) Toolkit.getDefaultToolkit(). getDesktopProperty("win.xpstyle.themeActive"); //NOI18N return isWindowsLaF() && (isXP == null ? false : isXP.booleanValue()); }
String str = "A quick brown fox jumps over the lazy dog"; Toolkit tk = Toolkit.getDefaultToolkit(); Map desktopHints = (Map)(tk.getDesktopProperty("awt.font.desktophints")); Graphics2D g2d = (Graphics2D)g; if(desktopHints != null) { g2d.addRenderingHints(desktopHints); } g2d.drawString(str, someX, someY);
/** * Checks and answers whether the Windows XP style is enabled. * This method is intended to be called only if a Windows look&feel * is about to be installed or already active in the UIManager. * The XP style of the Windows look&feel is enabled by default on * Windows XP platforms since the J2SE 1.4.2; it can be disabled either * in the Windows desktop as well as in the Java runtime by setting * a System property.<p> * * First checks the platform, platform version and Java version. Then * checks whether the desktop property <tt>win.xpstyle.themeActive</tt> * is set or not. * * @return true if the Windows XP style is enabled */ private static boolean isWindowsXPLafEnabled() { return IS_OS_WINDOWS && Boolean.TRUE.equals(Toolkit.getDefaultToolkit(). getDesktopProperty("win.xpstyle.themeActive")) && getSystemProperty("swing.noxp") == null; }
/** * Get the singleton instance of this class * * @return the singleton instance of this class or null if XP styles * are not active or if this is not Windows XP */ static synchronized XPStyle getXP() { if (themeActive == null) { Toolkit toolkit = Toolkit.getDefaultToolkit(); themeActive = (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive"); if (themeActive == null) { themeActive = Boolean.FALSE; } if (themeActive.booleanValue()) { GetPropertyAction propertyAction = new GetPropertyAction("swing.noxp"); if (AccessController.doPrivileged(propertyAction) == null && ThemeReader.isThemed() && !(UIManager.getLookAndFeel() instanceof WindowsClassicLookAndFeel)) { xp = new XPStyle(); } } } return xp; }
&& !(Boolean) Toolkit.getDefaultToolkit().getDesktopProperty( "win.xpstyle.themeActive");
if (desktopHints == null) { Toolkit tk = Toolkit.getDefaultToolkit(); desktopHints = (Map) (tk.getDesktopProperty("awt.font.desktophints")); } if (desktopHints != null) { g2d.addRenderingHints(desktopHints); }
/** * Looks up and returns a font using the default toolkit's desktop * properties. * * @param fontName * the name of the font to return * @return the font */ private static Font getDesktopFont(String fontName) { Toolkit toolkit = Toolkit.getDefaultToolkit(); return (Font) toolkit.getDesktopProperty(fontName); }
/** * For JDK6 we have a dedicated property which does not allow to understand anything * per device but could be useful for image creation. We will get true in case * if at least one retina device is present. */ private static boolean hasAppleRetinaDevice() { return (Float) Toolkit.getDefaultToolkit() .getDesktopProperty( "apple.awt.contentScaleFactor") != 1.0f; }
public static int getDoubleClickInterval() { if (doubleClickInterval < 0) { Number obj = (Number) Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"); if (obj != null) { doubleClickInterval = obj.intValue(); } else { doubleClickInterval = DEFAULT_DOUBLE_CLICK_INTERVAL; } } return doubleClickInterval; }
/** * Determines whether the user is on Windows and if so whether the "high contrast" setting * is set to on. * * @return {@code true} if on, otherwise {@code false} */ public static boolean isHighContrastOn() { Toolkit toolkit = Toolkit.getDefaultToolkit(); Optional<Boolean> highContrast = Optional.ofNullable((Boolean) toolkit.getDesktopProperty("win.highContrast.on")); return highContrast.orElse(false); }
public static final boolean gtkShouldAntialias() { if (gtkAA == null) { Object o = Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/Antialias"); //NOI18N gtkAA = Boolean.valueOf(Integer.valueOf(1).equals(o)); } return gtkAA.booleanValue(); }
private static Graphics2D prepareGraphics(Graphics g) { Graphics2D g2 = (Graphics2D) g; Map rhints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N if( rhints == null && Boolean.getBoolean("swing.aatext") ) { //NOI18N g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON ); } else if( rhints != null ) { g2.addRenderingHints( rhints ); } return g2; }
public static Graphics getAliasedGraphics (Graphics g) { Map<RenderingHints.Key, Object> hints = (Map<RenderingHints.Key, Object>) Toolkit.getDefaultToolkit ().getDesktopProperty ("awt.font.desktophints"); hints.put (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Graphics2D g2d = (Graphics2D) g; g2d.addRenderingHints (hints); //g2d.addRenderingHints (new RenderingHints (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); return g2d; } }
Graphics2D g2 = (Graphics2D)g.create(); Toolkit toolkit = Toolkit.getDefaultToolkit(); Map map = (Map)(toolkit.getDesktopProperty("awt.font.desktophints")); if (map != null) { g2.addRenderingHints(map); } g2.drawString(...); g2.dispose();