Package ca.cgjennings.graphics.filters
Class StrokeFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
java.awt.Color
getColor()
Returns the stroke colour as aColor
instance.int
getColorRGB()
Returns the stroke colour as an ARGB value.StrokeFilter.Position
getPosition()
Returns the position of the stroke relative to the edges in the image.int
getWidth()
Returns the width of the stroke effect, in pixels.boolean
isRoundedPen()
Returns whether the pen shape is rounded.void
setColor(java.awt.Color c)
Sets the stroke colour.void
setColorRGB(int argb)
Sets the stroke colour using an ARGB value.void
setPosition(StrokeFilter.Position position)
Sets the position of the stroke relative the edges in the image.void
setRoundedPen(boolean roundedPen)
Sets whether the pen shape is rounded.void
setWidth(int width)
Sets the width of the stroke effect, in pixels.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImageFilter
clamp, clamp, clamp, clampBoth, createCompatibleDestImage, fA, fB, fG, fR, getARGB, getARGB, getARGBSynch, getBounds2D, getPoint2D, getRenderingHints, iA, iB, iG, iR, setARGB, setARGB, setARGBSynch
-
-
-
-
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 integerwidth
- 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 aColor
objectwidth
- the pen width, in pixels- Throws:
java.lang.NullPointerException
- if the colour isnull
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 aColor
objectwidth
- the pen width, in pixelsposition
- the side of the edge to stroke- Throws:
java.lang.NullPointerException
- if the colour or position isnull
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 integerwidth
- the pen width, in pixelsposition
- the side of the edge to stroke- Throws:
java.lang.NullPointerException
- if the colour or position isnull
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 isnull
-
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 aColor
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)
-
-