public class BusyPainter extends AbstractPainter<Object>
Modifier and Type | Class and Description |
---|---|
static class |
BusyPainter.Direction
Direction is used to set the initial direction in which the
animation starts.
|
AbstractPainter.Interpolation
Modifier and Type | Field and Description |
---|---|
private Color |
baseColor |
private BusyPainter.Direction |
direction |
private int |
frame |
private Color |
highlightColor |
private boolean |
paintCentered |
private int |
points |
private Shape |
pointShape |
private int |
trailLength |
private Shape |
trajectory |
Constructor and Description |
---|
BusyPainter()
Creates new busy painter initialized to the shape of circle and bounds size 26x26 points.
|
BusyPainter(int height)
Creates new painter initialized to the shape of circle and bounds of square of specified height.
|
BusyPainter(Shape point,
Shape trajectory)
Initializes painter to the specified trajectory and and point shape.
|
Modifier and Type | Method and Description |
---|---|
private float |
calcCube(float[] coords,
Point2D.Float cp)
Claclulates length of the cubic segment.
|
private Color |
calcFrameColor(int i)
Selects appropriate color for given frame based on the frame position and gradient difference.
|
private float |
calcLengthOfQuad(float[] coords,
Point2D.Float cp)
Calculates length of the quadratic segment
|
private float |
calcLine(float[] coords,
Point2D.Float cp)
Calculates length of the linear segment.
|
private Point2D.Float |
calcPoint(float dist2go,
Point2D.Float startPoint,
float[] sgmt,
int w,
int h) |
protected void |
doPaint(Graphics2D g,
Object t,
int width,
int height)
Subclasses must implement this method and perform custom painting operations
here.
|
private void |
drawAt(Graphics2D g,
int i,
Point2D.Float p,
Point2D.Float c) |
Color |
getBaseColor()
Gets base color.
|
BusyPainter.Direction |
getDirection()
Gets current direction of spinning.
|
int |
getFrame()
Gets current frame.
|
Color |
getHighlightColor()
Gets highlight color.
|
int |
getPoints()
Gets total amount of distinct points in spinner.
|
Shape |
getPointShape()
Gets shape of current point.
|
protected static Shape |
getScaledDefaultPoint(int height) |
protected static Shape |
getScaledDefaultTrajectory(int height) |
int |
getTrailLength()
Gets length of trail in number of points.
|
Shape |
getTrajectory()
Gets current trajectory.
|
private Point2D.Float |
getXY(float t,
float x1,
float y1,
float x2,
float y2)
Calculates the XY point for a given t value.
|
static Point2D.Float |
getXY(float t,
Point2D.Float begin,
Point2D.Float ctrl,
Point2D.Float end)
Calculates relative position of the point on the quad curve in time t<0,1>.
|
protected void |
init(Shape point,
Shape trajectory,
Color baseColor,
Color highlightColor)
Initializes painter to provided shapes and default colors.
|
boolean |
isPaintCentered()
Gets value of centering hint.
|
private void |
paintRotatedCenteredShapeAtPoint(Point2D.Float p,
Point2D.Float c,
Graphics2D g) |
void |
setBaseColor(Color baseColor)
Sets new base color.
|
void |
setDirection(BusyPainter.Direction dir)
Sets new spinning direction.
|
void |
setFrame(int frame)
Sets current frame.
|
void |
setHighlightColor(Color highlightColor)
Sets new highlight color.
|
void |
setPaintCentered(boolean paintCentered)
Centers shape in the area covered by the painter.
|
void |
setPoints(int points)
Sets total amount of points in spinner.
|
void |
setPointShape(Shape pointShape)
Sets new point shape.
|
void |
setTrailLength(int trailLength)
Sets length of the trail in points.
|
void |
setTrajectory(Shape trajectory)
Sets new trajectory.
|
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 int frame
private int points
private Color highlightColor
private int trailLength
private Shape pointShape
private Shape trajectory
private BusyPainter.Direction direction
private boolean paintCentered
public BusyPainter()
public BusyPainter(int height)
height
- Painter height.public BusyPainter(Shape point, Shape trajectory)
point
- Point shape.trajectory
- Trajectory shape.protected static Shape getScaledDefaultTrajectory(int height)
protected static Shape getScaledDefaultPoint(int height)
protected void init(Shape point, Shape trajectory, Color baseColor, Color highlightColor)
point
- Point shape.trajectory
- Trajectory shape.protected void doPaint(Graphics2D g, Object t, int width, int height)
AbstractPainter
doPaint
in class AbstractPainter<Object>
g
- The Graphics2D object in which to paintpublic boolean isPaintCentered()
public void setPaintCentered(boolean paintCentered)
paintCentered
- Centering hint.private void drawAt(Graphics2D g, int i, Point2D.Float p, Point2D.Float c)
private void paintRotatedCenteredShapeAtPoint(Point2D.Float p, Point2D.Float c, Graphics2D g)
private Point2D.Float calcPoint(float dist2go, Point2D.Float startPoint, float[] sgmt, int w, int h)
private float calcLine(float[] coords, Point2D.Float cp)
coords
- Segment coordinates.cp
- Start point.private float calcCube(float[] coords, Point2D.Float cp)
coords
- Segment coordinates.cp
- Start point.private float calcLengthOfQuad(float[] coords, Point2D.Float cp)
coords
- Segment coordinatescp
- Start point.private Point2D.Float getXY(float t, float x1, float y1, float x2, float y2)
t
- parametric value for spline calculationpublic static Point2D.Float getXY(float t, Point2D.Float begin, Point2D.Float ctrl, Point2D.Float end)
t
- distance on the curvectrl
- Control point in rel coordsend
- End point in rel coordsprivate Color calcFrameColor(int i)
i
- Frame.public int getFrame()
public void setFrame(int frame)
frame
- Current frame.public Color getBaseColor()
public void setBaseColor(Color baseColor)
baseColor
- Base color.public Color getHighlightColor()
public void setHighlightColor(Color highlightColor)
highlightColor
- New highlight color.public int getPoints()
public void setPoints(int points)
points
- Total amount of points.public int getTrailLength()
public void setTrailLength(int trailLength)
trailLength
- Trail length in points.public final Shape getPointShape()
public final void setPointShape(Shape pointShape)
pointShape
- new Shape.public final Shape getTrajectory()
public final void setTrajectory(Shape trajectory)
trajectory
- New trajectory.public BusyPainter.Direction getDirection()
public void setDirection(BusyPainter.Direction dir)
dir
- Spinning direction.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses