|
|||||||||
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.RepaintDrawEngine
public class RepaintDrawEngine
An animation engine that uses repaint draw. Repaint draw proceeds by calling Component.repaint(), and then waiting for the platform to call our Component.paint(Graphics) method. On most players, it's probably at least a little bit slower than direct draw, due to the thread context switching. Repaint draw can be significantly slower than direct draw for certain kinds of drawing, because a frame's damage rect is limited to one big rectangle (even when several small ones might do), and because of extra overhead erasing areas of the double buffer that are later drawn to in source mode.
Repaint draw has the advantage that it can take advantage of platform-supplied double buffering. That is, the engine will only needs to create a BufferedImage for double-buffering on platforms where HScene.isDoubleBuffered() returns false. On platforms where it returns true, repaint draw may be faster. Repaint draw may also make it easier to coexist with widgets (like HButton), particularly if they overlap with the area managed by the animation engine.
Field Summary |
---|
Fields inherited from class com.hdcookbook.grin.animator.AnimationEngine |
---|
modelTimeSkipped, renderContext, repaintBounds, targetsCanOverlap, transparent |
Constructor Summary | |
---|---|
RepaintDrawEngine()
Create a new RepaintDrawEngine. |
Method Summary | |
---|---|
void |
addRepaintArea(int x,
int y,
int width,
int height)
Sets this engine so that the given region of the image buffer is forced to be repainted at next frame. |
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. |
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, toString, wait, wait, wait |
Constructor Detail |
---|
public RepaintDrawEngine()
Method Detail |
---|
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()
public void addRepaintArea(int x, int y, int width, int height)
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 repaint draw, because the AWT subsystem tells us the extent of our drawing, and it erases behind that area for us.
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 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 |