Class PlotParameters

java.lang.Object
edu.cnu.mdi.splot.plot.PlotParameters

public class PlotParameters extends Object
A centralized, mutable set of visual and behavioral parameters used by a PlotCanvas.

Fluent API: All mutator methods (methods that change internal state) return this so calls can be chained, e.g.

 params.setPlotTitle("My Plot").setXLabel("t (s)").setYLabel("V (m/s)").mustIncludeYZero(true).setLegendDrawing(true);
 
  • Constructor Details

    • PlotParameters

      public PlotParameters(PlotCanvas canvas)
      Create plot parameters for a canvas.
      Parameters:
      canvas - the owning canvas (not null)
  • Method Details

    • addRenderHint

      public void addRenderHint(RenderHint hint)
      Add a rendering hint.
      Parameters:
      hint - the hint to add
    • getRenderHints

      public EnumSet<RenderHint> getRenderHints()
      Get the rendering hints.
      Returns:
      the rendering hints
    • setRenderHints

      public void setRenderHints(EnumSet<RenderHint> hints)
      Set the rendering hints.
      Parameters:
      hints - the rendering hints
    • hasRenderHint

      public boolean hasRenderHint(RenderHint hint)
      Check whether a rendering hint is present.
      Parameters:
      hint - the hint to check
      Returns:
      true if the hint is present
    • isBarPlot

      public boolean isBarPlot()
      Check whether bar plot rendering is requested.
      Returns:
      true if bar plot rendering is requested
    • isLogZ

      public boolean isLogZ()
      Check whether Z values (heatmap intensity) are displayed on a log10 scale. Applies to heatmap/2D histogram rendering only.
      Returns:
      true if log10 scaling is used for Z/intensity
    • showEmptyBins

      public boolean showEmptyBins()
      Check whether to show empty bins in heatmap/2D histogram rendering.
      Returns:
      true to show empty bins
    • getColorMap

      public ScientificColorMap getColorMap()
      Get the color scale for Z values (heatmap intensity). Applies to heatmap/2D histogram rendering only.
      Returns:
      the Z color scale
    • setColorMap

      public PlotParameters setColorMap(ScientificColorMap colorMap)
      Set the color scale for Z values (heatmap intensity). Applies to heatmap/2D histogram rendering only.
      Parameters:
      colorMap - the Z color scale (null ignored)
      Returns:
      this parameters instance (for chaining)
    • setLogZ

      public PlotParameters setLogZ(boolean logZ)
      Set whether Z values (heatmap intensity) are displayed on a log10 scale. Applies to heatmap/2D histogram rendering only.
      Parameters:
      logZ - true for log10 scaling of Z/intensity
      Returns:
      this parameters instance (for chaining)
    • setShowEmptyBins

      public void setShowEmptyBins(boolean showEmptyBins)
      Set whether to show empty bins in heatmap/2D histogram rendering.
      Parameters:
      showEmptyBins - true to show empty bins
    • includeXZero

      public PlotParameters includeXZero(boolean incZero)
      Force the plot to include x = 0 when determining x-axis limits.
      Parameters:
      incZero - the flag
      Returns:
      this parameters instance (for chaining)
    • includeYZero

      public PlotParameters includeYZero(boolean incZero)
      Force the plot to include y = 0 when determining y-axis limits.
      Parameters:
      incZero - the flag
      Returns:
      this parameters instance (for chaining)
    • getXScale

      public PlotParameters.AxisScale getXScale()
      Returns:
      x-axis scale (linear or log10).
    • setXScale

      public PlotParameters setXScale(PlotParameters.AxisScale scale)
      Set the x-axis scale. Requests that the owning canvas recompute the world system.
      Parameters:
      scale - new scale (null treated as LINEAR)
      Returns:
      this parameters instance (for chaining)
    • getYScale

      public PlotParameters.AxisScale getYScale()
      Returns:
      y-axis scale (linear or log10).
    • setYScale

      public PlotParameters setYScale(PlotParameters.AxisScale scale)
      Set the y-axis scale. Requests that the owning canvas recompute the world system.
      Parameters:
      scale - new scale (null treated as LINEAR)
      Returns:
      this parameters instance (for chaining)
    • isXLog

      public boolean isXLog()
      Convenience: @return true if x axis is log10.
    • isYLog

      public boolean isYLog()
      Convenience: @return true if y axis is log10.
    • getExtraStrings

      public String[] getExtraStrings()
      Get the extra strings for a second legend-like display.
      Returns:
      the extra strings (may be null)
    • setExtraStrings

      public PlotParameters setExtraStrings(String... extraStrings)
      Set the extra strings for a second legend-like display.
      Parameters:
      extraStrings - the new extra strings array (may be null)
      Returns:
      this parameters instance (for chaining)
    • isReverseXaxis

      public boolean isReverseXaxis()
      Check whether to reverse the x axis.
      Returns:
      true if the x axis is reversed
    • setReverseXaxis

      public PlotParameters setReverseXaxis(boolean reverseXaxis)
      Set whether to reverse the x axis.
      Parameters:
      reverseXaxis - true to reverse the x axis
      Returns:
      this parameters instance (for chaining)
    • isReverseYaxis

      public boolean isReverseYaxis()
      Check whether to reverse the y axis.
      Returns:
      true if the y axis is reversed
    • setReverseYaxis

      public PlotParameters setReverseYaxis(boolean reverseYaxis)
      Set whether to reverse the y axis.
      Parameters:
      reverseYaxis - true to reverse the y axis
      Returns:
      this parameters instance (for chaining)
    • extraBorder

      public boolean extraBorder()
      Check whether the extra text border is drawn.
      Returns:
      true if the extra text border is drawn
    • setExtraBorder

      public PlotParameters setExtraBorder(boolean extraBorder)
      Set whether the extra text border is drawn.
      Parameters:
      extraBorder - true if the extra text border is drawn
      Returns:
      this parameters instance (for chaining)
    • isLegendBorder

      public boolean isLegendBorder()
      Check whether the legend border is drawn.
      Returns:
      true if the legend border is drawn
    • setLegendBorder

      public PlotParameters setLegendBorder(boolean legBorder)
      Set whether the legend border is drawn.
      Parameters:
      legBorder - true if the legend border is drawn
      Returns:
      this parameters instance (for chaining)
    • setTextBackground

      public PlotParameters setTextBackground(Color color)
      Set the legend fill/background color.
      Parameters:
      color - the legend fill color
      Returns:
      this parameters instance (for chaining)
    • getTextBackground

      public Color getTextBackground()
      Get the legend fill/background color.
      Returns:
      the legend fill color
    • setTextForeground

      public PlotParameters setTextForeground(Color color)
      Set the legend text color.
      Parameters:
      color - the legend text color
      Returns:
      this parameters instance (for chaining)
    • getTextForeground

      public Color getTextForeground()
      Get the legend text color.
      Returns:
      the legend text color
    • getTextBorderColor

      public Color getTextBorderColor()
      Get the legend border color.
      Returns:
      the legend border color
    • setTextBorderColor

      public PlotParameters setTextBorderColor(Color color)
      Set the legend border color.
      Parameters:
      color - the legend border color
      Returns:
      this parameters instance (for chaining)
    • setLegendFont

      public PlotParameters setLegendFont(Font font)
      Set the legend font.
      Parameters:
      font - the legend font
      Returns:
      this parameters instance (for chaining)
    • getTextFont

      public Font getTextFont()
      Get the legend font.
      Returns:
      the legend font
    • setExtraBackground

      public PlotParameters setExtraBackground(Color color)
      Set the extra text fill/background color.
      Parameters:
      color - the extra text fill color
      Returns:
      this parameters instance (for chaining)
    • getExtraBackground

      public Color getExtraBackground()
      Get the extra text fill/background color.
      Returns:
      the extra text fill color
    • setExtraForeground

      public PlotParameters setExtraForeground(Color color)
      Set the extra text color.
      Parameters:
      color - the extra text color
      Returns:
      this parameters instance (for chaining)
    • getExtraForeground

      public Color getExtraForeground()
      Get the extra text color.
      Returns:
      the extra text color
    • getExtraBorderColor

      public Color getExtraBorderColor()
      Get the extra text border color.
      Returns:
      the extra text border color
    • setExtraBorderColor

      public PlotParameters setExtraBorderColor(Color color)
      Set the extra text border color.
      Parameters:
      color - the extra text border color
      Returns:
      this parameters instance (for chaining)
    • setExtraFont

      public PlotParameters setExtraFont(Font font)
      Set the extra text font.
      Parameters:
      font - the new extra text font
      Returns:
      this parameters instance (for chaining)
    • getExtraFont

      public Font getExtraFont()
      Get the extra text font.
      Returns:
      the extra text font
    • setTitleFont

      public PlotParameters setTitleFont(Font font)
      Set the title font.
      Parameters:
      font - the new title font
      Returns:
      this parameters instance (for chaining)
    • getTitleFont

      public Font getTitleFont()
      Get the title font.
      Returns:
      the title font
    • setAxesFont

      public PlotParameters setAxesFont(Font font)
      Set the axes label font.
      Parameters:
      font - the new axes font
      Returns:
      this parameters instance (for chaining)
    • getAxesFont

      public Font getAxesFont()
      Get the axes label font.
      Returns:
      the axes font
    • setStatusFont

      public PlotParameters setStatusFont(Font font)
      Set the status font.
      Parameters:
      font - the new status font
      Returns:
      this parameters instance (for chaining)
    • getStatusFont

      public Font getStatusFont()
      Get the status font.
      Returns:
      the status font
    • setLegendLineLength

      public PlotParameters setLegendLineLength(int legLineLen)
      Set the legend line length.
      Parameters:
      legLineLen - the line length in pixels
      Returns:
      this parameters instance (for chaining)
    • getLegendLineLength

      public int getLegendLineLength()
      Get the legend line length.
      Returns:
      the line length in pixels
    • includeXZero

      public boolean includeXZero()
      Check whether to include x = 0.
      Returns:
      true if we should include x = 0
    • includeYZero

      public boolean includeYZero()
      Check whether to include y = 0.
      Returns:
      true if we should include y = 0
    • addPlotLine

      public PlotParameters addPlotLine(PlotLine line)
      Add a plot line (annotation) to the plot. If the line is already present, it is moved to the end (top) of the internal list.
      Parameters:
      line - the line to add
      Returns:
      this parameters instance (for chaining)
    • removePlotLine

      public PlotParameters removePlotLine(PlotLine line)
      Remove a plot line (annotation) from the plot.
      Parameters:
      line - the line to remove
      Returns:
      this parameters instance (for chaining)
    • clearPlotLines

      public void clearPlotLines()
      Clear all plot lines (annotations).
    • getPlotLines

      public Vector<PlotLine> getPlotLines()
      Get all plot lines (annotations).
      Returns:
      all plot lines (live collection)
    • getPlotTitle

      public String getPlotTitle()
      Get the plot title.
      Returns:
      the plot title
    • setPlotTitle

      public PlotParameters setPlotTitle(String title)
      Set the plot title and notify listeners via the owning PlotCanvas.
      Parameters:
      title - the plot title
      Returns:
      this parameters instance (for chaining)
    • getXLabel

      public String getXLabel()
      Get the label for the x axis.
      Returns:
      the x axis label
    • getYLabel

      public String getYLabel()
      Get the label for the y axis.
      Returns:
      the y axis label
    • setXLabel

      public PlotParameters setXLabel(String label)
      Set the x axis label and notify listeners via the owning PlotCanvas.
      Parameters:
      label - the plot x axis label
      Returns:
      this parameters instance (for chaining)
    • setYLabel

      public PlotParameters setYLabel(String label)
      Set the y axis label and notify listeners via the owning PlotCanvas.
      Parameters:
      label - the plot y axis label
      Returns:
      this parameters instance (for chaining)
    • extraDrawing

      public boolean extraDrawing()
      Check whether we should draw the extra text block.
      Returns:
      whether we should draw the extra text block
    • setExtraDrawing

      public PlotParameters setExtraDrawing(boolean draw)
      Set whether we should draw the extra text block.
      Parameters:
      draw - the new drawing flag
      Returns:
      this parameters instance (for chaining)
    • isLegendDrawn

      public boolean isLegendDrawn()
      Check whether we should draw a legend.
      Returns:
      whether we should draw a legend
    • setLegendDrawing

      public PlotParameters setLegendDrawing(boolean draw)
      Set whether we should draw a legend.
      Parameters:
      draw - the new drawing flag
      Returns:
      this parameters instance (for chaining)
    • getNumDecimalX

      public int getNumDecimalX()
      The number of decimals for tick values on the x axis.
      Returns:
      the number of decimals for tick values on the x axis
    • setNumDecimalX

      public PlotParameters setNumDecimalX(int numDecimalX)
      Set the number of decimals for tick values on the x axis.
      Parameters:
      numDecimalX - the number of decimals to use on the x axis
      Returns:
      this parameters instance (for chaining)
    • getMinExponentX

      public int getMinExponentX()
      The exponent where we switch to scientific notation on the x axis.
      Returns:
      the exponent threshold for scientific notation on the x axis
    • setMinExponentX

      public PlotParameters setMinExponentX(int minExponentX)
      Set the exponent where we switch to scientific notation on the x axis.
      Parameters:
      minExponentX - the exponent threshold for scientific notation on the x axis
      Returns:
      this parameters instance (for chaining)
    • getNumDecimalY

      public int getNumDecimalY()
      The number of decimals for tick values on the y axis.
      Returns:
      the number of decimals for tick values on the y axis
    • setNumDecimalY

      public PlotParameters setNumDecimalY(int numDecimalY)
      Set the number of decimals for tick values on the y axis.
      Parameters:
      numDecimalY - the number of decimals to use on the y axis
      Returns:
      this parameters instance (for chaining)
    • getMinExponentY

      public int getMinExponentY()
      The exponent where we switch to scientific notation on the y axis.
      Returns:
      the exponent threshold for scientific notation on the y axis
    • setMinExponentY

      public PlotParameters setMinExponentY(int minExponentY)
      Set the exponent where we switch to scientific notation on the y axis.
      Parameters:
      minExponentY - the exponent threshold for scientific notation on the y axis
      Returns:
      this parameters instance (for chaining)
    • setXRange

      public PlotParameters setXRange(double xmin, double xmax)
      Manually set the x range.

      This forces setXLimitsMethod(LimitsMethod) to LimitsMethod.MANUALLIMITS and requests that the owning canvas recompute the world coordinate system.

      Parameters:
      xmin - the minimum x
      xmax - the maximum x
      Returns:
      this parameters instance (for chaining)
    • setYRange

      public PlotParameters setYRange(double ymin, double ymax)
      Manually set the y range.

      This forces setYLimitsMethod(LimitsMethod) to LimitsMethod.MANUALLIMITS and requests that the owning canvas recompute the world coordinate system.

      Parameters:
      ymin - the minimum y
      ymax - the maximum y
      Returns:
      this parameters instance (for chaining)
    • getManualXMin

      public double getManualXMin()
      Get the minimum value for a manual X range.
      Returns:
      the minimum x (may be Double.NaN if not manually set)
    • getManualXMax

      public double getManualXMax()
      Get the maximum value for a manual X range.
      Returns:
      the maximum x (may be Double.NaN if not manually set)
    • getManualYMin

      public double getManualYMin()
      Get the minimum value for a manual Y range.
      Returns:
      the minimum y (may be Double.NaN if not manually set)
    • getManualYMax

      public double getManualYMax()
      Get the maximum value for a manual Y range.
      Returns:
      the maximum y (may be Double.NaN if not manually set)
    • getXLimitsMethod

      public LimitsMethod getXLimitsMethod()
      Get the limit method for the x axis.
      Returns:
      the limit method for the x axis
    • setXLimitsMethod

      public PlotParameters setXLimitsMethod(LimitsMethod method)
      Set the limits method for the x axis.
      Parameters:
      method - the method
      Returns:
      this parameters instance (for chaining)
    • getYLimitsMethod

      public LimitsMethod getYLimitsMethod()
      Get the limit method for the y axis.
      Returns:
      the limit method for the y axis
    • setYLimitsMethod

      public PlotParameters setYLimitsMethod(LimitsMethod method)
      Set the limits method for the y axis.
      Parameters:
      method - the method
      Returns:
      this parameters instance (for chaining)