|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hdcookbook.grin.animator.AnimationEngine
com.hdcookbook.grin.animator.ClockBasedEngine
com.hdcookbook.grin.test.bigjdk.ScalingDirectDrawEngine
public class ScalingDirectDrawEngine
A double-buffered animation engine that uses direct draw, and applies a scaling divisor. This is based off of DirectDrawEngine, with some adjustments to make it work on big JDK and provide scaling.
DirectDrawEngine
Field Summary |
---|
Fields inherited from class com.hdcookbook.grin.animator.AnimationEngine |
---|
modelTimeSkipped, renderContext, repaintBounds, targetsCanOverlap, transparent |
Constructor Summary | |
---|---|
ScalingDirectDrawEngine(int scaleDivisor,
GenericMain main)
Create a new ScalingDirectDrawEngine. |
Method Summary | |
---|---|
protected void |
callPaintTargets()
Paint the current frame into the right graphics buffer. |
protected void |
clearArea(int x,
int y,
int width,
int height)
Called from showFrame() to cause an area to be cleared in the current frame. |
protected void |
finishedFrame()
Called when the engine is finished drawing the current frame. |
java.awt.Component |
getComponent()
Get the component that this animation engine renders into. |
int |
getHeight()
Get the height of the area we display over |
int |
getWidth()
Get the width of the area we display over |
void |
initContainer(java.awt.Container container,
java.awt.Rectangle bounds)
Initialize this engine with its parent container and the position and size of the engine within the container. |
protected boolean |
needsFullRedrawInAnimationLoop()
Tell us whether or not this style of animation requires a full redraw of everything on the screen in each pass through the animation loop. |
protected void |
runAnimationLoop()
The inner loop for the animation thread. |
protected void |
terminatingEraseScreen()
Erase the screen because the AnimationManager is terminating. |
java.lang.String |
toString()
|
Methods inherited from class com.hdcookbook.grin.animator.ClockBasedEngine |
---|
getFps, pause, setFps, skipFrames, start |
Methods inherited from class com.hdcookbook.grin.animator.AnimationEngine |
---|
advanceModel, checkDestroy, checkNewClients, destroy, destroyRequested, getAnimationClients, getDrawTargets, getEraseTargets, getModelTimeSkipped, getNumDrawTargets, getNumEraseTargets, initClients, initialize, paintFrame, paintNextFrameFully, paintTargets, repaintFrame, resetAnimationClients, run, setAllowOverlappingTargets, setDrawTargetCollapseThreshold, setThreadPriority, showFrame |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ScalingDirectDrawEngine(int scaleDivisor, GenericMain main)
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public void initContainer(java.awt.Container container, java.awt.Rectangle bounds)
The Component will be set to the specified bounds, and an internal double buffer may be created to these bounds. The container is expected to have a null layout; if it doesn't, this might change the widget's size to be different than the bounds passed in (and therefore the double buffer). The container must be visible when this is called.
initContainer
in class AnimationEngine
AnimationEngine.initialize(com.hdcookbook.grin.animator.AnimationContext)
,
AnimationContext.animationInitialize()
public int getWidth()
getWidth
in class AnimationEngine
public int getHeight()
getHeight
in class AnimationEngine
public java.awt.Component getComponent()
getComponent
in class AnimationEngine
AnimationEngine.initialize(com.hdcookbook.grin.animator.AnimationContext)
,
AnimationContext.animationInitialize()
protected void clearArea(int x, int y, int width, int height)
clearArea
in class AnimationEngine
AnimationEngine.showFrame()
protected boolean needsFullRedrawInAnimationLoop()
This is always false for direct draw. Because we maintian our own double buffer, nothing external can damage its contents.
needsFullRedrawInAnimationLoop
in class AnimationEngine
protected void callPaintTargets() throws java.lang.InterruptedException
callPaintTargets
in class AnimationEngine
java.lang.InterruptedException
AnimationEngine.paintFrame(java.awt.Graphics2D)
protected void runAnimationLoop() throws java.lang.InterruptedException
This method must call checkNewClients() outside of any synchronized block at least once per frame. This should be done at the beginning of the frame before any model updates or animation work is done.
This method must check destroyRequested() at least once per frame, and if it's true, bail out of the loop. To advance the model by one frame, it should call advanceModel(). When it wants to show a frame (and not skip it), it should call showFrame(), which will cause callPaintTargets() to be called.
Of course, the animation loop should also check Thread.interrupted() regularly.
runAnimationLoop
in class ClockBasedEngine
java.lang.InterruptedException
AnimationEngine.destroyRequested()
,
AnimationEngine.advanceModel()
,
AnimationEngine.showFrame()
,
AnimationEngine.callPaintTargets()
protected void finishedFrame()
finishedFrame
in class AnimationEngine
protected void terminatingEraseScreen()
terminatingEraseScreen
in class AnimationEngine
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |