public class PinstripePainter extends AbstractPainter<Object>
A fun Painter that paints pinstripes. You can specify the Paint to paint those pinstripes in (could even be a texture paint!), the angle at which to paint the pinstripes, and the spacing between stripes.
The default PinstripePainter configuration will paint the pinstripes using the foreground color of the component (the default behavior if a Paint is not specified) at a 45 degree angle with 8 pixels between stripes
Here is a custom code snippet that paints Color.GRAY pinstripes at a 135 degree angle:
PinstripePainter p = new PinstripePainter();
p.setAngle(135);
p.setPaint(Color.GRAY);
AbstractPainter.Interpolation
Modifier and Type | Field and Description |
---|---|
private double |
angle
The angle in degrees to paint the pinstripes at.
|
private Paint |
paint
The Paint to use when drawing the pinstripes
|
private double |
spacing
The spacing between pinstripes
|
private double |
stripeWidth
The stroke width of the pinstripes
|
Constructor and Description |
---|
PinstripePainter()
Create a new PinstripePainter.
|
PinstripePainter(double angle)
Create a new PinstripePainter using the given angle, 8 pixel spacing,
and the foreground color of the Component
|
PinstripePainter(Paint paint)
Create a new PinstripePainter using an angle of 45, 8 pixel spacing,
and the given Paint.
|
PinstripePainter(Paint paint,
double angle)
Create a new PinstripePainter using the given angle, 8 pixel spacing,
and the given Paint
|
PinstripePainter(Paint paint,
double angle,
double stripeWidth,
double spacing)
Create a new PinstripePainter with the specified paint, angle, stripe width, and stripe spacing.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doPaint(Graphics2D g,
Object component,
int width,
int height)
Subclasses must implement this method and perform custom painting operations
here.
|
double |
getAngle()
Gets the current angle of the pinstripes
|
Paint |
getPaint()
Get the current paint used for drawing the pinstripes
|
double |
getSpacing()
Get the current spacing between the stripes
|
double |
getStripeWidth()
Gets the current width of the pinstripes
|
void |
setAngle(double angle)
Sets the angle, in degrees, at which to paint the pinstripes.
|
void |
setPaint(Paint p)
Set the paint to use for drawing the pinstripes
|
void |
setSpacing(double spacing)
Sets the spacing between pinstripes
|
void |
setStripeWidth(double stripeWidth)
Set the width of the pinstripes
|
clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isCacheCleared, isDirty, isInPaintContext, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInPaintContext, setInterpolation, setVisible, shouldUseCache, validate
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
private double angle
private double spacing
private double stripeWidth
public PinstripePainter()
public PinstripePainter(Paint paint)
paint
- the paint used when drawing the stripespublic PinstripePainter(Paint paint, double angle)
paint
- the paint used when drawing the stripesangle
- the angle, in degrees, in which to paint the pinstripespublic PinstripePainter(double angle)
angle
- the angle, in degrees, in which to paint the pinstripespublic PinstripePainter(Paint paint, double angle, double stripeWidth, double spacing)
paint
- angle
- stripeWidth
- spacing
- public void setPaint(Paint p)
p
- the Paint to use. May be a Color.public Paint getPaint()
public void setAngle(double angle)
angle
- the Angle in degrees at which to paint the pinstripespublic double getAngle()
public void setSpacing(double spacing)
spacing
- spacing between pinstripespublic double getSpacing()
protected void doPaint(Graphics2D g, Object component, int width, int height)
doPaint
in class AbstractPainter<Object>
g
- The Graphics2D object in which to paintpublic double getStripeWidth()
public void setStripeWidth(double stripeWidth)
stripeWidth
- a new width for the pinstripesWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses