Class DropShadowDecorator

  • All Implemented Interfaces:
    Decorator

    public class DropShadowDecorator
    extends java.lang.Object
    implements Decorator
    Decorator that adds a drop shadow to a component.
    • Constructor Summary

      Constructors 
      Constructor Description
      DropShadowDecorator()
      Default constructor with values of 3, 3, 3.
      DropShadowDecorator​(int radius, int xOff, int yOff)
      Construct using non-default values of radius and offsets.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getBlurRadius()  
      Bounds getBounds​(Component component)
      Returns the bounding area of the decorator.
      java.awt.Color getShadowColor()  
      float getShadowOpacity()
      Returns the opacity used to draw the shadow.
      int getXOffset()
      Returns the amount that the drop shadow will be offset along the x axis.
      int getYOffset()
      Returns the amount that the drop shadow will be offset along the y axis.
      java.awt.Graphics2D prepare​(Component component, java.awt.Graphics2D graphics)
      Prepares the graphics context into which the component or prior decorator will paint.
      void setBlurRadius​(int radius)
      Sets the blur radius used to draw the shadow.
      void setShadowColor​(java.awt.Color colorValue)
      Sets the color used to draw the shadow.
      void setShadowColor​(java.lang.String shadowColorString)
      Sets the color used to draw the shadow.
      void setShadowOpacity​(float opacity)
      Sets the opacity used to draw the shadow.
      void setXOffset​(int xOff)
      Sets the amount that the drop shadow will be offset along the x axis.
      void setYOffset​(int yOff)
      Sets the amount that the drop shadow will be offset along the y axis.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_SHADOW_OPACITY

        public static final float DEFAULT_SHADOW_OPACITY
        See Also:
        Constant Field Values
    • Constructor Detail

      • DropShadowDecorator

        public DropShadowDecorator()
        Default constructor with values of 3, 3, 3.
      • DropShadowDecorator

        public DropShadowDecorator​(int radius,
                                   int xOff,
                                   int yOff)
        Construct using non-default values of radius and offsets.
        Parameters:
        radius - The radius to blur around the component.
        xOff - X-offset for the blurring to occur.
        yOff - Y-offset of the blurring.
    • Method Detail

      • getShadowColor

        public java.awt.Color getShadowColor()
        Returns:
        The color used to draw the shadow.
      • setShadowColor

        public void setShadowColor​(java.awt.Color colorValue)
        Sets the color used to draw the shadow.
        Parameters:
        colorValue - The color used to draw the shadow.
      • setShadowColor

        public final void setShadowColor​(java.lang.String shadowColorString)
        Sets the color used to draw the shadow.
        Parameters:
        shadowColorString - The color used to draw the shadow, which can be any of the color values recognized by Pivot.
      • getShadowOpacity

        public float getShadowOpacity()
        Returns the opacity used to draw the shadow.
        Returns:
        The color used to draw the shadow.
      • setShadowOpacity

        public void setShadowOpacity​(float opacity)
        Sets the opacity used to draw the shadow.
        Parameters:
        opacity - The opacity used to draw the shadow.
      • getBlurRadius

        public int getBlurRadius()
        Returns:
        The blur radius used to draw the shadow.
      • setBlurRadius

        public void setBlurRadius​(int radius)
        Sets the blur radius used to draw the shadow.
        Parameters:
        radius - The blur radius used to draw the shadow.
      • getXOffset

        public int getXOffset()
        Returns the amount that the drop shadow will be offset along the x axis.
        Returns:
        The x offset used to draw the shadow.
      • setXOffset

        public void setXOffset​(int xOff)
        Sets the amount that the drop shadow will be offset along the x axis.
        Parameters:
        xOff - The x offset used to draw the shadow.
      • getYOffset

        public int getYOffset()
        Returns the amount that the drop shadow will be offset along the y axis.
        Returns:
        The y offset used to draw the shadow.
      • setYOffset

        public void setYOffset​(int yOff)
        Sets the amount that the drop shadow will be offset along the y axis.
        Parameters:
        yOff - The y offset used to draw the shadow.
      • prepare

        public java.awt.Graphics2D prepare​(Component component,
                                           java.awt.Graphics2D graphics)
        Description copied from interface: Decorator
        Prepares the graphics context into which the component or prior decorator will paint. This method is called immediately prior to Component.paint(Graphics2D); decorators are called in descending order.
        Specified by:
        prepare in interface Decorator
        Parameters:
        component - The component the decorator is attached to.
        graphics - The graphics context to draw into.
        Returns:
        The graphics context that should be used by the component or prior decorators.
      • getBounds

        public Bounds getBounds​(Component component)
        Description copied from interface: Decorator
        Returns the bounding area of the decorator.

        This default simply returns the bounds of the component's size.

        Specified by:
        getBounds in interface Decorator
        Parameters:
        component - The component that the decorator is attached to.
        Returns:
        The decorator's bounds, relative to the component's origin.