Class ShadeDecorator

  • All Implemented Interfaces:
    Decorator

    public class ShadeDecorator
    extends java.lang.Object
    implements Decorator
    Decorator that applies a "shade" to a component. The shade is a rectangle of the same size as the component that is painted over the component using a given color and opacity value.
    • Constructor Summary

      Constructors 
      Constructor Description
      ShadeDecorator()
      Creates a new ShadeDecorator with the default opacity and shade color.
      ShadeDecorator​(float opacity, java.awt.Color color)
      Creates a new ShadeDecorator with the specified opacity and shade color.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Color getColor()  
      float getOpacity()  
      java.awt.Graphics2D prepare​(Component componentValue, java.awt.Graphics2D graphicsValue)
      Prepares the graphics context into which the component or prior decorator will paint.
      void setColor​(java.awt.Color color)
      Sets the color of the decorator.
      void setColor​(java.lang.String color)
      Sets the color of the decorator.
      void setOpacity​(float opacity)
      Sets the opacity of the decorator.
      void setOpacity​(java.lang.Number opacity)
      Sets the opacity of the decorator.
      void update()
      Updates the graphics context into which the component or prior decorator was painted.
      • Methods inherited from class java.lang.Object

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

      • ShadeDecorator

        public ShadeDecorator()
        Creates a new ShadeDecorator with the default opacity and shade color.
      • ShadeDecorator

        public ShadeDecorator​(float opacity,
                              java.awt.Color color)
        Creates a new ShadeDecorator with the specified opacity and shade color.
        Parameters:
        opacity - The opacity of the shade, between 0.0 and 1.0, exclusive.
        color - The color of the shade.
    • Method Detail

      • getOpacity

        public float getOpacity()
        Returns:
        The opacity of the decorator, in [0.0,1.0].
      • setOpacity

        public void setOpacity​(float opacity)
        Sets the opacity of the decorator.
        Parameters:
        opacity - A number between 0.0 (transparent) and 1.0 (opaque), exclusive.
      • setOpacity

        public void setOpacity​(java.lang.Number opacity)
        Sets the opacity of the decorator.
        Parameters:
        opacity - A number between 0.0 (transparent) and 1.0 (opaque), exclusive.
      • getColor

        public java.awt.Color getColor()
        Returns:
        The color of the decorator.
      • setColor

        public void setColor​(java.awt.Color color)
        Sets the color of the decorator.
        Parameters:
        color - The new color for the decorator.
      • setColor

        public final void setColor​(java.lang.String color)
        Sets the color of the decorator.
        Parameters:
        color - Any of the color values recognized by Pivot.
      • prepare

        public java.awt.Graphics2D prepare​(Component componentValue,
                                           java.awt.Graphics2D graphicsValue)
        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:
        componentValue - The component the decorator is attached to.
        graphicsValue - The graphics context to draw into.
        Returns:
        The graphics context that should be used by the component or prior decorators.
      • update

        public void update()
        Description copied from interface: Decorator
        Updates the graphics context into which the component or prior decorator was painted. This method is called immediately after Component.paint(Graphics2D); decorators are called in ascending order.

        This default version simply returns, without doing anything (often the appropriate thing to do).

        Specified by:
        update in interface Decorator