uk.ac.starlink.ttools.plot2.layer
Class LinearFitPlotter

java.lang.Object
  extended by uk.ac.starlink.ttools.plot2.layer.AbstractPlotter<LineStyle>
      extended by uk.ac.starlink.ttools.plot2.layer.LinearFitPlotter
All Implemented Interfaces:
Plotter<LineStyle>

public class LinearFitPlotter
extends AbstractPlotter<LineStyle>

Fits a set of 2-d points to a linear equation, and plots the line.

Since:
8 Dec 2014
Author:
Mark Taylor

Field Summary
static ReportKey<double[]> COEFFS_KEY
          Report key for coefficients of linear fit (2 element array (c, m)).
static ReportKey<Double> CORRELATION_KEY
          Report key for product moment correlation coefficient.
static ReportKey<String> EQUATION_KEY
          Report key for text of linear fit equation.
 
Constructor Summary
LinearFitPlotter(boolean hasWeights)
          Constructor.
 
Method Summary
 PlotLayer createLayer(DataGeom geom, DataSpec dataSpec, LineStyle style)
          Creates a PlotLayer based on the given geometry, data and style.
 LineStyle createStyle(ConfigMap config)
          Creates a style that can be used when creating a plot layer.
 String getPlotterDescription()
          Returns an XML description of this plotter.
 ConfigKey[] getStyleKeys()
          Returns the configuration keys used to configure style for this plotter.
 
Methods inherited from class uk.ac.starlink.ttools.plot2.layer.AbstractPlotter
getCoordGroup, getPlotterIcon, getPlotterName, hasReports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COEFFS_KEY

public static final ReportKey<double[]> COEFFS_KEY
Report key for coefficients of linear fit (2 element array (c, m)).


EQUATION_KEY

public static final ReportKey<String> EQUATION_KEY
Report key for text of linear fit equation.


CORRELATION_KEY

public static final ReportKey<Double> CORRELATION_KEY
Report key for product moment correlation coefficient.

Constructor Detail

LinearFitPlotter

public LinearFitPlotter(boolean hasWeights)
Constructor.

Parameters:
hasWeights - true if points may be weighted
Method Detail

getPlotterDescription

public String getPlotterDescription()
Description copied from interface: Plotter
Returns an XML description of this plotter.

Note: really this should appear at the LayerType level.

Returns:
one or more <p> elements

getStyleKeys

public ConfigKey[] getStyleKeys()
Description copied from interface: Plotter
Returns the configuration keys used to configure style for this plotter. The keys in the return value are used in the map supplied to the Plotter.createStyle(uk.ac.starlink.ttools.plot2.config.ConfigMap) method.

Returns:
keys used when creating a style for this plotter.

createStyle

public LineStyle createStyle(ConfigMap config)
Description copied from interface: Plotter
Creates a style that can be used when creating a plot layer. The keys that are significant in the supplied config map are those returned by Plotter.getStyleKeys(). The return value can be used as input to Plotter.createLayer(uk.ac.starlink.ttools.plot2.DataGeom, uk.ac.starlink.ttools.plot2.data.DataSpec, S).

Parameters:
config - map of style configuration items
Returns:
plotter-specific plot style

createLayer

public PlotLayer createLayer(DataGeom geom,
                             DataSpec dataSpec,
                             LineStyle style)
Description copied from interface: Plotter
Creates a PlotLayer based on the given geometry, data and style.

The style parameter is the result of a call to Plotter.createStyle(uk.ac.starlink.ttools.plot2.config.ConfigMap).

The dataSpec parameter must contain the coordinates defined by this plotter's CoordGroup.

The pointDataGeom parameter is only used if getCoordGroup(). getPositionCount returns a non-zero value, otherwise the plot does not have point positions.

It is legal to supply null for any of the parameters; if insufficient data is supplied to generate a plot, then the method should return null.

Creating a layer should be cheap; layers may be created and not used.

Parameters:
geom - indicates base position coordinates and their mapping to points in the data space; if non-null, the data geom's DataGeom.hasPosition() method will return true
dataSpec - specifies the data required for the plot
style - data style as obtained from createStyle
Returns:
new plot layer, or null if no drawing will take place


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.