Inherited by edu.cmu.hcii.calo.view.notification.NotificationCenterView, edu.cmu.hcii.calo.view.schedule.BlockScheduleView, edu.cmu.hcii.calo.view.task.TaskSubpaneContainerView, and edu.cmu.hcii.calo.view.task.TaskSubpaneView.
Inheritance diagram for edu.cmu.hcii.calo.view.AnimatedPane:
Classes extending AnimatedPane should do several things:
This may seem like a lot of work, but the alternative is Swing thread hell. AnimatedPane automatically runs all necessary code in the AWT Event Dispatch thread, so you don't have to surround anything with calls to SwingUtilities.invokeLater
. This class is guaranteed to work all of the time 99% of the time, and most of the time the other 1% of the time. Have fun.
Public Member Functions | |
AnimatedPane () | |
Constructor for AnimatedPane. | |
void | animationDidUpdate (final Animation a) |
Called by the AnimationManager when an animation is updated. | |
void | doLayout () |
Calls super.doLayout() unless we have at least one animation in progress, in which case no layout is performed. | |
void | paint (Graphics g) |
Calls super.paint() unless ignorePaintRequests is true, in which case we draw our stored buffer instead. | |
boolean | preventsCollapse () |
Returns whether this pane should avoid becoming smaller than its initial state during an animation. | |
void | setPreventsCollapse (boolean preventCollapse) |
Sets whether this pane should avoid becoming smaller than its initial state during an animation. | |
void | update () |
Causes this view to synchronize itself with the TaskManager. | |
int | getNumAnimating () |
Gets the number of animations that have successfully started running. | |
Protected Member Functions | |
void | decrementNumAnimating () |
Subtracts one from the number of running animations. | |
abstract boolean | doAnimations () |
Should be implemented to record the positions of all the components in the view so they can be animated from their old positions, and then create and start the necessary Animation objects to perform these animations. | |
abstract void | doUpdate () |
Should be implemented to synchronize the view with the model on which it depends. | |
void | finalizeAnimation () |
Invoked when all animations have finished. | |
int | getTotalAnimations () |
Gets the total number of animations that must complete before the entire set of animations should be declared finished. | |
void | incrementNumAnimating () |
Adds one to the number of running animations. | |
abstract void | prepareAnimations () |
Should be implemented to record the positions of all the components in the view so they can be animated to their new positions later. | |
abstract void | safeUpdateAnimation (Animation a) |
Should be implemented to process an updated animation, just like AnimationListener.animationDidUpdate(Animation). | |
void | setIgnorePaintRequests (boolean ignorePaintRequests) |
Determines whether or not the view should ignore requests to paint itself. | |
void | setNumAnimating (int numAnimating) |
Sets the number of animations that have successfully started running. | |
void | setTotalAnimations (int totalAnimations) |
Sets the total number of animations that must complete before the entire set of animations should be declared finished. | |
boolean | getIgnorePaintRequests () |
Returns whether the view should ignore requests to paint itself. | |
Private Attributes | |
boolean | ignorePaintRequests = false |
Whether we are ignoring paint requests right now. | |
int | numAnimating = 0 |
How many animations are currently in progress. | |
BufferedImage | imageBuffer |
Image buffer that we paint when we're ignoring paint requests. | |
int | totalAnimations = 0 |
The total number of animations we expect to complete before we're done. | |
boolean | preventCollapse = true |
Whether we should prevent our height from growing smaller before all animations are complete. |
edu.cmu.hcii.calo.view.AnimatedPane.AnimatedPane | ( | ) |
Constructor for AnimatedPane.
void edu.cmu.hcii.calo.view.AnimatedPane.animationDidUpdate | ( | final Animation | a | ) |
Called by the AnimationManager when an animation is updated.
Subclasses should NOT override this method to handle animations, and should instead implement safeUpdateAnimation(Animation).
a | the animation being updated |
void edu.cmu.hcii.calo.view.AnimatedPane.doLayout | ( | ) |
Calls super.doLayout() unless we have at least one animation in progress, in which case no layout is performed.
This prevents ancestor views from messing up the animation by forcing the container to recompute its layout in the middle.
void edu.cmu.hcii.calo.view.AnimatedPane.paint | ( | Graphics | g | ) |
Calls super.paint() unless ignorePaintRequests is true, in which case we draw our stored buffer instead.
This ameliorates the effect of the views snapping to their eventual destination positions when validate is called just before the animation begins, though it does not completely eliminate the effect in all instances.
g | the Graphics instance to paint into |
Reimplemented from edu.cmu.hcii.calo.view.TranslucentView.
Reimplemented in edu.cmu.hcii.calo.view.task.TaskSubpaneView.
boolean edu.cmu.hcii.calo.view.AnimatedPane.preventsCollapse | ( | ) |
Returns whether this pane should avoid becoming smaller than its initial state during an animation.
If true
, the pane will instead resize at the end of the animation.
true
if this pane prevents collapse, false
otherwise void edu.cmu.hcii.calo.view.AnimatedPane.setPreventsCollapse | ( | boolean | preventCollapse | ) |
Sets whether this pane should avoid becoming smaller than its initial state during an animation.
If true
, the pane will instead resize at the end of the animation.
preventCollapse | true if this pane should prevent collapse, false otherwise |
void edu.cmu.hcii.calo.view.AnimatedPane.update | ( | ) |
Causes this view to synchronize itself with the TaskManager.
Specifically, the view first calls prepareAnimations() to allow the old positions of its components to be recorded. Next, it sets ignorePaintRequests to true if the view is visible onscreen, and calls doUpdate(). Then, doLayout() is called to recompute the positions of all the components in the view, and the view is resized to its preferred size. Lastly, doAnimations() is called to allow the new positions of the components to be recorded and the animations to be started.
void edu.cmu.hcii.calo.view.AnimatedPane.decrementNumAnimating | ( | ) | [protected] |
Subtracts one from the number of running animations.
Exactly equivalent to setNumAnimating(getNumAnimating() - 1)
. You usually do not need to call this method; the number of animations will automatically be decremented by AnimatedPane when each animation finishes.
abstract boolean edu.cmu.hcii.calo.view.AnimatedPane.doAnimations | ( | ) | [protected, pure virtual] |
Should be implemented to record the positions of all the components in the view so they can be animated from their old positions, and then create and start the necessary Animation objects to perform these animations.
Implemented in edu.cmu.hcii.calo.view.notification.NotificationCenterView, edu.cmu.hcii.calo.view.schedule.BlockScheduleView, edu.cmu.hcii.calo.view.task.TaskSubpaneContainerView, and edu.cmu.hcii.calo.view.task.TaskSubpaneView.
abstract void edu.cmu.hcii.calo.view.AnimatedPane.doUpdate | ( | ) | [protected, pure virtual] |
Should be implemented to synchronize the view with the model on which it depends.
AnimatedPane provides a public update() method to the client code which calls doUpdate automatically.
Implemented in edu.cmu.hcii.calo.view.notification.NotificationCenterView, edu.cmu.hcii.calo.view.schedule.BlockScheduleView, edu.cmu.hcii.calo.view.task.TaskSubpaneContainerView, and edu.cmu.hcii.calo.view.task.TaskSubpaneView.
void edu.cmu.hcii.calo.view.AnimatedPane.finalizeAnimation | ( | ) | [protected] |
Invoked when all animations have finished.
Performs cleanup to ensure that the pane is in the correct state after all animations are done.
Reimplemented in edu.cmu.hcii.calo.view.notification.NotificationCenterView.
int edu.cmu.hcii.calo.view.AnimatedPane.getNumAnimating | ( | ) |
Gets the number of animations that have successfully started running.
This number will change when you call setNumAnimating(int) or incrementNumAnimating(), and will also decrement automatically when animations finish.
int edu.cmu.hcii.calo.view.AnimatedPane.getTotalAnimations | ( | ) | [protected] |
Gets the total number of animations that must complete before the entire set of animations should be declared finished.
void edu.cmu.hcii.calo.view.AnimatedPane.incrementNumAnimating | ( | ) | [protected] |
Adds one to the number of running animations.
Exactly equivalent to setNumAnimating(getNumAnimating() + 1)
.
abstract void edu.cmu.hcii.calo.view.AnimatedPane.prepareAnimations | ( | ) | [protected, pure virtual] |
Should be implemented to record the positions of all the components in the view so they can be animated to their new positions later.
prepareAnimations() is called from update() before doUpdate() is invoked, so the component positions are unchanged from what they were before the update.
Implemented in edu.cmu.hcii.calo.view.notification.NotificationCenterView, edu.cmu.hcii.calo.view.schedule.BlockScheduleView, edu.cmu.hcii.calo.view.task.TaskSubpaneContainerView, and edu.cmu.hcii.calo.view.task.TaskSubpaneView.
abstract void edu.cmu.hcii.calo.view.AnimatedPane.safeUpdateAnimation | ( | Animation | a | ) | [protected, pure virtual] |
Should be implemented to process an updated animation, just like AnimationListener.animationDidUpdate(Animation).
This method exists because AnimatedPane performs some automatic setup and teardown in animationDidUpdate(Animation), and calls safeUpdateAnimation(Animation) in between.
a | the animation that is updating |
Implemented in edu.cmu.hcii.calo.view.notification.NotificationCenterView, edu.cmu.hcii.calo.view.schedule.BlockScheduleView, edu.cmu.hcii.calo.view.task.TaskSubpaneContainerView, and edu.cmu.hcii.calo.view.task.TaskSubpaneView.
void edu.cmu.hcii.calo.view.AnimatedPane.setIgnorePaintRequests | ( | boolean | ignorePaintRequests | ) | [protected] |
Determines whether or not the view should ignore requests to paint itself.
If set to true
, AnimatedPane will make a cached buffer of the window contents as they appear right now, and any subsequent requests to paint will be fulfilled by using this buffer. Thus, there will be no flickering or "giant eraser" effect, but any changes to the layout will be hidden until you are ready to show them.
ignorePaintRequests | true to ignore paint requests, false to service them as usual. |
void edu.cmu.hcii.calo.view.AnimatedPane.setNumAnimating | ( | int | numAnimating | ) | [protected] |
Sets the number of animations that have successfully started running.
It is often more convenient to use incrementNumAnimating() instead.
numAnimating | the new number of running animations |
void edu.cmu.hcii.calo.view.AnimatedPane.setTotalAnimations | ( | int | totalAnimations | ) | [protected] |
Sets the total number of animations that must complete before the entire set of animations should be declared finished.
This should be called in doAnimations() so that AnimatedPane can determine when to begin servicing paint events again.
totalAnimations | the total number of animations to be run |
boolean edu.cmu.hcii.calo.view.AnimatedPane.getIgnorePaintRequests | ( | ) | [protected] |
Returns whether the view should ignore requests to paint itself.
boolean edu.cmu.hcii.calo.view.AnimatedPane.ignorePaintRequests = false [private] |
Whether we are ignoring paint requests right now.
int edu.cmu.hcii.calo.view.AnimatedPane.numAnimating = 0 [private] |
How many animations are currently in progress.
BufferedImage edu.cmu.hcii.calo.view.AnimatedPane.imageBuffer [private] |
Image buffer that we paint when we're ignoring paint requests.
int edu.cmu.hcii.calo.view.AnimatedPane.totalAnimations = 0 [private] |
The total number of animations we expect to complete before we're done.
boolean edu.cmu.hcii.calo.view.AnimatedPane.preventCollapse = true [private] |
Whether we should prevent our height from growing smaller before all animations are complete.