java.lang.Object
org.rrd4j.graph.LegendComposer.Line
Enclosing class:
LegendComposer

class LegendComposer.Lineextends Object
Line-style graph element with configurable width and color.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final List<CommentText>
    Comment lines waiting to be drawn.
    private Markers
    The marker last processed.
    private boolean
    True to skip right-justifying the values.
    private int
    Leading spaces used to align the current line.
    private double
    Width of the widest legend line so far.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty line, holding no comments and no measured width yet.
  • Method Summary

    Private Methods
    Modifier and Type
    Method
    Description
    (package private) void
    add(CommentText comment)
    Appends a comment, widening the line and recording its marker as the new last marker
    (package private) boolean
    Reports whether the line has room for the comment and may honour its alignment
    (package private) void
    Discards the line's comments and resets its width and marker state
    private double
    Measures a comment line.
    (package private) void
    layoutAndAdvance(boolean isLastLine)
    Places the line's comments according to the last marker and advances the legend y offset
    private void
    placeComments(double xStart, double space)
    Assigns an x and y coordinate to each of the line's comments

    Methods inherited from class Object

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

    • lastMarker

      private Markers lastMarker
      The marker last processed.
    • width

      private double width
      Width of the widest legend line so far.
    • spaceCount

      private int spaceCount
      Leading spaces used to align the current line.
    • noJustification

      private boolean noJustification
      True to skip right-justifying the values.
    • comments

      private final List<CommentText> comments
      Comment lines waiting to be drawn.
  • Constructor Details

    • Line

      Line()
      Creates an empty line, holding no comments and no measured width yet.
  • Method Details

    • clear

      void clear()
      Discards the line's comments and resets its width and marker state
    • canAccommodate

      boolean canAccommodate(CommentText comment)
      Reports whether the line has room for the comment and may honour its alignment
      Parameters:
      comment - the candidate comment, measured against the unused legend width
      Returns:
      true if the line can still hold the comment and honour the current alignment
    • add

      void add(CommentText comment)
      Appends a comment, widening the line and recording its marker as the new last marker
      Parameters:
      comment - the comment to append, whose marker becomes the line's new last marker
    • layoutAndAdvance

      void layoutAndAdvance(boolean isLastLine)
      Places the line's comments according to the last marker and advances the legend y offset
      Parameters:
      isLastLine - true for the legend's closing line, which spreads the comments over the full legend width even when no \J justification marker was given
    • getCommentWidth

      private double getCommentWidth(CommentText comment)
      Measures a comment line.
      Parameters:
      comment - the line to measure
      Returns:
      its width, in pixels
    • placeComments

      private void placeComments(double xStart, double space)
      Assigns an x and y coordinate to each of the line's comments
      Parameters:
      xStart - the x coordinate of the first comment
      space - the gap to leave between consecutive comments