Package jisa.gui
Class Plot
- java.lang.Object
-
- jisa.gui.JFXElement
-
- jisa.gui.Plot
-
public class Plot extends JFXElement implements Element, Clearable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Plot.AxisType
static interface
Plot.ClickListener
-
Nested classes/interfaces inherited from interface jisa.gui.Element
Element.ElementBorder
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.Pattern
UNIT_PATTERN
-
Constructor Summary
Constructors Constructor Description Plot()
Plot(java.lang.String title)
Plot(java.lang.String title, java.lang.Iterable<? extends java.lang.Number> xData, java.lang.Iterable<? extends java.lang.Number> yData)
Plot(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel)
Plot(java.lang.String title, java.lang.String xLabel, java.lang.String xUnits, java.lang.String yLabel, java.lang.String yUnits)
Plot(java.lang.String title, ResultTable table)
Plot(java.lang.String title, ResultTable table, Column<? extends java.lang.Number> xAxis)
Plot(java.lang.String title, ResultTable table, Column<? extends java.lang.Number> xAxis, Column<? extends java.lang.Number> yAxis)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Plot.ClickListener
addClickListener(Plot.ClickListener listener)
Button
addSaveButton(java.lang.String text)
Adds toolbar button that opens the plot save dialog when clicked.void
autoRangeX()
void
autoRangeY()
void
clear()
Plot
copy()
Series
createSeries()
void
forceRedraw()
JISAXYChart
getChart()
java.util.List<Series>
getSeries()
SVG
getSVG(double width, double height)
double
getXAxisLogarithmBase()
Plot.AxisType
getXAxisType()
java.lang.String
getXLabel()
double
getXMax()
double
getXMin()
java.lang.String
getXUnit()
Returns the units of the x-axis of this plot.double
getYAxisLogarithmBase()
Plot.AxisType
getYAxisType()
java.lang.String
getYLabel()
double
getYMax()
double
getYMin()
java.lang.String
getYUnit()
Returns the units of the y-axis of this plot.boolean
isLegendVisible()
Returns whether the legend of this plot is currently visible.boolean
isMouseEnabled()
boolean
isXAutoRanging()
boolean
isYAutoRanging()
void
outputSVG(double width, double height)
void
outputSVG(java.io.PrintStream stream, double width, double height)
void
removeClickListener(Plot.ClickListener listener)
void
removeSeries(Series toRemove)
void
savePNG(java.lang.String path, double w, double h)
void
saveSVG(java.lang.String fileName, double width, double height)
void
saveTex(java.lang.String path)
void
setLegendVisible(boolean visible)
Sets whether the legend of this plot should be visible or not.void
setMouseEnabled(boolean enabled)
void
setTitle(java.lang.String title)
Sets the title of this plot.void
setXAxisLogarithmBase(double base)
void
setXAxisType(Plot.AxisType type)
void
setXLabel(java.lang.String name)
Sets the label to display on the x-axis of this plot.void
setXLabel(java.lang.String name, java.lang.String units)
Sets the label and units to display on the x-axis of this plot.void
setXLimits(double min, double max)
void
setXMax(double min)
void
setXMin(double min)
void
setXUnit(java.lang.String unit)
Sets the units of the x-axis of this plot.void
setYAxisLogarithmBase(double base)
void
setYAxisType(Plot.AxisType type)
void
setYLabel(java.lang.String name)
void
setYLabel(java.lang.String name, java.lang.String units)
void
setYLimits(double min, double may)
void
setYMax(double min)
void
setYMin(double min)
void
setYUnit(java.lang.String unit)
Sets the units of the y-axis of this plot.void
showSaveDialog()
Shows a dialogue allowing the user to save this plot as an image, with user-alterable parameters of format, width and height.void
updateLegend()
-
Methods inherited from class jisa.gui.JFXElement
addDialogButton, addDialogMenuButton, addToolbarButton, addToolbarMenuButton, addToolbarSeparator, autoAdjustSize, autoSizeWindow, clearDialogButtons, clearToolbar, close, getIcon, getMaxHeight, getMaxWidth, getMaxWindowHeight, getMaxWindowWidth, getMinHeight, getMinWidth, getNode, getStage, getTitle, getWindowHeight, getWindowWidth, hide, iconProperty, isDecorated, isExitOnClose, isMaximised, isShowing, setCentreNode, setDecorated, setExitOnClose, setIcon, setIcon, setMaxHeight, setMaximised, setMaxWidth, setMaxWindowHeight, setMaxWindowWidth, setMinHeight, setMinWidth, setOnClose, setWindowHeight, setWindowSize, setWindowWidth, show, showAsAlert, showAsConfirmation, showAsDialog, titleProperty
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jisa.gui.Element
close, getBorderedNode, getIcon, getNode, getTitle, hide, isVisible, setVisible, show, titleProperty
-
-
-
-
Constructor Detail
-
Plot
public Plot(java.lang.String title, java.lang.String xLabel, java.lang.String xUnits, java.lang.String yLabel, java.lang.String yUnits)
-
Plot
public Plot(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel)
-
Plot
public Plot(java.lang.String title)
-
Plot
public Plot()
-
Plot
public Plot(java.lang.String title, ResultTable table)
-
Plot
public Plot(java.lang.String title, ResultTable table, Column<? extends java.lang.Number> xAxis)
-
Plot
public Plot(java.lang.String title, ResultTable table, Column<? extends java.lang.Number> xAxis, Column<? extends java.lang.Number> yAxis)
-
Plot
public Plot(java.lang.String title, java.lang.Iterable<? extends java.lang.Number> xData, java.lang.Iterable<? extends java.lang.Number> yData)
-
-
Method Detail
-
getChart
public JISAXYChart getChart()
-
updateLegend
public void updateLegend()
-
forceRedraw
public void forceRedraw()
-
isLegendVisible
public boolean isLegendVisible()
Returns whether the legend of this plot is currently visible.- Returns:
- Is the legend visible?
-
setLegendVisible
public void setLegendVisible(boolean visible)
Sets whether the legend of this plot should be visible or not.- Parameters:
visible
- Should the legend be visible?
-
setXLabel
public void setXLabel(java.lang.String name, java.lang.String units)
Sets the label and units to display on the x-axis of this plot.- Parameters:
name
- The label textunits
- The units of the axis
-
setXLabel
public void setXLabel(java.lang.String name)
Sets the label to display on the x-axis of this plot. Units can be optionally specified in square brackets. For example: "Voltage [V]".- Parameters:
name
- The label text, optionally including units in square brackets [...]
-
setXUnit
public void setXUnit(java.lang.String unit)
Sets the units of the x-axis of this plot.- Parameters:
unit
- Units for x-axis
-
setYUnit
public void setYUnit(java.lang.String unit)
Sets the units of the y-axis of this plot.- Parameters:
unit
- Units for y-axis
-
setTitle
public void setTitle(java.lang.String title)
Sets the title of this plot.- Specified by:
setTitle
in interfaceElement
- Overrides:
setTitle
in classJFXElement
- Parameters:
title
- Title of plot
-
getXUnit
public java.lang.String getXUnit()
Returns the units of the x-axis of this plot.- Returns:
- X-axis units
-
getYUnit
public java.lang.String getYUnit()
Returns the units of the y-axis of this plot.- Returns:
- Y-axis units
-
getXLabel
public java.lang.String getXLabel()
-
getYLabel
public java.lang.String getYLabel()
-
setYLabel
public void setYLabel(java.lang.String name, java.lang.String units)
-
setYLabel
public void setYLabel(java.lang.String name)
-
setXLimits
public void setXLimits(double min, double max)
-
setXMin
public void setXMin(double min)
-
setXMax
public void setXMax(double min)
-
getXMin
public double getXMin()
-
getXMax
public double getXMax()
-
autoRangeX
public void autoRangeX()
-
isXAutoRanging
public boolean isXAutoRanging()
-
setYLimits
public void setYLimits(double min, double may)
-
setYMin
public void setYMin(double min)
-
setYMax
public void setYMax(double min)
-
getYMin
public double getYMin()
-
getYMax
public double getYMax()
-
autoRangeY
public void autoRangeY()
-
isYAutoRanging
public boolean isYAutoRanging()
-
getSeries
public java.util.List<Series> getSeries()
-
createSeries
public Series createSeries()
-
removeSeries
public void removeSeries(Series toRemove)
-
setXAxisType
public void setXAxisType(Plot.AxisType type)
-
setYAxisType
public void setYAxisType(Plot.AxisType type)
-
getXAxisType
public Plot.AxisType getXAxisType()
-
getYAxisType
public Plot.AxisType getYAxisType()
-
setXAxisLogarithmBase
public void setXAxisLogarithmBase(double base)
-
setYAxisLogarithmBase
public void setYAxisLogarithmBase(double base)
-
getXAxisLogarithmBase
public double getXAxisLogarithmBase()
-
getYAxisLogarithmBase
public double getYAxisLogarithmBase()
-
addSaveButton
public Button addSaveButton(java.lang.String text)
Adds toolbar button that opens the plot save dialog when clicked.- Parameters:
text
- Text to show
-
showSaveDialog
public void showSaveDialog()
Shows a dialogue allowing the user to save this plot as an image, with user-alterable parameters of format, width and height.
-
setMouseEnabled
public void setMouseEnabled(boolean enabled)
-
isMouseEnabled
public boolean isMouseEnabled()
-
copy
public Plot copy()
-
savePNG
public void savePNG(java.lang.String path, double w, double h)
-
getSVG
public SVG getSVG(double width, double height)
-
saveSVG
public void saveSVG(java.lang.String fileName, double width, double height) throws java.io.IOException
- Throws:
java.io.IOException
-
outputSVG
public void outputSVG(java.io.PrintStream stream, double width, double height)
-
outputSVG
public void outputSVG(double width, double height)
-
saveTex
public void saveTex(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
addClickListener
public Plot.ClickListener addClickListener(Plot.ClickListener listener)
-
removeClickListener
public void removeClickListener(Plot.ClickListener listener)
-
-