Package net.i2p.rrd4j
Class SimpleSVGMaker
java.lang.Object
net.i2p.rrd4j.SimpleSVGMaker
Create full or partial SVG images, without dependencies.
Does not extend or use Graphics2D or ImageWriter.
Each drawn element can be passed an optional CSS ID and/or classes,
for easy styling and manipulation via CSS or js.
All parameters are set as attributes, not as inline style,
so a separate CSS style may easily override them.
If inline style is desired, add it with the KEY_ELEMENT_ATTMAP hint.
Unlike in Graphics2D, the border and fill for an object may be drawn in
the same call, with separate colors.
There is no state here other than the StringBuffer;
there is no concept of current Color or Stroke or Font;
caller must keep track of current Colors, Stroke, and Font, and pass them in
on every draw() call, and/or overridden via CSS.
License: Apache 2.0 (same as rrd4j)
- Since:
- 0.9.64
- Author:
- zzz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefineClipPath
(Rectangle clip) Define clip pathvoid
drawCircle
(int x, int y, int radius, Color border, Color fill, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw circle centered on x,y with a radius givenvoid
drawLine
(int x1, int y1, int x2, int y2, Color color, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw linevoid
drawPolyline
(int[] x, int[] y, int sz, Color color, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw polylinevoid
drawRect
(int x, int y, int width, int height, Color border, Color fill, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw rectvoid
drawSquare
(int x, int y, int sz, Color border, Color fill, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw square centered on x,y with a width/height givenvoid
drawText
(String text, int x, int y, Color color, Font font, String clipid, Map<Object, Object> hints) Draw textvoid
endGroup()
End groupvoid
endSVG()
End svg tagvoid
Fill polygonvoid
startGroup
(String id, String clz, String att, String val) Start groupvoid
Start svg tag
-
Constructor Details
-
SimpleSVGMaker
-
-
Method Details
-
startSVG
Start svg tag- Parameters:
bgcolor
- null for noneid
- CSS id or null for noneclz
- CSS class or null for none
-
endSVG
public void endSVG()End svg tag -
startGroup
Start group- Parameters:
id
- CSS id or null for noneclz
- CSS class or null for noneatt
- an attribute to add att=val, e.g. "transform", or null for noneval
- an attribute to add att=val, or null for none
-
endGroup
public void endGroup()End group -
defineClipPath
Define clip path- Returns:
- a unique ID to pass to draw() calls
-
drawCircle
public void drawCircle(int x, int y, int radius, Color border, Color fill, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw circle centered on x,y with a radius given- Parameters:
border
- null for nonefill
- null for noneclipid
- as returned from defineClipID() or null for nonehints
- non-null
-
drawSquare
public void drawSquare(int x, int y, int sz, Color border, Color fill, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw square centered on x,y with a width/height given- Parameters:
border
- null for nonefill
- null for noneclipid
- as returned from defineClipID() or null for nonehints
- non-null
-
drawRect
public void drawRect(int x, int y, int width, int height, Color border, Color fill, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw rect- Parameters:
border
- null for nonefill
- null for nonehints
- non-null
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2, Color color, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw line- Parameters:
color
- null to let CSS do itclipid
- as returned from defineClipID() or null for nonehints
- non-null
-
drawPolyline
public void drawPolyline(int[] x, int[] y, int sz, Color color, BasicStroke stroke, String clipid, Map<Object, Object> hints) Draw polyline- Parameters:
color
- null to let CSS do itclipid
- as returned from defineClipID() or null for nonehints
- non-null
-
fillPolygon
public void fillPolygon(int[] x, int[] y, int sz, Color color, String clipid, Map<Object, Object> hints) Fill polygon- Parameters:
color
- null to let CSS do itclipid
- as returned from defineClipID() or null for nonehints
- non-null
-
drawText
public void drawText(String text, int x, int y, Color color, Font font, String clipid, Map<Object, Object> hints) Draw text- Parameters:
color
- null to let CSS do itfont
- null to let CSS do itclipid
- as returned from defineClipID() or null for nonehints
- non-null
-