Activate text antialiasing as well as 2D primitive antialiasing, as requested

by Matt.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2505 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert
2008-12-17 17:48:35 +00:00
parent 87a4c07ce5
commit 31bc42b5aa
@@ -449,31 +449,30 @@ public class SwingUtil
} }
/** /**
* Activates anti-aliasing in the supplied graphics context. * Activates anti-aliasing in the supplied graphics context on both text and 2D drawing
* primitives.
* *
* @return an object that should be passed to {@link * @return an object that should be passed to {@link #restoreAntiAliasing} to restore the
* #restoreAntiAliasing} to restore the graphics context to its * graphics context to its original settings.
* original settings.
*/ */
public static Object activateAntiAliasing (Graphics2D gfx) public static Object activateAntiAliasing (Graphics2D gfx)
{ {
Object oalias = gfx.getRenderingHint( RenderingHints ohints = gfx.getRenderingHints(), nhints = new RenderingHints(null);
RenderingHints.KEY_ANTIALIASING); nhints.add(ohints);
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, nhints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints.VALUE_ANTIALIAS_ON); nhints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
return oalias; gfx.setRenderingHints(nhints);
return ohints;
} }
/** /**
* Restores anti-aliasing in the supplied graphics context to its * Restores anti-aliasing in the supplied graphics context to its original setting.
* original setting.
* *
* @param rock the results of a previous call to {@link * @param rock the results of a previous call to {@link #activateAntiAliasing}.
* #activateAntiAliasing}.
*/ */
public static void restoreAntiAliasing (Graphics2D gfx, Object rock) public static void restoreAntiAliasing (Graphics2D gfx, Object rock)
{ {
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rock); gfx.setRenderingHints((RenderingHints)rock);
} }
/** /**