org.jdesktop.swingx.painter
Class BusyPainter

java.lang.Object
  extended by org.jdesktop.beans.AbstractBean
      extended by org.jdesktop.swingx.painter.AbstractPainter<Object>
          extended by org.jdesktop.swingx.painter.BusyPainter
All Implemented Interfaces:
Painter<Object>

public class BusyPainter
extends AbstractPainter<Object>

A specific painter that paints an "infinite progress" like animation. For more details see JXBusyLabel


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractPainter
AbstractPainter.Interpolation
 
Constructor Summary
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.
 
Method Summary
protected  void doPaint(Graphics2D g, Object t, int width, int height)
          Subclasses must implement this method and perform custom painting operations here.
 Color getBaseColor()
          Gets base color.
 JXBusyLabel.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.
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.
protected  Shape provideShape(Graphics2D g, Object comp, int width, int height)
           
 void setBaseColor(Color baseColor)
          Sets new base color.
 void setDirection(JXBusyLabel.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.
 
Methods inherited from class org.jdesktop.swingx.painter.AbstractPainter
clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validate
 
Methods inherited from class org.jdesktop.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BusyPainter

public BusyPainter()
Creates new busy painter initialized to the shape of circle and bounds size 26x26 points.


BusyPainter

public BusyPainter(int height)
Creates new painter initialized to the shape of circle and bounds of square of specified height.

Parameters:
height - Painter height.

BusyPainter

public BusyPainter(Shape point,
                   Shape trajectory)
Initializes painter to the specified trajectory and and point shape. Bounds are dynamically calculated to so the specified trajectory fits in.

Parameters:
point - Point shape.
trajectory - Trajectory shape.
Method Detail

getScaledDefaultTrajectory

protected static Shape getScaledDefaultTrajectory(int height)

getScaledDefaultPoint

protected static Shape getScaledDefaultPoint(int height)

init

protected void init(Shape point,
                    Shape trajectory,
                    Color baseColor,
                    Color highlightColor)
Initializes painter to provided shapes and default colors.

Parameters:
point - Point shape.
trajectory - Trajectory shape.

doPaint

protected void doPaint(Graphics2D g,
                       Object t,
                       int width,
                       int height)
Description copied from class: AbstractPainter
Subclasses must implement this method and perform custom painting operations here.

Specified by:
doPaint in class AbstractPainter<Object>
Parameters:
g - The Graphics2D object in which to paint

isPaintCentered

public boolean isPaintCentered()
Gets value of centering hint. If true, shape will be positioned in the center of painted area.

Returns:
Whether shape will be centered over painting area or not.

getXY

public 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>.

Parameters:
t - distance on the curve
ctrl - Control point in rel coords
end - End point in rel coords
Returns:
Solution of the quad equation for time T in non complex space in rel coords.

getFrame

public int getFrame()
Gets current frame.

Returns:
Current frame.

setFrame

public void setFrame(int frame)
Sets current frame.

Parameters:
frame - Current frame.

getBaseColor

public Color getBaseColor()
Gets base color.

Returns:
Base color.

setBaseColor

public void setBaseColor(Color baseColor)
Sets new base color. Bound property.

Parameters:
baseColor - Base color.

getHighlightColor

public Color getHighlightColor()
Gets highlight color.

Returns:
Current highlight color.

setHighlightColor

public void setHighlightColor(Color highlightColor)
Sets new highlight color. Bound property.

Parameters:
highlightColor - New highlight color.

getPoints

public int getPoints()
Gets total amount of distinct points in spinner.

Returns:
Total amount of points.

setPoints

public void setPoints(int points)
Sets total amount of points in spinner. Bound property.

Parameters:
points - Total amount of points.

getTrailLength

public int getTrailLength()
Gets length of trail in number of points.

Returns:
Trail lenght.

setTrailLength

public void setTrailLength(int trailLength)
Sets length of the trail in points. Bound property.

Parameters:
trailLength - Trail length in points.

getPointShape

public final Shape getPointShape()
Gets shape of current point.

Returns:
Shape of the point.

setPointShape

public final void setPointShape(Shape pointShape)
Sets new point shape. Bound property.

Parameters:
pointShape - new Shape.

getTrajectory

public final Shape getTrajectory()
Gets current trajectory.

Returns:
Current spinner trajectory .

setTrajectory

public final void setTrajectory(Shape trajectory)
Sets new trajectory. Expected trajectory have to be closed shape. Bound property.

Parameters:
trajectory - New trajectory.

setDirection

public void setDirection(JXBusyLabel.Direction dir)
Sets new spinning direction.

Parameters:
dir - Spinning direction.

getDirection

public JXBusyLabel.Direction getDirection()
Gets current direction of spinning.

Returns:
Current spinning direction.

provideShape

protected Shape provideShape(Graphics2D g,
                             Object comp,
                             int width,
                             int height)

setPaintCentered

public void setPaintCentered(boolean paintCentered)
Centers shape in the area covered by the painter.

Parameters:
paintCentered - Centering hint.