Package net.i2p.rrd4j

Class SimpleSVGMaker

java.lang.Object
net.i2p.rrd4j.SimpleSVGMaker

public class SimpleSVGMaker extends Object
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 Details

  • Method Details

    • startSVG

      public void startSVG(int width, int height, Color bgcolor, String id, String clz)
      Start svg tag
      Parameters:
      bgcolor - null for none
      id - CSS id or null for none
      clz - CSS class or null for none
    • endSVG

      public void endSVG()
      End svg tag
    • startGroup

      public void startGroup(String id, String clz, String att, String val)
      Start group
      Parameters:
      id - CSS id or null for none
      clz - CSS class or null for none
      att - an attribute to add att=val, e.g. "transform", or null for none
      val - an attribute to add att=val, or null for none
    • endGroup

      public void endGroup()
      End group
    • defineClipPath

      public String defineClipPath(Rectangle clip)
      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 none
      fill - null for none
      clipid - as returned from defineClipID() or null for none
      hints - 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 none
      fill - null for none
      clipid - as returned from defineClipID() or null for none
      hints - 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 none
      fill - null for none
      hints - 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 it
      clipid - as returned from defineClipID() or null for none
      hints - 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 it
      clipid - as returned from defineClipID() or null for none
      hints - 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 it
      clipid - as returned from defineClipID() or null for none
      hints - 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 it
      font - null to let CSS do it
      clipid - as returned from defineClipID() or null for none
      hints - non-null