public class TimerView extends Object implements FrameParticipant, HierarchyListener
| Constructor and Description |
|---|
TimerView(FrameManager fmgr,
JComponent host,
Rectangle bounds)
Constructs a timer view that fires at the default rate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
changeComplete(float complete)
Generate an unexpected change in the timer's completion and
set up the necessary details to render interpolation from the old
to new states
|
void |
checkFrameParticipation()
Check that the frame knows about the timer.
|
Component |
getComponent()
If a frame participant wishes also to be actively rendered every
frame rather than use passive rendering (which for Swing, at least,
is hijacked when using the frame manager such that we take care of
repainting dirty Swing components every frame into our off-screen
buffer), it can return a component here which will have
Component.paint(java.awt.Graphics) called on it once per frame with a translated but
unclipped graphics object. |
long |
getTransitionTime()
Get the amount of time it takes to render digital changes in the
completion state.
|
void |
hierarchyChanged(HierarchyEvent e) |
boolean |
needsPaint()
Called immediately prior to
FrameParticipant.getComponent() and then Component.paint(java.awt.Graphics) on said component, to determine whether or not
this frame participant needs to be painted. |
void |
paint(Graphics2D gfx,
float complete)
Paint the timer into the given graphics context at the inputted
percent complete (0f means just started, 1f means just finished).
|
void |
pause()
Pause the timer from processing.
|
void |
removeWarning()
Remove any warning this timer might have had.
|
void |
render(Graphics2D gfx)
Renders the timer to the given graphics context if enabled.
|
void |
reset()
Reset the timer.
|
boolean |
running()
Test if the timer is running right now.
|
void |
setEnabled(boolean enabled)
Sets whether this timer should be rendered.
|
void |
setTransitionTime(long time)
Set the amount of time it takes to render digital changes in the
completion state (probably due to a timer reset).
|
void |
setWarning(float warnPercent,
ResultListener<TimerView> warner)
Setup a warning to trigger after the timer is "warnPercent"
or more completed.
|
void |
start(float startPercent,
long duration,
ResultListener<TimerView> finisher)
Start the timer running from the specified percentage complete,
to expire at the specified time.
|
void |
stop()
Stop the timer.
|
void |
tick(long now)
This is called on all registered frame participants, one for every
frame.
|
void |
unpause()
Unpause the timer.
|
public TimerView(FrameManager fmgr, JComponent host, Rectangle bounds)
public void setEnabled(boolean enabled)
public long getTransitionTime()
public void setTransitionTime(long time)
public void setWarning(float warnPercent,
ResultListener<TimerView> warner)
public void removeWarning()
public boolean running()
public void start(float startPercent,
long duration,
ResultListener<TimerView> finisher)
startPercent - a value in [0f, 1f) indicating how much
hourglass time has already elapsed when the timer starts.duration - The time interval over which the timer would
run if it started at 0%.finisher - a listener that will be notified when the timer
finishes, or null if nothing should be notified.public void reset()
public void stop()
public void pause()
public void unpause()
public void changeComplete(float complete)
public void render(Graphics2D gfx)
public void paint(Graphics2D gfx, float complete)
public void tick(long now)
FrameParticipanttick in interface FrameParticipantpublic boolean needsPaint()
FrameParticipantFrameParticipant.getComponent() and then Component.paint(java.awt.Graphics) on said component, to determine whether or not
this frame participant needs to be painted.needsPaint in interface FrameParticipantpublic Component getComponent()
FrameParticipantComponent.paint(java.awt.Graphics) called on it once per frame with a translated but
unclipped graphics object.
Because clipping is expensive in terms of rectangle object allocation, frame participants are given the opportunity to do their own clipping because they are likely to want to clip to a more fine grained region than their entire bounds. If a participant does not wish to be actively rendered, it can safely return null.
getComponent in interface FrameParticipantpublic void hierarchyChanged(HierarchyEvent e)
hierarchyChanged in interface HierarchyListenerpublic void checkFrameParticipation()
Copyright © 2015. All rights reserved.