Package ca.cgjennings.graphics
Class PrototypingGraphics2D
- java.lang.Object
-
- java.awt.Graphics
-
- java.awt.Graphics2D
-
- ca.cgjennings.graphics.AbstractGraphics2DAdapter
-
- ca.cgjennings.graphics.PrototypingGraphics2D
-
public final class PrototypingGraphics2D extends AbstractGraphics2DAdapter
A graphics context that selectively renders different classes of content for speed or prototyping purposes. For example, it could be set to draw only text to save the ink that would be spent printing background graphics.- Author:
- Chris Jennings
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.graphics.AbstractGraphics2DAdapter
g
-
-
Constructor Summary
Constructors Constructor Description PrototypingGraphics2D(java.awt.Graphics2D unrestrictedGraphics)
Creates a new prototyping graphics context with default options: text and shapes are drawn, but images are not.PrototypingGraphics2D(java.awt.Graphics2D unrestrictedGraphics, boolean drawText, boolean drawImages, boolean strokeShapes, boolean fillShapes, boolean clearRects)
Creates a new prototyping graphics context that selectively renders the specified elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearRect(int x, int y, int width, int height)
protected PrototypingGraphics2D
createImpl(java.awt.Graphics2D newG)
Creates and returns a new instance of this adapter with the same behaviour, but for the specified graphics context.void
draw(java.awt.Shape s)
void
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
void
drawBytes(byte[] data, int offset, int length, int x, int y)
void
drawChars(char[] data, int offset, int length, int x, int y)
void
drawGlyphVector(java.awt.font.GlyphVector gv, float x, float y)
void
drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)
boolean
drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
boolean
drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)
boolean
drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
boolean
drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
boolean
drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
boolean
drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
boolean
drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.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
drawPolygon(java.awt.Polygon p)
void
drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
void
drawRect(int x, int y, int width, int height)
void
drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)
void
drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
void
drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
void
drawString(java.lang.String str, float x, float y)
void
drawString(java.lang.String str, int x, int y)
void
drawString(java.text.AttributedCharacterIterator iterator, float x, float y)
void
drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
void
fill(java.awt.Shape s)
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
fillPolygon(java.awt.Polygon p)
void
fillRect(int x, int y, int width, int height)
void
fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
java.awt.Graphics2D
getUnrestrictedGraphics()
Returns the graphics instance that this wraps.java.lang.String
toString()
-
Methods inherited from class ca.cgjennings.graphics.AbstractGraphics2DAdapter
addRenderingHints, clip, clipRect, copyArea, create, dispose, getBackground, getClip, getClipBounds, getClipBounds, getColor, getComposite, getDeviceConfiguration, getFont, getFontMetrics, getFontMetrics, getFontRenderContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, hitClip, rotate, rotate, scale, setBackground, setClip, setClip, setColor, setComposite, setFont, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, setXORMode, shear, transform, translate, translate
-
-
-
-
Constructor Detail
-
PrototypingGraphics2D
public PrototypingGraphics2D(java.awt.Graphics2D unrestrictedGraphics)
Creates a new prototyping graphics context with default options: text and shapes are drawn, but images are not.- Parameters:
unrestrictedGraphics
- a graphics context to modify
-
PrototypingGraphics2D
public PrototypingGraphics2D(java.awt.Graphics2D unrestrictedGraphics, boolean drawText, boolean drawImages, boolean strokeShapes, boolean fillShapes, boolean clearRects)
Creates a new prototyping graphics context that selectively renders the specified elements.- Parameters:
unrestrictedGraphics
- a graphics context to modifydrawText
- if true, regular text is rendereddrawImages
- if true, bitmap images are renderedstrokeShapes
- if true, lines, polygons, and shape outlines are drawnfillShapes
- if true, polygons and other shapes are filledclearRects
- if true, regions are cleared whenclearRect(int, int, int, int)
is called
-
-
Method Detail
-
createImpl
protected PrototypingGraphics2D createImpl(java.awt.Graphics2D newG)
Description copied from class:AbstractGraphics2DAdapter
Creates and returns a new instance of this adapter with the same behaviour, but for the specified graphics context.- Specified by:
createImpl
in classAbstractGraphics2DAdapter
- Parameters:
newG
- the new graphics context to target- Returns:
- an adapter that wraps the new context
-
getUnrestrictedGraphics
public java.awt.Graphics2D getUnrestrictedGraphics()
Returns the graphics instance that this wraps. This can be used to ensure that some content is always rendered.- Returns:
- the non-prototype graphics that backs this instance
-
drawImage
public boolean drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawImage
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawImage
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawImage
public void drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)
- Overrides:
drawImage
in classAbstractGraphics2DAdapter
-
drawRenderedImage
public void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
- Overrides:
drawRenderedImage
in classAbstractGraphics2DAdapter
-
drawRenderableImage
public void drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)
- Overrides:
drawRenderableImage
in classAbstractGraphics2DAdapter
-
drawString
public void drawString(java.lang.String str, int x, int y)
- Overrides:
drawString
in classAbstractGraphics2DAdapter
-
drawString
public void drawString(java.lang.String str, float x, float y)
- Overrides:
drawString
in classAbstractGraphics2DAdapter
-
drawString
public void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
- Overrides:
drawString
in classAbstractGraphics2DAdapter
-
drawString
public void drawString(java.text.AttributedCharacterIterator iterator, float x, float y)
- Overrides:
drawString
in classAbstractGraphics2DAdapter
-
drawBytes
public void drawBytes(byte[] data, int offset, int length, int x, int y)
- Overrides:
drawBytes
in classAbstractGraphics2DAdapter
-
drawChars
public void drawChars(char[] data, int offset, int length, int x, int y)
- Overrides:
drawChars
in classAbstractGraphics2DAdapter
-
drawGlyphVector
public void drawGlyphVector(java.awt.font.GlyphVector gv, float x, float y)
- Overrides:
drawGlyphVector
in classAbstractGraphics2DAdapter
-
draw
public void draw(java.awt.Shape s)
- Overrides:
draw
in classAbstractGraphics2DAdapter
-
fill
public void fill(java.awt.Shape s)
- Overrides:
fill
in classAbstractGraphics2DAdapter
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)
- Overrides:
drawLine
in classAbstractGraphics2DAdapter
-
drawRect
public void drawRect(int x, int y, int width, int height)
- Overrides:
drawRect
in classAbstractGraphics2DAdapter
-
fillRect
public void fillRect(int x, int y, int width, int height)
- Overrides:
fillRect
in classAbstractGraphics2DAdapter
-
clearRect
public void clearRect(int x, int y, int width, int height)
- Overrides:
clearRect
in classAbstractGraphics2DAdapter
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- Overrides:
drawRoundRect
in classAbstractGraphics2DAdapter
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- Overrides:
fillRoundRect
in classAbstractGraphics2DAdapter
-
drawOval
public void drawOval(int x, int y, int width, int height)
- Overrides:
drawOval
in classAbstractGraphics2DAdapter
-
fillOval
public void fillOval(int x, int y, int width, int height)
- Overrides:
fillOval
in classAbstractGraphics2DAdapter
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- Overrides:
drawArc
in classAbstractGraphics2DAdapter
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- Overrides:
fillArc
in classAbstractGraphics2DAdapter
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
- Overrides:
drawPolyline
in classAbstractGraphics2DAdapter
-
fillPolygon
public void fillPolygon(java.awt.Polygon p)
- Overrides:
fillPolygon
in classAbstractGraphics2DAdapter
-
drawPolygon
public void drawPolygon(java.awt.Polygon p)
- Overrides:
drawPolygon
in classAbstractGraphics2DAdapter
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
- Overrides:
drawPolygon
in classAbstractGraphics2DAdapter
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
- Overrides:
fillPolygon
in classAbstractGraphics2DAdapter
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.awt.Graphics
-
-