Class StrokeFilter

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp

    public final class StrokeFilter
    extends AbstractImageFilter
    An image filter that strokes the outline of the image shape. The stroke width, colour, and the side of the image edge which is stroked can all be configured by the filter user.

    In-place filtering: This filter does not support in-place filtering (the source and destination must be different).

    Since:
    3.0
    Author:
    Chris Jennings
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  StrokeFilter.Position
      An enumeration of the possible positions for the pen relative to the edges in the source image.
    • Constructor Summary

      Constructors 
      Constructor Description
      StrokeFilter()
      Creates a new stroke filter that strokes with a 4 pixel wide black pen along the outside of the image shape.
      StrokeFilter​(int color, int width)
      Creates a new stroke filter that strokes with the specified width and colour along the outside edge of the image shape.
      StrokeFilter​(int color, int width, StrokeFilter.Position position)
      Creates a new stroke filter that strokes with the specified width and colour along the specified edge of the image shape.
      StrokeFilter​(java.awt.Color color, int width)
      Creates a new stroke filter that strokes with the specified width and colour along the outside edge of the image shape.
      StrokeFilter​(java.awt.Color color, int width, StrokeFilter.Position position)
      Creates a new stroke filter that strokes with the specified width and colour along the specified edge of the image shape.
    • Constructor Detail

      • StrokeFilter

        public StrokeFilter()
        Creates a new stroke filter that strokes with a 4 pixel wide black pen along the outside of the image shape.
      • StrokeFilter

        public StrokeFilter​(int color,
                            int width)
        Creates a new stroke filter that strokes with the specified width and colour along the outside edge of the image shape.
        Parameters:
        color - the pen colour, as a 32-bit ARGB integer
        width - the pen width, in pixels
        Throws:
        java.lang.IllegalArgumentException - if the width is less than 1
      • StrokeFilter

        public StrokeFilter​(java.awt.Color color,
                            int width)
        Creates a new stroke filter that strokes with the specified width and colour along the outside edge of the image shape.
        Parameters:
        color - the pen colour, as a Color object
        width - the pen width, in pixels
        Throws:
        java.lang.NullPointerException - if the colour is null
        java.lang.IllegalArgumentException - if the width is less than 1
      • StrokeFilter

        public StrokeFilter​(java.awt.Color color,
                            int width,
                            StrokeFilter.Position position)
        Creates a new stroke filter that strokes with the specified width and colour along the specified edge of the image shape.
        Parameters:
        color - the pen colour, as a Color object
        width - the pen width, in pixels
        position - the side of the edge to stroke
        Throws:
        java.lang.NullPointerException - if the colour or position is null
        java.lang.IllegalArgumentException - if the width is less than 1
      • StrokeFilter

        public StrokeFilter​(int color,
                            int width,
                            StrokeFilter.Position position)
        Creates a new stroke filter that strokes with the specified width and colour along the specified edge of the image shape.
        Parameters:
        color - the pen colour, as a 32-bit ARGB integer
        width - the pen width, in pixels
        position - the side of the edge to stroke
        Throws:
        java.lang.NullPointerException - if the colour or position is null
        java.lang.IllegalArgumentException - if the width is less than 1
    • Method Detail

      • getPosition

        public StrokeFilter.Position getPosition()
        Returns the position of the stroke relative to the edges in the image.
        Returns:
        whether the stroke falls outside, inside, or on the image edge
      • setPosition

        public void setPosition​(StrokeFilter.Position position)
        Sets the position of the stroke relative the edges in the image.
        Parameters:
        position - whether the stroke falls outside, inside, or on the image edge
        Throws:
        java.lang.NullPointerException - if the position is null
      • setWidth

        public void setWidth​(int width)
        Sets the width of the stroke effect, in pixels.
        Parameters:
        width - the radius of the stroke effect
      • getWidth

        public int getWidth()
        Returns the width of the stroke effect, in pixels.
        Returns:
        the radius of the stroke effect
      • setColorRGB

        public void setColorRGB​(int argb)
        Sets the stroke colour using an ARGB value.
        Parameters:
        argb - the stroke colour
      • getColorRGB

        public int getColorRGB()
        Returns the stroke colour as an ARGB value.
        Returns:
        the ARGB value of the stroke colour
      • setColor

        public void setColor​(java.awt.Color c)
        Sets the stroke colour.
        Parameters:
        c - the stroke colour
      • getColor

        public java.awt.Color getColor()
        Returns the stroke colour as a Color instance.
        Returns:
        the stroke colour
      • setRoundedPen

        public void setRoundedPen​(boolean roundedPen)
        Sets whether the pen shape is rounded.
        Parameters:
        roundedPen - true if the pen is rounded; false if the pen is squared
      • isRoundedPen

        public boolean isRoundedPen()
        Returns whether the pen shape is rounded.
        Returns:
        true if the pen is rounded; false if the pen is squared
      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dest)