Class GraphicsUtil


  • public final class GraphicsUtil
    extends java.lang.Object
    GraphicsUtil
    Version:
    $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/image/GraphicsUtil.java#1 $
    Author:
    Harald Kuhr, last modified by $Author: haku $
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphicsUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void enableAA​(java.awt.Graphics pGraphics)
      Enables anti-aliasing in the Graphics object.
      static void setAlpha​(java.awt.Graphics pGraphics, float pAlpha)
      Sets the alpha in the Graphics object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GraphicsUtil

        public GraphicsUtil()
    • Method Detail

      • enableAA

        public static void enableAA​(java.awt.Graphics pGraphics)
        Enables anti-aliasing in the Graphics object.

        Anti-aliasing is enabled by casting to Graphics2D and setting the rendering hint RenderingHints.KEY_ANTIALIASING to RenderingHints.VALUE_ANTIALIAS_ON.

        Parameters:
        pGraphics - the graphics object
        Throws:
        java.lang.ClassCastException - if pGraphics is not an instance of Graphics2D.
        See Also:
        RenderingHints.KEY_ANTIALIASING
      • setAlpha

        public static void setAlpha​(java.awt.Graphics pGraphics,
                                    float pAlpha)
        Sets the alpha in the Graphics object.

        Alpha is set by casting to Graphics2D and setting the composite to the rule AlphaComposite.SRC_OVER multiplied by the given alpha.

        Parameters:
        pGraphics - the graphics object
        pAlpha - the alpha level, alpha must be a floating point number in the inclusive range [0.0, 1.0].
        Throws:
        java.lang.ClassCastException - if pGraphics is not an instance of Graphics2D.
        See Also:
        AlphaComposite.SRC_OVER, AlphaComposite.getInstance(int, float)