void (Graphics g2, boolean enableAA, boolean ignoreSystemSettings) { if (g2 instanceof Graphics2D g) { Toolkit tk = Toolkit.getDefaultToolkit(); Map<?, ?> map = (Map<?, ?>)tk.getDesktopProperty(DESKTOP_HINTS); if (map != null && !ignoreSystemSettings) { g.addRenderingHints(map); } else { Object hint = enableAA ? RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF; g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, hint); } } }