|
|||||||||
| 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.animator.DirectDrawEngine
public class DirectDrawEngine
A double-buffered animation engine that uses direct draw. The engine maintains a BufferedImage that the animation clients paint into for each animation frame. At the end of each frame, this buffer is blitted to the framebuffer using Component.getGraphics(), and Toolkit.sync() is called.
On most players, direct draw is probably the fastest drawing option. However, direct draw doesn't take advantage of platform double-buffering, that is, platforms where HScene.isDoubleBuffered() returns true. On such platforms, repaint draw will save memory, and on some implementations of platform double buffering, repaint draw may even prove to be faster.
Direct draw also has the drawback (no pun intended) that you can't draw widgets in back of or in front of the area managed by the engine, unless you make sure the right drawing happens yourself. In other words, using direct draw in an area makes it difficult to have widgets (like HButton) occupy overlapping screen real estate.
| Field Summary |
|---|
| Fields inherited from class com.hdcookbook.grin.animator.AnimationEngine |
|---|
modelTimeSkipped, renderContext, repaintBounds, targetsCanOverlap, transparent |
| Constructor Summary | |
|---|---|
DirectDrawEngine()
Create a new DirectDrawEngine. |
|
| 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 |
terminatingEraseScreen()
Erase the screen because the AnimationManager is terminating. |
java.lang.String |
toString()
|
| Methods inherited from class com.hdcookbook.grin.animator.ClockBasedEngine |
|---|
getFps, pause, runAnimationLoop, 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 DirectDrawEngine()
| 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 AnimationEngineAnimationEngine.initialize(com.hdcookbook.grin.animator.AnimationContext),
AnimationContext.animationInitialize()public int getWidth()
getWidth in class AnimationEnginepublic int getHeight()
getHeight in class AnimationEnginepublic java.awt.Component getComponent()
getComponent in class AnimationEngineAnimationEngine.initialize(com.hdcookbook.grin.animator.AnimationContext),
AnimationContext.animationInitialize()
protected void clearArea(int x,
int y,
int width,
int height)
clearArea in class AnimationEngineAnimationEngine.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 AnimationEnginejava.lang.InterruptedExceptionAnimationEngine.paintFrame(java.awt.Graphics2D)protected void finishedFrame()
finishedFrame in class AnimationEngineprotected void terminatingEraseScreen()
terminatingEraseScreen in class AnimationEngine
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||