java.lang.Object
org.rrd4j.graph.ImageWorker
org.rrd4j.graph.SVGImageWorker

public class SVGImageWorkerextends ImageWorker
I2P adapter for jfreesvg. State deduplication in ImageWorker handles inline style reduction; SVG element grouping is handled by postProcessSvg consolidation in SVGGraphics2D.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The graphics context drawing the SVG.
    private boolean
    True when the graph is drawn with a glow effect.
    private int
    Img height
    private int
    Img width
    private boolean
    True when lines are drawn smoothed.
    private String
    Console theme, reapplied on every resize since that rebuilds g2d.

    Fields inherited from class ImageWorker

    DEFAULT_TRANSITION_WIDTH
    Modifier and Type
    Field
    Description
    (package private) static final int
    Default pixels of width given to a transition narrower than one pixel.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SVGImageWorker(int width, int height)
    Image width in pixels.
    SVGImageWorker(int width, int height, boolean glow)
    Image width in pixels.
    SVGImageWorker(int width, int height, boolean glow, boolean smoothing)
    Image width in pixels.
    SVGImageWorker(int width, int height, boolean glow, boolean smoothing, String theme)
    Image width in pixels.
  • Method Summary

    Private Methods
    Modifier and Type
    Method
    Description
    (package private) void
    drawString(String text, int x, int y, Font font, Paint paint)
    Draw string
    (package private) double
    getStringWidth(String text, Font font)
    Get the width of the given text in the specified font.
    private void
    initGraphics(int width, int height)
    Init graphics
    (package private) void
    Make image
    protected void
    Reset the allocator state
    (package private) void
    resize(int width, int height)
    Reinitializes the drawing surface when the requested size has changed.

    Methods inherited from class ImageWorker

    areaOutlineFlat, areaOutlineVariable, clip, dispose, drawLine, drawPolyline, drawPolylineSmooth, fillPolygon, fillPolygon, fillPolygonSmooth, fillRect, getFontAscent, getFontHeight, getImageBytes, isSmoothing, loadImage, makeImage, reduceVertices, reset, resetState, runAnchorX, saveImage, setAntiAliasing, setG2d, setSmoothing, setTextAntiAliasing, setTransitionWidth, smoothedRun, transform
    Modifier and Type
    Method
    Description
    (package private) static int
    areaOutlineFlat(double[] x, double[] yTop, int start, int end, double yBottom, int[] xDev, int[] yDev)
    Builds the closed outline of an area whose lower boundary is the graph baseline.
    (package private) static int
    areaOutlineVariable(double[] x, double[] yBottom, double[] yTop, int start, int end, int[] xDev, int[] yDev)
    Builds the closed outline of an area whose lower boundary is itself a plotted series, as used by stacked plots.
    (package private) void
    clip(int x, int y, int width, int height)
    Set the clipping region for drawing operations.
    (package private) void
    Dispose of the graphics context.
    (package private) void
    drawLine(int x1, int y1, int x2, int y2, Paint paint, Stroke stroke)
    Draw a line with the given paint and stroke.
    (package private) void
    drawPolyline(double[] x, double[] y, Paint paint, Stroke stroke)
    Draw a polyline with the given paint and stroke.
    (package private) void
    drawPolylineSmooth(double[] x, double[] y, Paint paint, Stroke stroke)
    Draw a polyline as a smoothed curve.
    (package private) void
    fillPolygon(double[] x, double[] yBottom, double[] yTop, Paint paint)
    Fill a polygon with variable bottom points.
    (package private) void
    fillPolygon(double[] x, double yBottom, double[] yTop, Paint paint)
    Fill a polygon with a flat bottom.
    (package private) void
    fillPolygonSmooth(double[] x, double yBottom, double[] yTop, Paint paint)
    Fill an area with a flat lower boundary, drawn as a smoothed curve.
    (package private) void
    fillRect(int x, int y, int width, int height, Paint paint)
    Fill a rectangle with the given paint.
    (package private) double
    Get the ascent of the given font.
    (package private) double
    Get the total height of the given font.
    (package private) byte[]
    Get the image as a byte array.
    (package private) boolean
    Reports whether plots are drawn as bezier curves rather than as steps.
    (package private) void
    loadImage(RrdGraphDef.ImageSource imageSource, int x, int y, int w, int h)
    Load and draw an image from the given source.
    (package private) void
    Write the image to the given path.
    (package private) static int
    reduceVertices(double[] x, double[] y, int from, int to, boolean reverse, int[] xDev, int[] yDev, int c)
    Append the step-collapsed vertices of y over [start, end) into xDev/yDev, continuing from index c.
    (package private) void
    Reset the graphics state.
    protected void
    Resets cached state tracking.
    (package private) static int
    runAnchorX(double[] x, int start)
    Leftmost column a run of samples may be drawn at, matching where the step renderer anchors the same run.
    (package private) void
    Save the image to the given file path.
    (package private) void
    setAntiAliasing(boolean enable)
    Enable or disable anti-aliasing.
    protected void
    Sets the graphics context for drawing operations.
    (package private) void
    setSmoothing(boolean smoothing)
    Selects whether plots are drawn as bezier curves or as steps.
    (package private) void
    setTextAntiAliasing(boolean enable)
    Enable or disable text anti-aliasing.
    (package private) void
    setTransitionWidth(int pixels)
    Sets how much width a sub-pixel transition may borrow from the flat runs beside it.
    (package private) static GeneralPath
    smoothedRun(double[] x, double[] y, int start, int end, int[] xDev, int[] yDev, int transitionWidth)
    Builds the smoothed curve through one gap-free run of samples: the run is reduced to step-collapsed vertices, anchored and widened, and then interpolated.
    (package private) void
    transform(int x, int y, double angle)
    Apply a translation and rotation transform.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • g2d

      private SVGGraphics2D g2d
      The graphics context drawing the SVG.
    • themeName

      private String themeName
      Console theme, reapplied on every resize since that rebuilds g2d.
    • imgWidth

      private int imgWidth
      Img width
    • imgHeight

      private int imgHeight
      Img height
    • glow

      private boolean glow
      True when the graph is drawn with a glow effect.
    • smoothing

      private boolean smoothing
      True when lines are drawn smoothed.
  • Constructor Details

    • SVGImageWorker

      public SVGImageWorker(int width, int height)
      Image width in pixels.
      Parameters:
      width - image width in pixels
      height - image height in pixels
    • SVGImageWorker

      public SVGImageWorker(int width, int height, boolean glow)
      Image width in pixels.
      Parameters:
      width - image width in pixels
      height - image height in pixels
      glow - whether to enable glow effect
    • SVGImageWorker

      public SVGImageWorker(int width, int height, boolean glow, boolean smoothing)
      Image width in pixels.
      Parameters:
      width - image width in pixels
      height - image height in pixels
      glow - whether to enable glow effect
      smoothing - whether plot paths hold curves, which are antialiased rather than crisp
    • SVGImageWorker

      public SVGImageWorker(int width, int height, boolean glow, boolean smoothing, String theme)
      Image width in pixels.
      Parameters:
      width - Image width in pixels
      height - Image height in pixels
      glow - whether to enable glow effect
      smoothing - whether plot paths hold curves, which are antialiased rather than crisp
      theme - console theme name, or null to infer it from the plot
  • Method Details

    • initGraphics

      private void initGraphics(int width, int height)
      Init graphics
      Parameters:
      width - the image width in pixels
      height - the image height in pixels
    • resize

      void resize(int width, int height)
      Reinitializes the drawing surface when the requested size has changed.
      Specified by:
      resize in class ImageWorker
      Parameters:
      width - the width of the rectangle, in image pixels
      height - the height of the rectangle, in image pixels
    • reset

      protected void reset(Graphics2D g2d)
      Reset the allocator state
      Specified by:
      reset in class ImageWorker
      Parameters:
      g2d - the graphics context
    • makeImage

      void makeImage(OutputStream os) throws IOException
      Make image
      Specified by:
      makeImage in class ImageWorker
      Parameters:
      os - the output stream
      Throws:
      IOException - if an I/O error occurs
    • drawString

      void drawString(String text, int x, int y, Font font, Paint paint)
      Draw string
      Overrides:
      drawString in class ImageWorker
      Parameters:
      text - the text to draw
      x - the x coordinate
      y - the y coordinate
      font - the font to render the string in
      paint - the color or gradient the glyphs are filled with
    • getStringWidth

      double getStringWidth(String text, Font font)
      Description copied from class: ImageWorker
      Get the width of the given text in the specified font.
      Overrides:
      getStringWidth in class ImageWorker
      Parameters:
      text - the string to measure
      font - the font to measure it in
      Returns:
      the string width