Java Graphics Draw useAntiAliasing(Graphics2D g)

Here you can find the source of useAntiAliasing(Graphics2D g)

Description

Tell the G to use anti aliased drawing and text

License

Open Source License

Return

old AA

Declaration

public static Object useAntiAliasing(Graphics2D g) 

Method Source Code

//package com.java2s;
/*/*from w w w . j  a v a2  s.  c  o m*/
 * Copyright (c) 2014 tabletoptool.com team.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     rptools.com team - initial implementation
 *     tabletoptool.com team - further development
 */

import java.awt.Graphics2D;

import java.awt.RenderingHints;

import javax.swing.JComponent;

public class Main {
    public static void useAntiAliasing(JComponent component) {
        component.putClientProperty("AATextPropertyKey", true);
    }

    /**
     * Tell the G to use anti aliased drawing and text
     * @return old AA
     */
    public static Object useAntiAliasing(Graphics2D g) {
        Object oldAA = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        return oldAA;
    }
}

Related

  1. printAll(java.awt.Graphics2D g2, java.awt.Component component)
  2. raiseOval(Graphics2D g2, Rectangle r, Color foreColor)
  3. raiseRect(Graphics2D g2, Rectangle r, Color foreColor)
  4. renderByLineGraphics(JComponent c, Graphics g)
  5. renderGraphics(JComponent c, Graphics g)