java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
org.bzdev.gio.SurrogateGraphics2D
Graphics2D class providing a minimal implementation.
When this class is used, it will typically be used to create a
minimal implementation of
Graphics2D
that will be passed
to the constructor
Graphics2DRecorder(Graphics2D)
.
A typical use is to record a series of graphics operation that will
be "replayed" inside a method such as
JComponent.paintComponent(Graphics)
.
The implementation uses a buffered image for some operations to ensure that the behavior is the same as that for the Java class library, but the methods that draw objects, with a few exceptions involving the explicit use of image observers, do nothing.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.SurrogateGraphics2D
(boolean preferAlpha) Constructor indicating if an internal buffered image should use an alpha channel.SurrogateGraphics2D
(int width, int height, boolean preferAlpha) Constructor specifying a width and height. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRenderingHints
(Map<?, ?> hints) void
clearRect
(int x, int y, int width, int height) void
void
clipRect
(int x, int y, int width, int height) void
copyArea
(int x, int y, int width, int height, int dx, int dy) create()
create
(int x, int y, int width, int height) void
dispose()
void
void
drawArc
(int x, int y, int width, int height, int startAngle, int arcAngle) void
drawGlyphVector
(GlyphVector g, float x, float y) void
drawImage
(BufferedImage img, BufferedImageOp op, int x, int y) boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, int width, int height, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, Color bgcolor, ImageObserver observer) boolean
drawImage
(Image img, int x, int y, ImageObserver observer) boolean
drawImage
(Image img, AffineTransform xform, ImageObserver obs) void
drawLine
(int x1, int y1, int x2, int y2) void
drawOval
(int x, int y, int width, int height) void
drawPolygon
(int[] xPoints, int[] yPoints, int nPoints) void
drawPolyline
(int[] xPoints, int[] yPoints, int nPoints) void
drawRenderableImage
(RenderableImage img, AffineTransform xform) void
drawRenderedImage
(RenderedImage img, AffineTransform xform) void
drawRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) void
drawString
(String str, float x, float y) void
drawString
(String str, int x, int y) void
drawString
(AttributedCharacterIterator iterator, float x, float y) void
drawString
(AttributedCharacterIterator iterator, int x, int y) void
void
fillArc
(int x, int y, int width, int height, int startAngle, int arcAngle) void
fillOval
(int x, int y, int width, int height) void
fillPolygon
(int[] xPoints, int[] yPoints, int nPoints) void
fillRect
(int x, int y, int width, int height) void
fillRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) getClip()
getColor()
getFont()
static Graph.ImageType
getGraphImageType
(boolean preferAlpha) Get the image type used by a buffered image associated with an instance of SurrogateGraphics2D.getPaint()
getRenderingHint
(RenderingHints.Key hintKey) boolean
boolean
hitClip
(int x, int y, int width, int height) void
rotate
(double theta) void
rotate
(double theta, double x, double y) void
scale
(double sx, double sy) void
setBackground
(Color color) void
setClip
(int x, int y, int width, int height) void
void
void
setComposite
(Composite comp) void
void
void
void
setRenderingHint
(RenderingHints.Key hintKey, Object hintValue) void
setRenderingHints
(Map<?, ?> hints) void
void
void
setXORMode
(Color c1) void
shear
(double shx, double shy) void
void
translate
(double tx, double ty) void
translate
(int x, int y) Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
Methods inherited from class java.awt.Graphics
drawBytes, drawChars, drawPolygon, drawRect, fillPolygon, finalize, getClipBounds, getClipRect, toString
-
Constructor Details
-
SurrogateGraphics2D
public SurrogateGraphics2D()Constructor. -
SurrogateGraphics2D
public SurrogateGraphics2D(boolean preferAlpha) Constructor indicating if an internal buffered image should use an alpha channel.- Parameters:
preferAlpha
- true if the an alpha channel should be provided; false otherwise
-
SurrogateGraphics2D
public SurrogateGraphics2D(int width, int height, boolean preferAlpha) Constructor specifying a width and height.- Parameters:
width
- the width for a buffered imageheight
- the height for a buffered imagepreferAlpha
- true if an alpha channel should be provided; false otherwise
-
-
Method Details
-
getGraphImageType
Get the image type used by a buffered image associated with an instance of SurrogateGraphics2D.- Parameters:
preferAlpha
- true if the buffered image should have an alpha channel; false otherwise- Returns:
- the image type as an enumeration constant
-
addRenderingHints
- Specified by:
addRenderingHints
in classGraphics2D
-
clip
- Specified by:
clip
in classGraphics2D
-
draw
- Specified by:
draw
in classGraphics2D
-
drawGlyphVector
- Specified by:
drawGlyphVector
in classGraphics2D
-
getFontRenderContext
- Specified by:
getFontRenderContext
in classGraphics2D
-
drawImage
- Specified by:
drawImage
in classGraphics2D
-
drawImage
- Specified by:
drawImage
in classGraphics2D
-
drawRenderableImage
- Specified by:
drawRenderableImage
in classGraphics2D
-
drawRenderedImage
- Specified by:
drawRenderedImage
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
drawString
- Specified by:
drawString
in classGraphics2D
-
fill
- Specified by:
fill
in classGraphics2D
-
getBackground
- Specified by:
getBackground
in classGraphics2D
-
getComposite
- Specified by:
getComposite
in classGraphics2D
-
getDeviceConfiguration
- Specified by:
getDeviceConfiguration
in classGraphics2D
-
getPaint
- Specified by:
getPaint
in classGraphics2D
-
getRenderingHint
- Specified by:
getRenderingHint
in classGraphics2D
-
getRenderingHints
- Specified by:
getRenderingHints
in classGraphics2D
-
getStroke
- Specified by:
getStroke
in classGraphics2D
-
getTransform
- Specified by:
getTransform
in classGraphics2D
-
hit
- Specified by:
hit
in classGraphics2D
-
rotate
public void rotate(double theta) - Specified by:
rotate
in classGraphics2D
-
rotate
public void rotate(double theta, double x, double y) - Specified by:
rotate
in classGraphics2D
-
scale
public void scale(double sx, double sy) - Specified by:
scale
in classGraphics2D
-
setBackground
- Specified by:
setBackground
in classGraphics2D
-
setComposite
- Specified by:
setComposite
in classGraphics2D
-
setPaint
- Specified by:
setPaint
in classGraphics2D
-
setRenderingHint
- Specified by:
setRenderingHint
in classGraphics2D
-
setRenderingHints
- Specified by:
setRenderingHints
in classGraphics2D
-
setStroke
- Specified by:
setStroke
in classGraphics2D
-
setTransform
- Specified by:
setTransform
in classGraphics2D
-
shear
public void shear(double shx, double shy) - Specified by:
shear
in classGraphics2D
-
transform
- Specified by:
transform
in classGraphics2D
-
translate
public void translate(double tx, double ty) - Specified by:
translate
in classGraphics2D
-
translate
public void translate(int x, int y) - Specified by:
translate
in classGraphics2D
-
clearRect
public void clearRect(int x, int y, int width, int height) -
clipRect
public void clipRect(int x, int y, int width, int height) -
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) -
create
-
create
-
dispose
public void dispose() -
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
drawImage
-
drawImage
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) -
drawImage
-
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) -
drawLine
public void drawLine(int x1, int y1, int x2, int y2) -
drawOval
public void drawOval(int x, int y, int width, int height) -
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolygon
in classGraphics
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
drawPolyline
in classGraphics
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
drawRoundRect
in classGraphics
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
fillOval
public void fillOval(int x, int y, int width, int height) -
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) - Specified by:
fillPolygon
in classGraphics
-
fillRect
public void fillRect(int x, int y, int width, int height) -
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Specified by:
fillRoundRect
in classGraphics
-
getClip
-
getClipBounds
- Specified by:
getClipBounds
in classGraphics
-
getColor
-
getFont
-
getFontMetrics
- Overrides:
getFontMetrics
in classGraphics
-
getFontMetrics
- Specified by:
getFontMetrics
in classGraphics
-
hitClip
public boolean hitClip(int x, int y, int width, int height) -
setClip
public void setClip(int x, int y, int width, int height) -
setClip
-
setColor
-
setFont
-
setPaintMode
public void setPaintMode()- Specified by:
setPaintMode
in classGraphics
-
setXORMode
- Specified by:
setXORMode
in classGraphics
-