Package edu.cnu.mdi.splot.plot
Class PlotParameters
java.lang.Object
edu.cnu.mdi.splot.plot.PlotParameters
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);
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPlotLine(PlotLine line) Add a plot line (annotation) to the plot.voidaddRenderHint(RenderHint hint) Add a rendering hint.voidClear all plot lines (annotations).booleanCheck whether the extra text border is drawn.booleanCheck whether we should draw the extra text block.Get the axes label font.Get the color scale for Z values (heatmap intensity).Get the extra text fill/background color.Get the extra text border color.Get the extra text font.Get the extra text color.String[]Get the extra strings for a second legend-like display.intGet the legend line length.doubleGet the maximum value for a manual X range.doubleGet the minimum value for a manual X range.doubleGet the maximum value for a manual Y range.doubleGet the minimum value for a manual Y range.intThe exponent where we switch to scientific notation on the x axis.intThe exponent where we switch to scientific notation on the y axis.intThe number of decimals for tick values on the x axis.intThe number of decimals for tick values on the y axis.Get all plot lines (annotations).Get the plot title.Get the rendering hints.Get the status font.Get the legend fill/background color.Get the legend border color.Get the legend font.Get the legend text color.Get the title font.Get the label for the x axis.Get the limit method for the x axis.Get the label for the y axis.Get the limit method for the y axis.booleanhasRenderHint(RenderHint hint) Check whether a rendering hint is present.booleanCheck whether to includex = 0.includeXZero(boolean incZero) Force the plot to includex = 0when determining x-axis limits.booleanCheck whether to includey = 0.includeYZero(boolean incZero) Force the plot to includey = 0when determining y-axis limits.booleanCheck whether bar plot rendering is requested.booleanCheck whether the legend border is drawn.booleanCheck whether we should draw a legend.booleanisLogZ()Check whether Z values (heatmap intensity) are displayed on a log10 scale.booleanCheck whether to reverse the x axis.booleanCheck whether to reverse the y axis.booleanisXLog()Convenience: @return true if x axis is log10.booleanisYLog()Convenience: @return true if y axis is log10.removePlotLine(PlotLine line) Remove a plot line (annotation) from the plot.setAxesFont(Font font) Set the axes label font.setColorMap(ScientificColorMap colorMap) Set the color scale for Z values (heatmap intensity).setExtraBackground(Color color) Set the extra text fill/background color.setExtraBorder(boolean extraBorder) Set whether the extra text border is drawn.setExtraBorderColor(Color color) Set the extra text border color.setExtraDrawing(boolean draw) Set whether we should draw the extra text block.setExtraFont(Font font) Set the extra text font.setExtraForeground(Color color) Set the extra text color.setExtraStrings(String... extraStrings) Set the extra strings for a second legend-like display.setLegendBorder(boolean legBorder) Set whether the legend border is drawn.setLegendDrawing(boolean draw) Set whether we should draw a legend.setLegendFont(Font font) Set the legend font.setLegendLineLength(int legLineLen) Set the legend line length.setLogZ(boolean logZ) Set whether Z values (heatmap intensity) are displayed on a log10 scale.setMinExponentX(int minExponentX) Set the exponent where we switch to scientific notation on the x axis.setMinExponentY(int minExponentY) Set the exponent where we switch to scientific notation on the y axis.setNumDecimalX(int numDecimalX) Set the number of decimals for tick values on the x axis.setNumDecimalY(int numDecimalY) Set the number of decimals for tick values on the y axis.setPlotTitle(String title) Set the plot title and notify listeners via the owningPlotCanvas.voidsetRenderHints(EnumSet<RenderHint> hints) Set the rendering hints.setReverseXaxis(boolean reverseXaxis) Set whether to reverse the x axis.setReverseYaxis(boolean reverseYaxis) Set whether to reverse the y axis.voidsetShowEmptyBins(boolean showEmptyBins) Set whether to show empty bins in heatmap/2D histogram rendering.setStatusFont(Font font) Set the status font.setTextBackground(Color color) Set the legend fill/background color.setTextBorderColor(Color color) Set the legend border color.setTextForeground(Color color) Set the legend text color.setTitleFont(Font font) Set the title font.Set the x axis label and notify listeners via the owningPlotCanvas.setXLimitsMethod(LimitsMethod method) Set the limits method for the x axis.setXRange(double xmin, double xmax) Manually set the x range.Set the x-axis scale.Set the y axis label and notify listeners via the owningPlotCanvas.setYLimitsMethod(LimitsMethod method) Set the limits method for the y axis.setYRange(double ymin, double ymax) Manually set the y range.Set the y-axis scale.booleanCheck whether to show empty bins in heatmap/2D histogram rendering.
-
Constructor Details
-
PlotParameters
Create plot parameters for a canvas.- Parameters:
canvas- the owning canvas (notnull)
-
-
Method Details
-
addRenderHint
Add a rendering hint.- Parameters:
hint- the hint to add
-
getRenderHints
Get the rendering hints.- Returns:
- the rendering hints
-
setRenderHints
Set the rendering hints.- Parameters:
hints- the rendering hints
-
hasRenderHint
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
Get the color scale for Z values (heatmap intensity). Applies to heatmap/2D histogram rendering only.- Returns:
- the Z color scale
-
setColorMap
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
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
Force the plot to includex = 0when determining x-axis limits.- Parameters:
incZero- the flag- Returns:
- this parameters instance (for chaining)
-
includeYZero
Force the plot to includey = 0when determining y-axis limits.- Parameters:
incZero- the flag- Returns:
- this parameters instance (for chaining)
-
getXScale
- Returns:
- x-axis scale (linear or log10).
-
setXScale
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
- Returns:
- y-axis scale (linear or log10).
-
setYScale
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
Get the extra strings for a second legend-like display.- Returns:
- the extra strings (may be
null)
-
setExtraStrings
Set the extra strings for a second legend-like display.- Parameters:
extraStrings- the new extra strings array (may benull)- 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
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
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:
trueif the extra text border is drawn
-
setExtraBorder
Set whether the extra text border is drawn.- Parameters:
extraBorder-trueif the extra text border is drawn- Returns:
- this parameters instance (for chaining)
-
isLegendBorder
public boolean isLegendBorder()Check whether the legend border is drawn.- Returns:
trueif the legend border is drawn
-
setLegendBorder
Set whether the legend border is drawn.- Parameters:
legBorder-trueif the legend border is drawn- Returns:
- this parameters instance (for chaining)
-
setTextBackground
Set the legend fill/background color.- Parameters:
color- the legend fill color- Returns:
- this parameters instance (for chaining)
-
getTextBackground
Get the legend fill/background color.- Returns:
- the legend fill color
-
setTextForeground
Set the legend text color.- Parameters:
color- the legend text color- Returns:
- this parameters instance (for chaining)
-
getTextForeground
Get the legend text color.- Returns:
- the legend text color
-
getTextBorderColor
Get the legend border color.- Returns:
- the legend border color
-
setTextBorderColor
Set the legend border color.- Parameters:
color- the legend border color- Returns:
- this parameters instance (for chaining)
-
setLegendFont
Set the legend font.- Parameters:
font- the legend font- Returns:
- this parameters instance (for chaining)
-
getTextFont
Get the legend font.- Returns:
- the legend font
-
setExtraBackground
Set the extra text fill/background color.- Parameters:
color- the extra text fill color- Returns:
- this parameters instance (for chaining)
-
getExtraBackground
Get the extra text fill/background color.- Returns:
- the extra text fill color
-
setExtraForeground
Set the extra text color.- Parameters:
color- the extra text color- Returns:
- this parameters instance (for chaining)
-
getExtraForeground
Get the extra text color.- Returns:
- the extra text color
-
getExtraBorderColor
Get the extra text border color.- Returns:
- the extra text border color
-
setExtraBorderColor
Set the extra text border color.- Parameters:
color- the extra text border color- Returns:
- this parameters instance (for chaining)
-
setExtraFont
Set the extra text font.- Parameters:
font- the new extra text font- Returns:
- this parameters instance (for chaining)
-
getExtraFont
Get the extra text font.- Returns:
- the extra text font
-
setTitleFont
Set the title font.- Parameters:
font- the new title font- Returns:
- this parameters instance (for chaining)
-
getTitleFont
Get the title font.- Returns:
- the title font
-
setAxesFont
Set the axes label font.- Parameters:
font- the new axes font- Returns:
- this parameters instance (for chaining)
-
getAxesFont
Get the axes label font.- Returns:
- the axes font
-
setStatusFont
Set the status font.- Parameters:
font- the new status font- Returns:
- this parameters instance (for chaining)
-
getStatusFont
Get the status font.- Returns:
- the status font
-
setLegendLineLength
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 includex = 0.- Returns:
trueif we should includex = 0
-
includeYZero
public boolean includeYZero()Check whether to includey = 0.- Returns:
trueif we should includey = 0
-
addPlotLine
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
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
Get all plot lines (annotations).- Returns:
- all plot lines (live collection)
-
getPlotTitle
Get the plot title.- Returns:
- the plot title
-
setPlotTitle
Set the plot title and notify listeners via the owningPlotCanvas.- Parameters:
title- the plot title- Returns:
- this parameters instance (for chaining)
-
getXLabel
Get the label for the x axis.- Returns:
- the x axis label
-
getYLabel
Get the label for the y axis.- Returns:
- the y axis label
-
setXLabel
Set the x axis label and notify listeners via the owningPlotCanvas.- Parameters:
label- the plot x axis label- Returns:
- this parameters instance (for chaining)
-
setYLabel
Set the y axis label and notify listeners via the owningPlotCanvas.- 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
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
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
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
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
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
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
Manually set the x range.This forces
setXLimitsMethod(LimitsMethod)toLimitsMethod.MANUALLIMITSand requests that the owning canvas recompute the world coordinate system.- Parameters:
xmin- the minimum xxmax- the maximum x- Returns:
- this parameters instance (for chaining)
-
setYRange
Manually set the y range.This forces
setYLimitsMethod(LimitsMethod)toLimitsMethod.MANUALLIMITSand requests that the owning canvas recompute the world coordinate system.- Parameters:
ymin- the minimum yymax- 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.NaNif not manually set)
-
getManualXMax
public double getManualXMax()Get the maximum value for a manual X range.- Returns:
- the maximum x (may be
Double.NaNif not manually set)
-
getManualYMin
public double getManualYMin()Get the minimum value for a manual Y range.- Returns:
- the minimum y (may be
Double.NaNif not manually set)
-
getManualYMax
public double getManualYMax()Get the maximum value for a manual Y range.- Returns:
- the maximum y (may be
Double.NaNif not manually set)
-
getXLimitsMethod
Get the limit method for the x axis.- Returns:
- the limit method for the x axis
-
setXLimitsMethod
Set the limits method for the x axis.- Parameters:
method- the method- Returns:
- this parameters instance (for chaining)
-
getYLimitsMethod
Get the limit method for the y axis.- Returns:
- the limit method for the y axis
-
setYLimitsMethod
Set the limits method for the y axis.- Parameters:
method- the method- Returns:
- this parameters instance (for chaining)
-