Class DatasetCurveFitter

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DatasetCurveFitter extends JPanel
A panel that displays and controls functional curve fits to a Dataset.
Version:
1.0
Author:
Douglas Brown
See Also:
  • Field Details

    • PROPERTY_DATASETCURVEFITTER_CHANGED

      public static final String PROPERTY_DATASETCURVEFITTER_CHANGED
      See Also:
    • PROPERTY_DATASETCURVEFITTER_DRAWER

      public static final String PROPERTY_DATASETCURVEFITTER_DRAWER
      See Also:
    • PROPERTY_DATASETCURVEFITTER_FIT

      public static final String PROPERTY_DATASETCURVEFITTER_FIT
      See Also:
    • isFixedDecimalFormat

      public static boolean isFixedDecimalFormat
    • splitPane

      protected JSplitPane splitPane
  • Constructor Details

    • DatasetCurveFitter

      public DatasetCurveFitter(Dataset data, FitBuilder builder)
      Constructs a DatasetCurveFitter for the specified Dataset.
      Parameters:
      data - the dataset
      builder - the FitBuilder used for constructing custom fits
  • Method Details

    • setActiveNoFit

      public void setActiveNoFit(boolean b)
    • isActive

      public boolean isActive()
    • setAutofit

      public void setAutofit(boolean auto)
      Sets the autofit flag.
      Parameters:
      auto - true to autofit
    • setAutoFit

      public void setAutoFit(boolean autofit)
    • getSplitPane

      public JSplitPane getSplitPane()
    • getDrawer

      public UncertainFunctionDrawer getDrawer()
      Gets the function drawer.
      Returns:
      the drawer
    • getData

      public Dataset getData()
      Gets the data.
      Returns:
      the dataset
    • setData

      public void setData(Dataset data, boolean doFit)
      Sets the dataset.
      Parameters:
      data - the dataset - if null, then just initializing
    • setColor

      public void setColor(Color newColor)
      Sets the color.
      Parameters:
      newColor - the color
    • setActiveAndFit

      public void setActiveAndFit(boolean active)
      Sets the active flag if not already set and does a fit if setting it to true.
      Parameters:
      active - true
    • fit

      public double fit(KnownFunction fit)
      Fits a fit function to the current data.
      Parameters:
      fit - the function to fit
      Returns:
      the rms deviation
    • fit

      public double fit(KnownFunction fit, boolean fromScratch)
      Fits a fit function to the current data.
      Parameters:
      fit - the function to fit
      Returns:
      the rms deviation
    • addFitFunction

      public void addFitFunction(KnownFunction f, boolean addToFitBuilder)
      Adds a fit function.
      Parameters:
      f - the fit function to add
      addToFitBuilder - ignored--all fits are added to the fit builder
    • refreshStatusBar

      public void refreshStatusBar()
      Refreshes the parent tab's status bar
    • getUncertainty

      public double getUncertainty(int paramIndex)
      Gets the estimated uncertainty (standard error or other) of a best fit parameter. Returns Double.NaN if uncertainty is unknown or is not best fit.
      Parameters:
      paramIndex - the parameter index
      Returns:
      the estimated uncertainty in the parameter
    • formatUncertainParameter

      public String[] formatUncertainParameter(double value, double sigma, int extraPlaces, NumberFormat format)
      Returns two strings describing a parameter and its uncertainty. One for display, other with more sig figs for tooltip
      Parameters:
      value - the parameter value
      sigma - the uncertainty (may be null)
      Returns:
      the format values {decimal places, format} or null if uncert unknown or zero
    • getFitFunction

      public KnownFunction getFitFunction(String name)
      Gets a fit function by name.
      Parameters:
      name - the name
      Returns:
      the fit function, or null if none found
    • getSelectedFitParameters

      public Map<String,Double> getSelectedFitParameters()
      Gets the selected fit parameters.
      Returns:
      a map of parameter names to values
    • getMinimumSize

      public Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent
    • createGUI

      protected void createGUI()
      Creates the GUI.
    • fixSize

      protected Dimension fixSize(Dimension dim)
    • processPropertyChange

      protected void processPropertyChange(PropertyChangeEvent e)
    • refreshGUI

      protected void refreshGUI()
      Refreshes the GUI.
    • refreshDecimalSeparators

      protected void refreshDecimalSeparators()
      Refreshes the decimal separators.
    • refreshFitDropDown

      protected void refreshFitDropDown()
      Refreshes the fitDropDown.
    • refreshFitMap

      protected void refreshFitMap()
      Refreshes the fit map with localized names.
    • getPolyFitNameOfDegree

      public String getPolyFitNameOfDegree(int degree)
      Gets the name of a fit function for specified polynomial degree
      Returns:
      the name of the function
    • setDataToolTab

      protected void setDataToolTab(DataToolTab tab)
    • setFontLevel

      protected void setFontLevel(int level)
      Sets the font level.
      Parameters:
      level - the level
    • setParameterValue

      protected void setParameterValue(int row, double value)
      Sets the value of a parameter.
      Parameters:
      row - the row number
      value - the value
    • selectFit

      protected void selectFit(String name)
      Selects a named fit.
      Parameters:
      name - the name of the fit function
    • createClone

      protected UserFunction createClone(KnownFunction f, String name)
    • doLinearRegression

      public void doLinearRegression(double[] xd, double[] yd)
      Determines the Pearson correlation and linear fit parameter SEs.
      Parameters:
      xd - double[]
      yd - double[]
      isLinearFit - true if linear fit (sets uncertainties to slope and intercept SE)
    • replaceFit

      protected void replaceFit(String oldName, String newName, KnownFunction newFit)
      Replaces an existing fit function with a new one.
      Parameters:
      oldName - the (localized) name of the existing fit function
      newName - the (localized) new name of the function
      newFit - the new fit function
    • getColorDialog

      protected JDialog getColorDialog()
      Gets a color dialog for the plotted curve fit drawer
    • setDefaultFitFunctions

      public static void setDefaultFitFunctions(ArrayList<KnownFunction> functions)
      Sets the default fit functions. Instances of DatasetCurveFitter instantiated AFTER this call will make these fits available to the user.
      Parameters:
      functions - the fit functions
    • getFits

      public void getFits(Map<String,KnownFunction> fits, ArrayList<String> fitnames)
    • getFitNames

      public String[] getFitNames()
    • setSelectedItem

      public void setSelectedItem(String fitName)
    • setText

      public void setText(String text)
    • setFitVisible

      public void setFitVisible(boolean vis)