Handles scaling for high-res displays, also sets text anti-aliasing options to be far less ugly than the defaults. Moved to a utility function because it's used in several classes. @return a Graphics2D object, as a bit o sugar
(Graphics g)
| 740 | * @return a Graphics2D object, as a bit o sugar |
| 741 | */ |
| 742 | static public Graphics2D prepareGraphics(Graphics g) { |
| 743 | Graphics2D g2 = (Graphics2D) g; |
| 744 | |
| 745 | //float z = zoom * (Toolkit.isRetina() ? 2 : 1); |
| 746 | if (Toolkit.isRetina()) { |
| 747 | // scale everything 2x, will be scaled down when drawn to the screen |
| 748 | g2.scale(2, 2); |
| 749 | } |
| 750 | //g2.scale(z, z); |
| 751 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
| 752 | RenderingHints.VALUE_ANTIALIAS_ON); |
| 753 | g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, |
| 754 | RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
| 755 | g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
| 756 | RenderingHints.VALUE_INTERPOLATION_BICUBIC); |
| 757 | if (Toolkit.isRetina()) { |
| 758 | // Looks great on retina, not so great (with our font) on 1x |
| 759 | g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, |
| 760 | RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); |
| 761 | } |
| 762 | zoomStroke(g2); |
| 763 | return g2; |
| 764 | } |
| 765 | |
| 766 | |
| 767 | // /** |
no test coverage detected