java.lang.Object
org.rrd4j.graph.RrdGraph
All Implemented Interfaces:
RrdGraphConstants

public class RrdGraphextends Object implements RrdGraphConstants
Class which actually creates Rrd4j graphs (does the hard work).
  • Field Details

    • gdef

      final RrdGraphDef gdef
      The definition describing what this graph plots.
    • im

      final ImageParameters im
      The dimensions and text layout of the rendered image.
    • info

      private final RrdGraphInfo info
      Metadata about the graph, such as its value range and time bounds.
  • Constructor Details

    • RrdGraph

      public RrdGraph(RrdGraphDef gdef) throws IOException
      Creates graph from the corresponding RrdGraphDef object.
      Parameters:
      gdef - the graph definition to render
      Throws:
      IOException - Thrown in case of I/O error
    • RrdGraph

      public RrdGraph(RrdGraphDef gdef, ImageWorker worker) throws IOException
      Create graph from a custom image worker
      Parameters:
      gdef - the graph definition to render
      worker - the image worker painting the graph, replacing the default one
      Throws:
      IOException - Thrown in case of I/O error
    • RrdGraph

      public RrdGraph(RrdGraphDef gdef, ImageWriter writer, ImageWriteParam param) throws IOException
      Creates graph from the corresponding RrdGraphDef object.

      The graph will be created using customs ImageWriter and ImageWriteParam given.

      The ImageWriter type and ImageWriteParam settings have priority other the RrdGraphDef settings.

      Parameters:
      gdef - the graph definition to render
      writer - the ImageWriter that encodes the graph
      param - the encoder settings applied by that writer
      Throws:
      IOException - Thrown in case of I/O error
    • RrdGraph

      private RrdGraph(RrdGraphDef gdef, java.util.function.Supplier<ImageWorker> worker) throws IOException
      Builds the image for a graph definition.
      Parameters:
      gdef - the graph definition
      worker - supplies the image worker
      Throws:
      IOException - if the image cannot be rendered
  • Method Details

    • generateImageWorker

      private static ImageWorker generateImageWorker(RrdGraphDef gdef, ImageWriter writer, ImageWriteParam param)
      Creates the worker that renders the graph.
      Parameters:
      gdef - the graph definition
      writer - the image writer to render with
      param - the writer parameters, or null
      Returns:
      the worker to render with
    • generateImageWorker

      private static ImageWorker generateImageWorker(RrdGraphDef gdef)
      Generate image worker
      Parameters:
      gdef - the graph definition the worker renders
      Returns:
      the image worker for the definition
    • getRrdGraphInfo

      public RrdGraphInfo getRrdGraphInfo()
      Returns complete graph information in a single object.
      Returns:
      Graph information (width, height, filename, image bytes, etc...)
    • render

      public void render(Graphics g)
      Renders this graph onto graphing device
      Parameters:
      g - Graphics to paint the already-rendered image onto