hep.analysis.partition
Class Abstract1DPartition

java.lang.Object
  |
  +--java.util.Observable
        |
        +--hep.analysis.Partition
              |
              +--hep.analysis.partition.Abstract1DPartition
All Implemented Interfaces:
OneDDataSource, OneDFillable, RangeChangeListener, java.io.Serializable, StatisticsProvider, TwoDFillable
Direct Known Subclasses:
OneDDelegatingPartition

public abstract class Abstract1DPartition
extends Partition
implements RangeChangeListener, OneDDataSource

The base class for all one-dimensional partitions. All fill methods will throw a PartitionFillException if not overridden. Therefore, subclasses should override the methods corresponding to the data types the subclass supports and leave the remaining ones to throw exceptions. Similarly, all getBinAt methods throw a NoSuchBinException unless overridden so subclasses should override the methods corresponding to the types that the subclass supports.

See Also:
PartitionFillException, NoSuchBinException, Serialized Form

Fields inherited from class hep.analysis.Partition
DATE, DELTATIME, DOUBLE, HORIZONTAL_AXIS, INTEGER, m_owner, STRING, VERTICAL_AXIS
 
Constructor Summary
Abstract1DPartition()
           
 
Method Summary
 void clear()
          Resets the partition to default settings.
protected  void clearDataChanged()
          Indicate that all data changes have been acknowledged by the observer and that the partition should resume sending new updates.
protected  void clearRangeChanged()
          Indicate that all range changes have been acknowledged by the observer and that the partition should resume sending new updates.
 void done()
          Called when event loop is finished; sends a final update of any range and/or data change.
 void fill(java.util.Date x)
          Invokes the fill(Date, double) method with a weighting value of 1.
 void fill(java.util.Date x, double y)
           
 void fill(double x)
          Invokes the fill(double, double) method with a weighting value of 1.
 void fill(double x, double y)
           
 void fill(int x)
          Invokes the fill(int, double) method with a weighting value of 1.
 void fill(java.lang.String x)
          Invokes the fill(String, double) method with a weighting value of 1.
 void fillW(java.util.Date x, double v)
          Fills the associated histogram with a date value.
 void fillW(java.util.Date x, double y, double weight)
           
 void fillW(double x, double v)
          Fills the associated histogram with a numerical value.
 void fillW(double x, double y, double weight)
           
 void fillW(int x, double v)
          Converts the given int parameter to type double and calls fill(double, double).
 void fillW(java.lang.String x, double v)
          Fills the associated histogram with a string value.
 java.lang.String[] getAxisLabels()
          Override to allow axis labels to be accessed.
 int getAxisType()
          Return the Axis type
 double getBin(int bin)
          Returns the contents of the given bin.
 int getBinAt(java.util.Date x)
          Returns the bin index corresponding to the given date value.
 int getBinAt(double x)
          Returns the bin index corresponding to the given numerical value.
 int getBinAt(int x)
          Converts the given int parameter to type double and invokes the method getBinAt(double).
 int getBinAt(java.lang.String x)
          Returns the bin index corresponding to the given string value.
abstract  double[] getBins()
          Return an array containing the sizes of all the bins.
 double getError(int bin)
          Returns the error for the given bin.
abstract  double getMax()
          Return the maximum in the distribution.
abstract  double getMin()
          Return the minimum in the distribution.
 double getMinusError(int bin)
          Returns the minus error for the given bin.
abstract  double[] getMinusErrors()
           
abstract  int getNumberOfBins()
          Return the number of bins.
 double getPlusError(int bin)
          Returns the plus error for the given bin.
abstract  double[] getPlusErrors()
          Return an array containing the errors for all the bins.
 boolean hasAsymmetricErrorBars()
          Returns false by default.
 boolean hasSimpleQuadraticErrorBars()
          Returns false by default.
 boolean isRebinnable()
          Returns false by default.
 void notifyObservers(java.lang.Object arg)
           
 void rangeChanged(double min, double max)
          Implementation of RangeChangeListener
 void setBinning(int bins, double min, double max)
          Override to allow binning to be set.
protected  void setDataAndRangeChanged()
          Indicate that the data and range have changed and notify observers of the change.
protected  void setDataAndRangeChangedNow()
          Indicate that the data and range have changed and notify observers of the change with a final update.
protected  void setDataChanged()
          Indicate that the data have changed and notify observers of the change.
protected  void setRangeChanged()
          Indicate that the range has changed and notify observers of the change.
 
Methods inherited from class hep.analysis.Partition
destroy, getStyle, makeCopy, setStyle
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hep.analysis.partition.StatisticsProvider
getStatistics
 

Constructor Detail

Abstract1DPartition

public Abstract1DPartition()
Method Detail

fillW

public void fillW(double x,
                  double v)
Fills the associated histogram with a numerical value. Subclasses must override this method with a partition-specific implementation to prevent a PartitionFillException (i.e., override this method if your subclass will support numerical binning).
Parameters:
x - the value to fill
v - a partition-specific value (normally some weighting value)
Throws:
PartitionFillException - if this method is not overridden
See Also:
PartitionFillException

fillW

public void fillW(int x,
                  double v)
Converts the given int parameter to type double and calls fill(double, double).
Parameters:
x - the value to fill
v - a partition-specific value (normally some weighting value)
Throws:
PartitionFillException - if thrown from fill(double, double)
See Also:
fill(double, double), PartitionFillException

fillW

public void fillW(java.lang.String x,
                  double v)
Fills the associated histogram with a string value. Subclasses must override this method with a partition-specific implementation to prevent a PartitionFillException (i.e., override this method if your subclass will support string binning).
Parameters:
x - the value to fill
v - a partition-specific value (normally some weighting value)
Throws:
PartitionFillException - if not overridden
See Also:
PartitionFillException

fillW

public void fillW(java.util.Date x,
                  double v)
Fills the associated histogram with a date value. Subclasses must override this method with a partition-specific implementation to prevent a PartitionFillException (i.e., override this method if your subclass will support date binning).
Parameters:
x - the value to fill
v - a partition-specific value (normally some weighting value)
Throws:
PartitionFillException - if not overridden
See Also:
PartitionFillException

fill

public void fill(double x)
Invokes the fill(double, double) method with a weighting value of 1.
Parameters:
x - the value to fill
See Also:
fillW(double, double)

fill

public void fill(int x)
Invokes the fill(int, double) method with a weighting value of 1.
Parameters:
x - the value to fill
See Also:
fillW(int, double)

fill

public void fill(java.lang.String x)
Invokes the fill(String, double) method with a weighting value of 1.
Parameters:
x - the value to fill
See Also:
fillW(String, double)

fill

public void fill(java.util.Date x)
Invokes the fill(Date, double) method with a weighting value of 1.
Parameters:
x - the value to fill
See Also:
fillW(Date, double)

fill

public void fill(double x,
                 double y)

fillW

public void fillW(double x,
                  double y,
                  double weight)

fill

public void fill(java.util.Date x,
                 double y)

fillW

public void fillW(java.util.Date x,
                  double y,
                  double weight)

getBinAt

public int getBinAt(double x)
             throws NoSuchBinException
Returns the bin index corresponding to the given numerical value. Subclasses must override this method to avoid getting a NoSuchBinException (i.e., override this method if your subclass will support numerical binning).
Parameters:
x - the value to map to a bin
Returns:
the bin index for the given parameter x
Throws:
NoSuchBinException - if not overridden

getBinAt

public int getBinAt(int x)
             throws NoSuchBinException
Converts the given int parameter to type double and invokes the method getBinAt(double).
Throws:
NoSuchBinException - if thrown from getBinAt(double)
See Also:
getBinAt(double)

getBinAt

public int getBinAt(java.lang.String x)
             throws NoSuchBinException
Returns the bin index corresponding to the given string value. Subclasses must override this method to avoid getting a NoSuchBinException (i.e., override this method if your subclass will support string binning).
Parameters:
x - the value to map to a bin
Returns:
the bin index for the given parameter x
Throws:
NoSuchBinException - if not overridden

getBinAt

public int getBinAt(java.util.Date x)
             throws NoSuchBinException
Returns the bin index corresponding to the given date value. Subclasses must override this method to avoid getting a NoSuchBinException (i.e., override this method if your subclass will support date binning).
Parameters:
x - the value to map to a bin
Returns:
the bin index for the given parameter x
Throws:
NoSuchBinException - if not overridden

getBin

public double getBin(int bin)
              throws NoSuchBinException
Returns the contents of the given bin.
Parameters:
bin - the bin to return the content of
Returns:
the content of the given bin
Throws:
NoSuchBinException - if the parameter bin is invalid

hasAsymmetricErrorBars

public boolean hasAsymmetricErrorBars()
Returns false by default. Override to have asymmetric error bars.
Specified by:
hasAsymmetricErrorBars in interface OneDDataSource

hasSimpleQuadraticErrorBars

public boolean hasSimpleQuadraticErrorBars()
Returns false by default. Override to have simple quadratic error bars.
Specified by:
hasSimpleQuadraticErrorBars in interface OneDDataSource

getPlusError

public double getPlusError(int bin)
Returns the plus error for the given bin. Equivalent to
getPlusErrors()[bin].
Parameters:
bin - the bin to return the plus error on
Returns:
the plus error on the given bin
Throws:
NoSuchBinException - if the parameter bin is invalid
See Also:
getPlusErrors()

getMinusError

public double getMinusError(int bin)
Returns the minus error for the given bin. Equivalent to
getMinusErrors()[bin].
Parameters:
bin - the bin to return the minus error on
Returns:
the plus error on the given bin
Throws:
NoSuchBinException - if the parameter bin is invalid
See Also:
getMinusErrors()

getError

public double getError(int bin)
Returns the error for the given bin.

isRebinnable

public boolean isRebinnable()
Returns false by default. Override to have a rebinnable partition.
Specified by:
isRebinnable in interface OneDDataSource

setBinning

public void setBinning(int bins,
                       double min,
                       double max)
Override to allow binning to be set. Throws an UnsupportedPartitionMethodException by default.
Specified by:
setBinning in interface OneDDataSource
Parameters:
bins - the number of bins to have
min - the minimum of the partition range
max - the maximum of the partition range
Throws:
UnsupportedPartitionMethodException - if not overridden.

getAxisLabels

public java.lang.String[] getAxisLabels()
Override to allow axis labels to be accessed. Throws an UnsupportedPartitionMethodException by default.
Specified by:
getAxisLabels in interface OneDDataSource
Returns:
an array of axis labels

getAxisType

public int getAxisType()
Return the Axis type
Specified by:
getAxisType in interface OneDDataSource

getBins

public abstract double[] getBins()
Return an array containing the sizes of all the bins.
Specified by:
getBins in interface OneDDataSource

getPlusErrors

public abstract double[] getPlusErrors()
Return an array containing the errors for all the bins.
Specified by:
getPlusErrors in interface OneDDataSource

getMinusErrors

public abstract double[] getMinusErrors()
Specified by:
getMinusErrors in interface OneDDataSource

getNumberOfBins

public abstract int getNumberOfBins()
Return the number of bins.

getMin

public abstract double getMin()
Return the minimum in the distribution.
Specified by:
getMin in interface OneDDataSource

getMax

public abstract double getMax()
Return the maximum in the distribution.
Specified by:
getMax in interface OneDDataSource

setDataChanged

protected final void setDataChanged()
Indicate that the data have changed and notify observers of the change.

rangeChanged

public void rangeChanged(double min,
                         double max)
Implementation of RangeChangeListener
Specified by:
rangeChanged in interface RangeChangeListener

setDataAndRangeChanged

protected final void setDataAndRangeChanged()
Indicate that the data and range have changed and notify observers of the change.

setDataAndRangeChangedNow

protected final void setDataAndRangeChangedNow()
Indicate that the data and range have changed and notify observers of the change with a final update.

clearDataChanged

protected final void clearDataChanged()
Indicate that all data changes have been acknowledged by the observer and that the partition should resume sending new updates.

setRangeChanged

protected final void setRangeChanged()
Indicate that the range has changed and notify observers of the change.

clearRangeChanged

protected final void clearRangeChanged()
Indicate that all range changes have been acknowledged by the observer and that the partition should resume sending new updates.

clear

public void clear()
Resets the partition to default settings.
Overrides:
clear in class Partition

done

public void done()
Called when event loop is finished; sends a final update of any range and/or data change.
Overrides:
done in class Partition

notifyObservers

public final void notifyObservers(java.lang.Object arg)
Overrides:
notifyObservers in class java.util.Observable