Class ChartingModule
java.lang.Object
org.eclipse.ease.modules.AbstractScriptModule
org.eclipse.ease.modules.charting.ChartingModule
- All Implemented Interfaces:
IScriptModule
public class ChartingModule extends AbstractScriptModule
Provide functions to display and populate line charts.
-
Field Summary
Fields Modifier and Type Field Description static String
MODULE_NAME
-
Constructor Summary
Constructors Constructor Description ChartingModule()
-
Method Summary
Modifier and Type Method Description org.eclipse.nebula.visualization.xygraph.figures.Annotation
addMarker(String text, Double xPosition, Double yPosition)
Add a marker to the chart.void
clear()
Clears the active chart.Chart
createChart(org.eclipse.swt.widgets.Composite parent, String figureId)
Create a new chart on a given parent composite.void
exportGraph(Object location, boolean overwrite)
Export the current figure as png file.Chart
figure(String figureId)
Opens a new view with an empty figure.org.eclipse.nebula.visualization.xygraph.figures.Trace
plot(double[] x, double[] y)
Plot array of points (x[],y[]) on the last series that is set with method series(seriesName, format).org.eclipse.nebula.visualization.xygraph.figures.Trace
plotPoint(double x, double y)
Add (x,y) point to the last Series that is set with method series(seriesName,format).void
removeSeries(String seriesName)
Deletes a given series.org.eclipse.nebula.visualization.xygraph.figures.Trace
series(String seriesName, String format)
Series will be created with the name seriesName.void
setAutoScale(boolean performAutoScale)
Activates or deactivates auto scaling whenever the cart is updated.void
setAxisRange(double[] xRange, double[] yRange)
Set lower and upper limit of the X axis and the Y axis.org.eclipse.nebula.visualization.xygraph.figures.XYGraph
setPlotTitle(String chartTitle)
Sets the title of the active chart.org.eclipse.nebula.visualization.xygraph.figures.Axis
setXLabel(String label)
Set X axis name.org.eclipse.nebula.visualization.xygraph.figures.Axis
setYLabel(String label)
Set Y axis name.void
showGrid(boolean showGrid)
Activates or deactivates drawing of a background grid.Methods inherited from class org.eclipse.ease.modules.AbstractScriptModule
getScriptEngine, initialize
-
Field Details
-
MODULE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Details
-
ChartingModule
public ChartingModule()
-
-
Method Details
-
figure
public Chart figure(@ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String figureId) throws ThrowableOpens a new view with an empty figure. figureId is used as a view and chart title. If a view with the same figureId already exists, it will be activated. The last activated figure will be used for all further commands of this modules.- Parameters:
figureId
- name of the figure to be created- Returns:
- new or activated chart
- Throws:
Throwable
- when the view could not be initialized
-
createChart
public Chart createChart(org.eclipse.swt.widgets.Composite parent, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String figureId)Create a new chart on a given parent composite.- Parameters:
parent
- composite to create chart intofigureId
- name of the figure to be created- Returns:
- new chart instance
-
series
public org.eclipse.nebula.visualization.xygraph.figures.Trace series(@ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String seriesName, @ScriptParameter(defaultValue="") String format) throws ThrowableSeries will be created with the name seriesName. If the name is not given then Series will have the name "Series id" where id is the current number of the Series Iterator. Series Iterator start at 1 and with every new Series is incremented by one. If Series is already created with seriesName then that series will be set as currently active Series and on that Series methods will be performed. If there is no active Figure then Figure will be created and activated.- Parameters:
seriesName
- Name of this series. Default isnull
if no seriesName is given, in that case the name is "Series id" as explained aboveformat
- default is "", if number is written inside format like "f#25" point size will be set(in this case 25), please write format correctly, if for example 2 colors will be written like "rg" then the last one will be taken, in this case g or green, so please set line style, point size, color and Marker Type only once. Used matlab syntax to define plot format:Specifier LineStyle '-' Solid line (default) '--' Dashed line ':' Dotted line '-.' Dash-dot line '#' No line Specifier Color r Red g Green b Blue c Cyan m Magenta y Yellow k Black w White Specifier Marker Type '+' Plus sign 'o' Circle 'p' Point 'x' Cross 's' Square 'f' Filled Square 'd' Diamond 'v' Downward-pointing triangle - Returns:
- series as Trace type to set different properties for this series
- Throws:
Throwable
- if the series could not be initialized
-
plotPoint
public org.eclipse.nebula.visualization.xygraph.figures.Trace plotPoint(double x, double y) throws ThrowableAdd (x,y) point to the last Series that is set with method series(seriesName,format). If there is no active figure and series then both will be created and activated.- Parameters:
x
- x coordinate of this pointy
- y coordinate of this point- Returns:
- series as Trace type to set different properties for this series
- Throws:
Throwable
- when the view could not be initialized
-
plot
public org.eclipse.nebula.visualization.xygraph.figures.Trace plot(double[] x, double[] y) throws ThrowablePlot array of points (x[],y[]) on the last series that is set with method series(seriesName, format). If there is no active Figure and Series then both will be created and activated.- Parameters:
x
- array of x coordinatesy
- array of y coordinates- Returns:
- series as Trace type to set different properties for this series
- Throws:
Throwable
- when the view could not be initialized
-
setPlotTitle
Sets the title of the active chart.- Parameters:
chartTitle
- title to be set- Returns:
XYGraph
object ornull
if there is no active graph
-
setXLabel
Set X axis name.- Parameters:
label
- label to be used for X axis- Returns:
Axis
object ornull
if there is no active graph
-
setYLabel
Set Y axis name.- Parameters:
label
- label to be used for Y axis- Returns:
Axis
object ornull
if there is no active graph
-
setAxisRange
public void setAxisRange(double[] xRange, double[] yRange)Set lower and upper limit of the X axis and the Y axis.- Parameters:
xRange
- Range from x Axis to be set, format is [xmin, xmax]yRange
- Range from Y Axis to be set, format is [ymin, ymax]
-
showGrid
public void showGrid(boolean showGrid)Activates or deactivates drawing of a background grid.- Parameters:
showGrid
- iftrue
a grid will be displayed
-
setAutoScale
public void setAutoScale(boolean performAutoScale)Activates or deactivates auto scaling whenever the cart is updated. An auto scale may also be triggered by double clicking right into the chart area.- Parameters:
performAutoScale
- iftrue
auto scaling will be enabled
-
clear
public void clear()Clears the active chart. -
exportGraph
public void exportGraph(@ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") Object location, @ScriptParameter(defaultValue="false") boolean overwrite) throws ThrowableExport the current figure as png file. When no location is provided, a popup dialog will ask the user for the target location. -
removeSeries
Deletes a given series. If the series does not exists this method does nothing.- Parameters:
seriesName
- name of series to be deleted- Throws:
Throwable
- when the view could not be initialized
-
addMarker
public org.eclipse.nebula.visualization.xygraph.figures.Annotation addMarker(String text, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") Double xPosition, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") Double yPosition)Add a marker to the chart. A marker is a text label that points to a grid location. By default the marker will point to the data point that was added last. If positions are provided always xPosition and yPosition need to be provided. The returned marker can be further customized in the UI thread.- Parameters:
text
- text to displayxPosition
- if set, this will be the X position the marker points toyPosition
- if set, this will be the Y position the marker points to- Returns:
- marker implementation
-