Package de.erichseifert.vectorgraphics2d
Class VectorGraphics2D
- java.lang.Object
-
- java.awt.Graphics
-
- java.awt.Graphics2D
-
- de.erichseifert.vectorgraphics2d.VectorGraphics2D
-
- All Implemented Interfaces:
java.lang.Cloneable
public class VectorGraphics2D extends java.awt.Graphics2D implements java.lang.CloneableImplementation of the Graphics2D interface to Java to generate a sequence of commands. An instance of
VectorGraphics2Dcan be used to replace anyGraphics2Dobject. It can be created with its standard constructor:Graphics2D g = new VectorGraphics2D();
-
-
Field Summary
Fields Modifier and Type Field Description private MutableCommandSequencecommandsprivate java.awt.GraphicsConfigurationdeviceConfigDevice configuration settings.private booleandisposedFlag that tells whether this graphics object has been disposed.private java.awt.font.FontRenderContextfontRenderContextContext settings used to render fonts.private GraphicsStatestate
-
Constructor Summary
Constructors Constructor Description VectorGraphics2D()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRenderingHints(java.util.Map<?,?> hints)voidclearRect(int x, int y, int width, int height)voidclip(java.awt.Shape s)voidclipRect(int x, int y, int width, int height)java.lang.Objectclone()voidcopyArea(int x, int y, int width, int height, int dx, int dy)java.awt.Graphicscreate()voiddispose()voiddraw(java.awt.Shape s)voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle)voiddrawGlyphVector(java.awt.font.GlyphVector g, float x, float y)voiddrawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)booleandrawImage(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)booleandrawImage(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)booleandrawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)booleandrawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)booleandrawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)booleandrawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)booleandrawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)voiddrawLine(int x1, int y1, int x2, int y2)voiddrawOval(int x, int y, int width, int height)voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints)voiddrawPolygon(java.awt.Polygon p)voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints)voiddrawRect(int x, int y, int width, int height)voiddrawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)voiddrawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)voiddrawString(java.lang.String str, float x, float y)voiddrawString(java.lang.String str, int x, int y)voiddrawString(java.text.AttributedCharacterIterator iterator, float x, float y)voiddrawString(java.text.AttributedCharacterIterator iterator, int x, int y)private voidemit(Command<?> command)voidfill(java.awt.Shape s)voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle)voidfillOval(int x, int y, int width, int height)voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints)voidfillPolygon(java.awt.Polygon p)voidfillRect(int x, int y, int width, int height)voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)java.awt.ColorgetBackground()java.awt.ShapegetClip()java.awt.RectanglegetClipBounds()java.awt.ColorgetColor()CommandSequencegetCommands()Returns aCommandSequencerepresenting all calls that were issued to thisVectorGraphics2Dobject.java.awt.CompositegetComposite()java.awt.GraphicsConfigurationgetDeviceConfiguration()java.awt.FontgetFont()java.awt.FontMetricsgetFontMetrics(java.awt.Font f)java.awt.font.FontRenderContextgetFontRenderContext()java.awt.PaintgetPaint()java.lang.ObjectgetRenderingHint(java.awt.RenderingHints.Key hintKey)java.awt.RenderingHintsgetRenderingHints()java.awt.StrokegetStroke()java.awt.geom.AffineTransformgetTransform()private java.awt.image.BufferedImagegetTransformedImage(java.awt.Image image, java.awt.geom.AffineTransform xform)Returns a transformed version of an image.java.awt.ColorgetXORMode()booleanhit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)private static java.awt.ShapeintersectShapes(java.awt.Shape s1, java.awt.Shape s2)protected booleanisDisposed()voidrotate(double theta)voidrotate(double theta, double x, double y)voidscale(double sx, double sy)voidsetBackground(java.awt.Color color)voidsetClip(int x, int y, int width, int height)voidsetClip(java.awt.Shape clip)voidsetColor(java.awt.Color c)voidsetComposite(java.awt.Composite comp)voidsetFont(java.awt.Font font)voidsetPaint(java.awt.Paint paint)voidsetPaintMode()voidsetRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)voidsetRenderingHints(java.util.Map<?,?> hints)voidsetStroke(java.awt.Stroke s)voidsetTransform(java.awt.geom.AffineTransform tx)voidsetXORMode(java.awt.Color c1)voidshear(double shx, double shy)voidtransform(java.awt.geom.AffineTransform tx)voidtranslate(double tx, double ty)voidtranslate(int x, int y)
-
-
-
Field Detail
-
commands
private final MutableCommandSequence commands
-
deviceConfig
private final java.awt.GraphicsConfiguration deviceConfig
Device configuration settings.
-
fontRenderContext
private final java.awt.font.FontRenderContext fontRenderContext
Context settings used to render fonts.
-
disposed
private boolean disposed
Flag that tells whether this graphics object has been disposed.
-
state
private GraphicsState state
-
-
Method Detail
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
addRenderingHints
public void addRenderingHints(java.util.Map<?,?> hints)
- Specified by:
addRenderingHintsin classjava.awt.Graphics2D
-
clip
public void clip(java.awt.Shape s)
- Specified by:
clipin classjava.awt.Graphics2D
-
intersectShapes
private static java.awt.Shape intersectShapes(java.awt.Shape s1, java.awt.Shape s2)
-
draw
public void draw(java.awt.Shape s)
- Specified by:
drawin classjava.awt.Graphics2D
-
drawGlyphVector
public void drawGlyphVector(java.awt.font.GlyphVector g, float x, float y)- Specified by:
drawGlyphVectorin classjava.awt.Graphics2D
-
drawImage
public boolean drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)- Specified by:
drawImagein classjava.awt.Graphics2D
-
getTransformedImage
private java.awt.image.BufferedImage getTransformedImage(java.awt.Image image, java.awt.geom.AffineTransform xform)Returns a transformed version of an image.- Parameters:
image- Image to be transformedxform- Affine transform to be applied- Returns:
- Image with transformed content
-
drawImage
public void drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)- Specified by:
drawImagein classjava.awt.Graphics2D
-
drawRenderableImage
public void drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)- Specified by:
drawRenderableImagein classjava.awt.Graphics2D
-
drawRenderedImage
public void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)- Specified by:
drawRenderedImagein classjava.awt.Graphics2D
-
drawString
public void drawString(java.lang.String str, int x, int y)- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.lang.String str, float x, float y)- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)- Specified by:
drawStringin classjava.awt.Graphics2D
-
drawString
public void drawString(java.text.AttributedCharacterIterator iterator, float x, float y)- Specified by:
drawStringin classjava.awt.Graphics2D
-
fill
public void fill(java.awt.Shape s)
- Specified by:
fillin classjava.awt.Graphics2D
-
getBackground
public java.awt.Color getBackground()
- Specified by:
getBackgroundin classjava.awt.Graphics2D
-
getComposite
public java.awt.Composite getComposite()
- Specified by:
getCompositein classjava.awt.Graphics2D
-
getDeviceConfiguration
public java.awt.GraphicsConfiguration getDeviceConfiguration()
- Specified by:
getDeviceConfigurationin classjava.awt.Graphics2D
-
getFontRenderContext
public java.awt.font.FontRenderContext getFontRenderContext()
- Specified by:
getFontRenderContextin classjava.awt.Graphics2D
-
getPaint
public java.awt.Paint getPaint()
- Specified by:
getPaintin classjava.awt.Graphics2D
-
getRenderingHint
public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)
- Specified by:
getRenderingHintin classjava.awt.Graphics2D
-
getRenderingHints
public java.awt.RenderingHints getRenderingHints()
- Specified by:
getRenderingHintsin classjava.awt.Graphics2D
-
getStroke
public java.awt.Stroke getStroke()
- Specified by:
getStrokein classjava.awt.Graphics2D
-
hit
public boolean hit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)- Specified by:
hitin classjava.awt.Graphics2D
-
setBackground
public void setBackground(java.awt.Color color)
- Specified by:
setBackgroundin classjava.awt.Graphics2D
-
setComposite
public void setComposite(java.awt.Composite comp)
- Specified by:
setCompositein classjava.awt.Graphics2D
-
setPaint
public void setPaint(java.awt.Paint paint)
- Specified by:
setPaintin classjava.awt.Graphics2D
-
setRenderingHint
public void setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)- Specified by:
setRenderingHintin classjava.awt.Graphics2D
-
setRenderingHints
public void setRenderingHints(java.util.Map<?,?> hints)
- Specified by:
setRenderingHintsin classjava.awt.Graphics2D
-
setStroke
public void setStroke(java.awt.Stroke s)
- Specified by:
setStrokein classjava.awt.Graphics2D
-
getTransform
public java.awt.geom.AffineTransform getTransform()
- Specified by:
getTransformin classjava.awt.Graphics2D
-
setTransform
public void setTransform(java.awt.geom.AffineTransform tx)
- Specified by:
setTransformin classjava.awt.Graphics2D
-
shear
public void shear(double shx, double shy)- Specified by:
shearin classjava.awt.Graphics2D
-
transform
public void transform(java.awt.geom.AffineTransform tx)
- Specified by:
transformin classjava.awt.Graphics2D
-
translate
public void translate(int x, int y)- Specified by:
translatein classjava.awt.Graphics2D
-
translate
public void translate(double tx, double ty)- Specified by:
translatein classjava.awt.Graphics2D
-
rotate
public void rotate(double theta)
- Specified by:
rotatein classjava.awt.Graphics2D
-
rotate
public void rotate(double theta, double x, double y)- Specified by:
rotatein classjava.awt.Graphics2D
-
scale
public void scale(double sx, double sy)- Specified by:
scalein classjava.awt.Graphics2D
-
clearRect
public void clearRect(int x, int y, int width, int height)- Specified by:
clearRectin classjava.awt.Graphics
-
clipRect
public void clipRect(int x, int y, int width, int height)- Specified by:
clipRectin classjava.awt.Graphics
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy)- Specified by:
copyAreain classjava.awt.Graphics
-
create
public java.awt.Graphics create()
- Specified by:
createin classjava.awt.Graphics
-
dispose
public void dispose()
- Specified by:
disposein classjava.awt.Graphics
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)- Specified by:
drawArcin classjava.awt.Graphics
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)- Specified by:
drawImagein classjava.awt.Graphics
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)- Specified by:
drawImagein classjava.awt.Graphics
-
drawImage
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)- Specified by:
drawImagein classjava.awt.Graphics
-
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)- Specified by:
drawImagein classjava.awt.Graphics
-
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)- Specified by:
drawImagein classjava.awt.Graphics
-
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)- Specified by:
drawImagein classjava.awt.Graphics
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)- Specified by:
drawLinein classjava.awt.Graphics
-
drawOval
public void drawOval(int x, int y, int width, int height)- Specified by:
drawOvalin classjava.awt.Graphics
-
drawPolygon
public void drawPolygon(java.awt.Polygon p)
- Overrides:
drawPolygonin classjava.awt.Graphics
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)- Specified by:
drawPolygonin classjava.awt.Graphics
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)- Specified by:
drawPolylinein classjava.awt.Graphics
-
drawRect
public void drawRect(int x, int y, int width, int height)- Overrides:
drawRectin classjava.awt.Graphics
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)- Specified by:
drawRoundRectin classjava.awt.Graphics
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)- Specified by:
fillArcin classjava.awt.Graphics
-
fillOval
public void fillOval(int x, int y, int width, int height)- Specified by:
fillOvalin classjava.awt.Graphics
-
fillPolygon
public void fillPolygon(java.awt.Polygon p)
- Overrides:
fillPolygonin classjava.awt.Graphics
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)- Specified by:
fillPolygonin classjava.awt.Graphics
-
fillRect
public void fillRect(int x, int y, int width, int height)- Specified by:
fillRectin classjava.awt.Graphics
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)- Specified by:
fillRoundRectin classjava.awt.Graphics
-
getClip
public java.awt.Shape getClip()
- Specified by:
getClipin classjava.awt.Graphics
-
getClipBounds
public java.awt.Rectangle getClipBounds()
- Specified by:
getClipBoundsin classjava.awt.Graphics
-
getColor
public java.awt.Color getColor()
- Specified by:
getColorin classjava.awt.Graphics
-
getFont
public java.awt.Font getFont()
- Specified by:
getFontin classjava.awt.Graphics
-
getFontMetrics
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
- Specified by:
getFontMetricsin classjava.awt.Graphics
-
setClip
public void setClip(java.awt.Shape clip)
- Specified by:
setClipin classjava.awt.Graphics
-
setClip
public void setClip(int x, int y, int width, int height)- Specified by:
setClipin classjava.awt.Graphics
-
setColor
public void setColor(java.awt.Color c)
- Specified by:
setColorin classjava.awt.Graphics
-
setFont
public void setFont(java.awt.Font font)
- Specified by:
setFontin classjava.awt.Graphics
-
setPaintMode
public void setPaintMode()
- Specified by:
setPaintModein classjava.awt.Graphics
-
getXORMode
public java.awt.Color getXORMode()
-
setXORMode
public void setXORMode(java.awt.Color c1)
- Specified by:
setXORModein classjava.awt.Graphics
-
emit
private void emit(Command<?> command)
-
isDisposed
protected boolean isDisposed()
-
getCommands
public CommandSequence getCommands()
Returns aCommandSequencerepresenting all calls that were issued to thisVectorGraphics2Dobject.- Returns:
- Sequence of commands since.
-
-