Package net.i2p.rrd4j
Class SimpleSVGGraphics2D
- java.lang.Object
-
- java.awt.Graphics
-
- java.awt.Graphics2D
-
- net.i2p.rrd4j.SimpleSVGGraphics2D
-
public class SimpleSVGGraphics2D extends Graphics2D
Very simple SVGGraphics2D, only enough for basic rrd4j use, without dependencies. Plus a few things that rrd4j doesn't use, but not much. Unsupported things will throw UnsupportedOperationExceptions. Supports custom RenderingHints for id and class on top-level svg element. Supports custom RenderingHints for id, class, title, and arbitrary attributes on all drawn elements. Supports custom RenderingHints for inner SVG on all drawn elements except text. No standard Java AWT hints are supported. Antialiasing is done automatically. Antialiasing hints have no effect. License: Apache 2.0 (same as rrd4j)- Since:
- 0.9.64
- Author:
- zzz
-
-
Field Summary
Fields Modifier and Type Field Description static RenderingHints.Key
KEY_ELEMENT_ATTMAP
Value is a Map of String to String of extra attributes on the next element drawn, one-shot, will be removed after rendering.static RenderingHints.Key
KEY_ELEMENT_CLASS
On the next element drawn, one-shot, will be removed after rendering.static RenderingHints.Key
KEY_ELEMENT_ID
On the next element drawn, one-shot, will be removed after rendering.static RenderingHints.Key
KEY_ELEMENT_INNERSVG
Put "inside" the next element drawn, one-shot, will be removed after rendering.static RenderingHints.Key
KEY_ELEMENT_TITLE
On the next element drawn, one-shot, will be removed after rendering.static RenderingHints.Key
KEY_SVG_CLASS
On the top svg element.static RenderingHints.Key
KEY_SVG_ID
On the top svg element.static RenderingHints.Key
KEY_SVG_TITLE
On the top svg element.
-
Constructor Summary
Constructors Constructor Description SimpleSVGGraphics2D(int width, int height)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRenderingHints(Map<?,?> hints)
void
append(String s)
Graphics2D API bypass, advanced use onlyvoid
clearRect(int x, int y, int width, int height)
void
clip(Shape s)
void
clipRect(int x, int y, int width, int height)
void
copyArea(int x, int y, int width, int height, int dx, int dy)
Graphics
create()
void
dispose()
void
draw(Shape s)
void
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Circles only for now, must be width == height and arcAngle == 360 Otherwise throws UnsupportedOperationException TODOvoid
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 obs)
boolean
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver obs)
boolean
drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver obs)
boolean
drawImage(Image img, int x, int y, int width, int height, ImageObserver obs)
boolean
drawImage(Image img, int x, int y, Color bgcolor, ImageObserver obs)
boolean
drawImage(Image img, int x, int y, ImageObserver obs)
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
fill(Shape s)
void
fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Circles only for now, must be width == height and arcAngle == 360 Otherwise throws UnsupportedOperationException TODOvoid
fillOval(int x, int y, int width, int height)
void
fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
void
fillPolyline(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)
Color
getBackground()
Shape
getClip()
Rectangle
getClipBounds()
Color
getColor()
Composite
getComposite()
GraphicsConfiguration
getDeviceConfiguration()
Font
getFont()
FontMetrics
getFontMetrics(Font f)
FontRenderContext
getFontRenderContext()
SimpleSVGMaker
getMaker()
Graphics2D API bypass, advanced use onlyPaint
getPaint()
Object
getRenderingHint(RenderingHints.Key hintKey)
RenderingHints
getRenderingHints()
Stroke
getStroke()
String
getSVG()
AffineTransform
getTransform()
boolean
hit(Rectangle rect, Shape s, boolean onStroke)
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
setClip(Shape clip)
void
setColor(Color color)
void
setComposite(Composite comp)
void
setFont(Font font)
void
setPaint(Paint paint)
void
setPaintMode()
void
setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
void
setRenderingHints(Map<?,?> hints)
void
setStroke(Stroke stroke)
void
setTransform(AffineTransform tx)
void
setXORMode(Color color)
void
shear(double shx, double shy)
void
transform(AffineTransform tx)
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
create, drawBytes, drawChars, drawPolygon, drawRect, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
-
-
-
Field Detail
-
KEY_SVG_ID
public static final RenderingHints.Key KEY_SVG_ID
On the top svg element. Value is a string and will be XML-escaped when rendering.
-
KEY_SVG_CLASS
public static final RenderingHints.Key KEY_SVG_CLASS
On the top svg element. Value is a string and will be XML-escaped when rendering.
-
KEY_SVG_TITLE
public static final RenderingHints.Key KEY_SVG_TITLE
On the top svg element. Value is a string and will be XML-escaped when rendering.
-
KEY_ELEMENT_ID
public static final RenderingHints.Key KEY_ELEMENT_ID
On the next element drawn, one-shot, will be removed after rendering. Value is a string and will be XML-escaped when rendering.
-
KEY_ELEMENT_CLASS
public static final RenderingHints.Key KEY_ELEMENT_CLASS
On the next element drawn, one-shot, will be removed after rendering. Value is a string and will be XML-escaped when rendering.
-
KEY_ELEMENT_ATTMAP
public static final RenderingHints.Key KEY_ELEMENT_ATTMAP
Value is a Map of String to String of extra attributes on the next element drawn, one-shot, will be removed after rendering. Map keys must be XML-escaped by caller if necessary. Map values will be XML-escaped when rendering.
-
KEY_ELEMENT_TITLE
public static final RenderingHints.Key KEY_ELEMENT_TITLE
On the next element drawn, one-shot, will be removed after rendering. Value is a string and will be XML-escaped when rendering.
-
KEY_ELEMENT_INNERSVG
public static final RenderingHints.Key KEY_ELEMENT_INNERSVG
Put "inside" the next element drawn, one-shot, will be removed after rendering. Value is an XML string and must be XML-escaped by caller if necessary.
-
-
Method Detail
-
getSVG
public String getSVG()
-
getMaker
public SimpleSVGMaker getMaker()
Graphics2D API bypass, advanced use only
-
append
public void append(String s)
Graphics2D API bypass, advanced use only
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)
-
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
- Specified by:
drawPolyline
in classGraphics
-
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)
-
drawString
public void drawString(String str, int x, int y)
- Specified by:
drawString
in classGraphics2D
-
drawString
public void drawString(String str, float x, float y)
- Specified by:
drawString
in classGraphics2D
-
getFontRenderContext
public FontRenderContext getFontRenderContext()
- Specified by:
getFontRenderContext
in classGraphics2D
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Circles only for now, must be width == height and arcAngle == 360 Otherwise throws UnsupportedOperationException TODO
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Circles only for now, must be width == height and arcAngle == 360 Otherwise throws UnsupportedOperationException TODO
-
clearRect
public void clearRect(int x, int y, int width, int height)
-
draw
public void draw(Shape s)
- Specified by:
draw
in classGraphics2D
-
fill
public void fill(Shape s)
- Specified by:
fill
in classGraphics2D
-
setClip
public void setClip(int x, int y, int width, int height)
-
translate
public void translate(int x, int y)
- Specified by:
translate
in classGraphics2D
-
translate
public void translate(double tx, double ty)
- Specified by:
translate
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
-
shear
public void shear(double shx, double shy)
- Specified by:
shear
in classGraphics2D
-
setTransform
public void setTransform(AffineTransform tx)
- Specified by:
setTransform
in classGraphics2D
-
getTransform
public AffineTransform getTransform()
- Specified by:
getTransform
in classGraphics2D
-
setPaint
public void setPaint(Paint paint)
- Specified by:
setPaint
in classGraphics2D
-
setStroke
public void setStroke(Stroke stroke)
- Specified by:
setStroke
in classGraphics2D
-
setBackground
public void setBackground(Color color)
- Specified by:
setBackground
in classGraphics2D
-
getBackground
public Color getBackground()
- Specified by:
getBackground
in classGraphics2D
-
getClipBounds
public Rectangle getClipBounds()
- Specified by:
getClipBounds
in classGraphics
-
getPaint
public Paint getPaint()
- Specified by:
getPaint
in classGraphics2D
-
getStroke
public Stroke getStroke()
- Specified by:
getStroke
in classGraphics2D
-
addRenderingHints
public void addRenderingHints(Map<?,?> hints)
- Specified by:
addRenderingHints
in classGraphics2D
-
getRenderingHint
public Object getRenderingHint(RenderingHints.Key hintKey)
- Specified by:
getRenderingHint
in classGraphics2D
-
setRenderingHint
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
- Specified by:
setRenderingHint
in classGraphics2D
-
setRenderingHints
public void setRenderingHints(Map<?,?> hints)
- Specified by:
setRenderingHints
in classGraphics2D
-
clipRect
public void clipRect(int x, int y, int width, int height)
-
clip
public void clip(Shape s)
- Specified by:
clip
in classGraphics2D
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy)
-
drawGlyphVector
public void drawGlyphVector(GlyphVector g, float x, float y)
- Specified by:
drawGlyphVector
in classGraphics2D
-
drawImage
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
- Specified by:
drawImage
in classGraphics2D
-
drawImage
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
- Specified by:
drawImage
in classGraphics2D
-
drawImage
public boolean drawImage(Image img, int x, int y, ImageObserver obs)
-
drawImage
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver obs)
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver obs)
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver obs)
-
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver obs)
-
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 obs)
-
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
-
drawRenderableImage
public void drawRenderableImage(RenderableImage img, AffineTransform xform)
- Specified by:
drawRenderableImage
in classGraphics2D
-
drawRenderedImage
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
- Specified by:
drawRenderedImage
in classGraphics2D
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- Specified by:
drawRoundRect
in classGraphics
-
drawString
public void drawString(AttributedCharacterIterator iterator, float x, float y)
- Specified by:
drawString
in classGraphics2D
-
drawString
public void drawString(AttributedCharacterIterator iterator, int x, int y)
- Specified by:
drawString
in classGraphics2D
-
fillOval
public void fillOval(int x, int y, int width, int height)
-
fillPolyline
public void fillPolyline(int[] xPoints, int[] yPoints, int nPoints)
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- Specified by:
fillRoundRect
in classGraphics
-
getComposite
public Composite getComposite()
- Specified by:
getComposite
in classGraphics2D
-
getDeviceConfiguration
public GraphicsConfiguration getDeviceConfiguration()
- Specified by:
getDeviceConfiguration
in classGraphics2D
-
getFontMetrics
public FontMetrics getFontMetrics(Font f)
- Specified by:
getFontMetrics
in classGraphics
-
getRenderingHints
public RenderingHints getRenderingHints()
- Specified by:
getRenderingHints
in classGraphics2D
-
hit
public boolean hit(Rectangle rect, Shape s, boolean onStroke)
- Specified by:
hit
in classGraphics2D
-
setComposite
public void setComposite(Composite comp)
- Specified by:
setComposite
in classGraphics2D
-
setPaintMode
public void setPaintMode()
- Specified by:
setPaintMode
in classGraphics
-
setXORMode
public void setXORMode(Color color)
- Specified by:
setXORMode
in classGraphics
-
transform
public void transform(AffineTransform tx)
- Specified by:
transform
in classGraphics2D
-
-