Sets the Graphics2D instance's anti-alias feature. - Java 2D Graphics

Java examples for 2D Graphics:Graphics

Description

Sets the Graphics2D instance's anti-alias feature.

Demo Code


//package com.java2s;

import java.awt.Graphics2D;
import java.awt.RenderingHints;

public class Main {
    /**//from  w  ww . java  2 s  .co m
     * Sets the Graphics2D instance's anti-alias feature.
     * 
     * @param g2d
     * @param use
     */
    public static void setAntiAlias(Graphics2D g2d, boolean use) {
        if (use) {
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
        } else {
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_OFF);
        }
    }
}

Related Tutorials