java.lang.Object
org.rrd4j.graph.ImageWorker
org.rrd4j.graph.BufferedImageWorker
Image worker implementation that creates buffered images for RRD graphs. Provides functionality to create, manipulate, and save graph images in various formats.
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classBuilder class for creating BufferedImageWorker instances with configurable parameters.Field Summary
FieldsModifier and TypeFieldDescriptionprivate BufferedImageThe image being written out.private intHeight of the image.private intWidth of the image.private AffineTransformInitial affine transformprivate final ImageWriteParamParameters given to the writer.private final ImageWriterWriter that writes the image out.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
ConstructorsModifierConstructorDescription(package private)BufferedImageWorker(int width, int height) Not for use, only for testsprivateBuilds the worker from its builder.Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImageWorker.BuilderCreates a new builder for BufferedImageWorker.(package private) voidmakeImage(OutputStream stream) Creates and writes the image to the specified output stream.protected voidreset(Graphics2D g2d) Reset the allocator state(package private) voidresize(int width, int height) Resizes the worker to the specified dimensions.Methods inherited from class ImageWorker
areaOutlineFlat, areaOutlineVariable, clip, dispose, drawLine, drawPolyline, drawPolylineSmooth, drawString, fillPolygon, fillPolygon, fillPolygonSmooth, fillRect, getFontAscent, getFontHeight, getImageBytes, getStringWidth, 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) voiddrawString(String text, int x, int y, Font font, Paint paint) Draw a string at the given position with the specified font and paint.(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) doublegetStringWidth(String text, Font font) Get the width of the given text in the specified font.(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
img
The image being written out.imgWidth
private int imgWidthWidth of the image.imgHeight
private int imgHeightHeight of the image.initialAffineTransform
Initial affine transformwriter
Writer that writes the image out.iwp
Parameters given to the writer.
Constructor Details
BufferedImageWorker
Builds the worker from its builder.- Parameters:
builder- the builder holding the image and parameters
BufferedImageWorker
BufferedImageWorker(int width, int height) Not for use, only for tests- Parameters:
width- the width in pixelsheight- the height in pixels
Method Details
getBuilder
Creates a new builder for BufferedImageWorker.- Returns:
- A new builder instance.
resize
void resize(int width, int height) Resizes the worker to the specified dimensions.- Specified by:
resizein classImageWorker- Parameters:
width- The new width in pixels.height- The new height in pixels.
reset
Reset the allocator state- Specified by:
resetin classImageWorker- Parameters:
g2d- the graphics context
makeImage
Creates and writes the image to the specified output stream.- Specified by:
makeImagein classImageWorker- Parameters:
stream- The output stream to write the image to.- Throws:
IOException- If an I/O error occurs during writing.