Java Graphics Settings setRenderingHints(Graphics2D g2d)

Here you can find the source of setRenderingHints(Graphics2D g2d)

Description

set Rendering Hints

License

Apache License

Declaration

public static void setRenderingHints(Graphics2D g2d) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Graphics2D;

import java.awt.RenderingHints;

public class Main {
    public static void setRenderingHints(Graphics2D g2d) {
        // This time, we want to use anti-aliasing if possible to avoid the
        // jagged edges
        // With the Java 2D rendering engine (Graphics2D) to do this using a
        // "rendering hint".
        RenderingHints rh = g2d.getRenderingHints();
        rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        // rh.put(RenderingHints.KEY_COLOR_RENDERING,
        // RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        // rh.put(RenderingHints.KEY_ALPHA_INTERPOLATION,
        // RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        // rh.put(RenderingHints.KEY_TEXT_ANTIALIASING,
        // RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        // rh.put(RenderingHints.KEY_FRACTIONALMETRICS,
        // RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        g2d.setRenderingHints(rh);// w ww.  j a  va2 s  .  co m
    }
}

Related

  1. getTransparentGraphicsConfiguration()
  2. gradientFillShape(Graphics2D g, Color startColor, Color endColor, Shape shape)
  3. gradientPaint(Graphics2D g2d, Point2D startPosition, Color startColor, Point2D endPosition, Color endColor, int sx, int sy, int ex, int ey)
  4. setClip(Graphics g, Rectangle clipBounds)
  5. setRenderingHints(Graphics2D g)
  6. setTextRenderingHints(Graphics2D g2d)
  7. setupGraphics(Graphics2D pG2d)