java.lang.Object
org.bzdev.gio.Graphics2DRecorder
- All Implemented Interfaces:
Cloneable
,GraphicsCreator
Class for creating Graphics2D instances that can be replayed.
While in most cases, instances of this class will just "do the right thing", one should note that the Graphics2D methods
- getFontRenderContext()
- getDeviceConfiguration()
- toString()
playback(Graphics2D)
. One should avoid
using these methods (except for the toString() method for diagnostics
or debugging). By contrast, the methods
- getBackground()
- getComposite()
- getPaint()
- getRenderingHint(RenderingHints.Key)
- getRenderingHints()
- getStroke()
- getTransform()
- hit()
- getClip()
- getClipBounds()
- getFont()
- getFontMetrics()
- hitClip()
playback(Graphics2D)
, but only if the
corresponding 'set' methods have not been called. In other words,
to get a desired background color, one should explicitly call
Graphics2D.setBackground(Color)
and not depend on a default
value. Similarly, before calling Graphics.getFontMetrics()
,
one should call Graphics.setFont(Font)
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a graphics context.void
playback
(Graphics2D tg2d) Play back all the operations perforemed on the graphics contexts created, except for a dispose as that will be handled separately for the target graphics context.void
reset()
Reset the recorder.
-
Constructor Details
-
Graphics2DRecorder
Constructor.- Parameters:
g2d
- the Graphics2D used by createGraphics to create multiple Graphics 2D graphics contexts
-
-
Method Details
-
reset
public void reset()Reset the recorder. It is the caller's responsibility to make sure that all graphics contexts previously created by the recorder are not used subsequently. -
createGraphics
Create a graphics context.- Specified by:
createGraphics
in interfaceGraphicsCreator
- Returns:
- the new graphics context
-
playback
Play back all the operations perforemed on the graphics contexts created, except for a dispose as that will be handled separately for the target graphics context.- Parameters:
tg2d
- the target graphics context for the playback
-