java.lang.Object
org.rrd4j.graph.ImageWorker
org.rrd4j.graph.SVGImageWorker
I2P adapter for jfreesvg. State deduplication in
ImageWorker handles inline style reduction; SVG element grouping is handled by postProcessSvg consolidation in SVGGraphics2D.Field Summary
FieldsModifier and TypeFieldDescriptionprivate SVGGraphics2DThe graphics context drawing the SVG.private booleanTrue when the graph is drawn with a glow effect.private intImg heightprivate intImg widthprivate booleanTrue when lines are drawn smoothed.private StringConsole theme, reapplied on every resize since that rebuildsg2d.Fields inherited from class ImageWorker
DEFAULT_TRANSITION_WIDTHModifier and TypeFieldDescription(package private) static final intDefault pixels of width given to a transition narrower than one pixel.Constructor Summary
ConstructorsConstructorDescriptionSVGImageWorker(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 MethodsModifier and TypeMethodDescription(package private) voiddrawString(String text, int x, int y, Font font, Paint paint) Draw string(package private) doublegetStringWidth(String text, Font font) Get the width of the given text in the specified font.private voidinitGraphics(int width, int height) Init graphics(package private) voidMake imageprotected voidreset(Graphics2D g2d) Reset the allocator state(package private) voidresize(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, transformModifier and TypeMethodDescription(package private) static intareaOutlineFlat(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 intareaOutlineVariable(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) voidclip(int x, int y, int width, int height) Set the clipping region for drawing operations.(package private) voiddispose()Dispose of the graphics context.(package private) voidDraw a line with the given paint and stroke.(package private) voiddrawPolyline(double[] x, double[] y, Paint paint, Stroke stroke) Draw a polyline with the given paint and stroke.(package private) voiddrawPolylineSmooth(double[] x, double[] y, Paint paint, Stroke stroke) Draw a polyline as a smoothed curve.(package private) voidfillPolygon(double[] x, double[] yBottom, double[] yTop, Paint paint) Fill a polygon with variable bottom points.(package private) voidfillPolygon(double[] x, double yBottom, double[] yTop, Paint paint) Fill a polygon with a flat bottom.(package private) voidfillPolygonSmooth(double[] x, double yBottom, double[] yTop, Paint paint) Fill an area with a flat lower boundary, drawn as a smoothed curve.(package private) voidFill a rectangle with the given paint.(package private) doublegetFontAscent(Font font) Get the ascent of the given font.(package private) doublegetFontHeight(Font font) Get the total height of the given font.(package private) byte[]Get the image as a byte array.(package private) booleanReports whether plots are drawn as bezier curves rather than as steps.(package private) voidloadImage(RrdGraphDef.ImageSource imageSource, int x, int y, int w, int h) Load and draw an image from the given source.(package private) voidWrite the image to the given path.(package private) static intreduceVertices(double[] x, double[] y, int from, int to, boolean reverse, int[] xDev, int[] yDev, int c) Append the step-collapsed vertices ofyover[start, end)intoxDev/yDev, continuing from indexc.(package private) voidreset()Reset the graphics state.protected voidResets cached state tracking.(package private) static intrunAnchorX(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) voidSave the image to the given file path.(package private) voidsetAntiAliasing(boolean enable) Enable or disable anti-aliasing.protected voidsetG2d(Graphics2D g2d) Sets the graphics context for drawing operations.(package private) voidsetSmoothing(boolean smoothing) Selects whether plots are drawn as bezier curves or as steps.(package private) voidsetTextAntiAliasing(boolean enable) Enable or disable text anti-aliasing.(package private) voidsetTransitionWidth(int pixels) Sets how much width a sub-pixel transition may borrow from the flat runs beside it.(package private) static GeneralPathsmoothedRun(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) voidtransform(int x, int y, double angle) Apply a translation and rotation transform.
Field Details
g2d
The graphics context drawing the SVG.themeName
imgWidth
private int imgWidthImg widthimgHeight
private int imgHeightImg heightglow
private boolean glowTrue when the graph is drawn with a glow effect.smoothing
private boolean smoothingTrue when lines are drawn smoothed.
Constructor Details
SVGImageWorker
public SVGImageWorker(int width, int height) Image width in pixels.- Parameters:
width- image width in pixelsheight- image height in pixels
SVGImageWorker
public SVGImageWorker(int width, int height, boolean glow) Image width in pixels.- Parameters:
width- image width in pixelsheight- image height in pixelsglow- 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 pixelsheight- image height in pixelsglow- whether to enable glow effectsmoothing- whether plot paths hold curves, which are antialiased rather than crisp
SVGImageWorker
Image width in pixels.- Parameters:
width- Image width in pixelsheight- Image height in pixelsglow- whether to enable glow effectsmoothing- whether plot paths hold curves, which are antialiased rather than crisptheme- 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 pixelsheight- the image height in pixels
resize
void resize(int width, int height) Reinitializes the drawing surface when the requested size has changed.- Specified by:
resizein classImageWorker- Parameters:
width- the width of the rectangle, in image pixelsheight- the height of the rectangle, in image pixels
reset
Reset the allocator state- Specified by:
resetin classImageWorker- Parameters:
g2d- the graphics context
makeImage
Make image- Specified by:
makeImagein classImageWorker- Parameters:
os- the output stream- Throws:
IOException- if an I/O error occurs
drawString
Draw string- Overrides:
drawStringin classImageWorker- Parameters:
text- the text to drawx- the x coordinatey- the y coordinatefont- the font to render the string inpaint- the color or gradient the glyphs are filled with
getStringWidth
Description copied from class:ImageWorkerGet the width of the given text in the specified font.- Overrides:
getStringWidthin classImageWorker- Parameters:
text- the string to measurefont- the font to measure it in- Returns:
- the string width