Class BlurDecorator

  • All Implemented Interfaces:
    Decorator

    public class BlurDecorator
    extends java.lang.Object
    implements Decorator
    Decorator that applies a blur to a component.

    Blurs are given an integer magnitude, which represents the intensity of the blur. This value translates to a grid of pixels (blurMagnitude^2), where each pixel value is calculated by consulting its neighboring pixels according to the grid. Because of this, note that you will get "prettier" blurring if you choose odd values for the blur magnitude; this allows the pixel in question to reside at the center of the grid, thus preventing any arbitrary shifting of pixels. Also note that the greater the intensity of the blur, the greater the intensity of the calculations necessary to accomplish the blur (and the longer it will take to perform the blur).

    TODO Increase size of buffered image to account for edge conditions of the blur.

    TODO Use unequal values in the blur kernel to make pixels that are farther away count less towards the blur.

    • Constructor Summary

      Constructors 
      Constructor Description
      BlurDecorator()
      Creates a BlurDecorator with the default blur magnitude.
      BlurDecorator​(int blurMagnitude)
      Creates a BlurDecorator with the specified blur magnitude.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Graphics2D prepare​(Component component, java.awt.Graphics2D graphicsValue)
      Prepares the graphics context into which the component or prior decorator will paint.
      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

      • BlurDecorator

        public BlurDecorator()
        Creates a BlurDecorator with the default blur magnitude.
        See Also:
        BlurDecorator(int)
      • BlurDecorator

        public BlurDecorator​(int blurMagnitude)
        Creates a BlurDecorator with the specified blur magnitude.
        Parameters:
        blurMagnitude - The intensity of the blur.
    • Method Detail

      • prepare

        public java.awt.Graphics2D prepare​(Component component,
                                           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:
        component - 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