Point Class Reference

A data point value with associated point-level errors. More...

Inheritance diagram for Point:

Inheritance graph
[legend]

Collaboration diagram for Point:

Collaboration graph
[legend]

List of all members.


Public Member Functions

 Point ()
 No-arg constructor for Hibernate.
 Point (Double value)
 Constructor for a value.
 Point (Double value, Relation relation, Double confidenceLevel) throws HDException
 Constructor for a limit.
 Point (YAxis yAxis)
 Constructor binding to a particular axis.
 Point (YAxis yAxis, Double value)
 Constructor for a value, binding to a particular axis.
 Point (YAxis yAxis, Double value, Relation relation, Double confidenceLevel) throws HDException
 Constructor for a limit, binding to a particular axis.
Point setLimit (Relation relation, Double value, Double confidenceLevel) throws HDException
Integer getId ()
Point setId (Integer pointId)
Double getValue ()
Point setValue (Double value)
Relation getRelation ()
 Get Relation.
Point setRelation (Relation relation)
Double getConfidenceLevel ()
Point setConfidenceLevel (Double confidenceLevel) throws HDException
SortedSet< PointErrorgetErrors ()
Point setErrors (SortedSet< PointError > errors)
Point setErrors (Collection< PointError > errors)
Point setErrors (PointError[] errors)
Point addError (PointError error)
Point removeError (PointError error)
YAxis getYAxis ()
 Get containing y-axis.
Point setYAxis (YAxis yAxis)
 Set containing y-axis.
Set< UncertaintygetDatasetErrors ()
 Get errors from parent Dataset.
SortedSet< UncertaintygetAxisErrors ()
 Get errors from parent YAxis.
Set< UncertaintygetPointErrors ()
 Get errors from this point (as generic Errors).
SortedSet< UncertaintygetAllErrors ()
 Get all the errors that apply to this point.
SortedSet< BingetBins ()
 Get the corresponding Bins from the x-axes in this Dataset.
SortedSet< PointgetPoints ()
 Get all the y-axis Points which are in the same row as this one (inclusive).
String toString ()
 String representation.
String toString (Integer indentBy)
 String representation with indent.
boolean equals (Object other)
 Override equals method with business key equality.
int hashCode ()
 Override hashcode method.
int compareTo (Point other)
 Compare points by comparing central values.

Package Functions

.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId (columns=@Column(name="PointErrorId"), type=@org.hibernate.annotations.Type(type="long"), generator="sequence")@org.hibernate.annotations.Sort(type
 Point errors.
Logger log ()
 Neat method to allow every class to get hold of a custom-named Logger.

Detailed Description

A data point value with associated point-level errors.

Author:
Andy Buckley
Version:
Date
Revision

Definition at line 21 of file Point.java.


Constructor & Destructor Documentation

Point (  ) 

No-arg constructor for Hibernate.

Definition at line 62 of file Point.java.

00062 {}

Point ( Double  value  ) 

Constructor for a value.

Definition at line 65 of file Point.java.

00065                                {
00066         setValue(value);
00067     }

Point ( Double  value,
Relation  relation,
Double  confidenceLevel 
) throws HDException

Constructor for a limit.

Definition at line 70 of file Point.java.

00070                                                                                              {
00071         setLimit(relation, value, confidenceLevel);
00072     }

Point ( YAxis  yAxis  ) 

Constructor binding to a particular axis.

Definition at line 75 of file Point.java.

00075                               {
00076         setYAxis(yAxis);
00077     }

Point ( YAxis  yAxis,
Double  value 
)

Constructor for a value, binding to a particular axis.

Definition at line 80 of file Point.java.

00080                                             {
00081         this(yAxis);
00082         setValue(value);
00083     }

Point ( YAxis  yAxis,
Double  value,
Relation  relation,
Double  confidenceLevel 
) throws HDException

Constructor for a limit, binding to a particular axis.

Definition at line 86 of file Point.java.

00086                                                                                                           {
00087         this(yAxis);
00088         setLimit(relation, value, confidenceLevel);
00089     }


Member Function Documentation

.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId ( columns  = @Column(name="PointErrorId"),
type  = @org.hibernate.annotations.Type(type="long"),
generator  = "sequence" 
) [package]

Point errors.

Point setLimit ( Relation  relation,
Double  value,
Double  confidenceLevel 
) throws HDException

Definition at line 95 of file Point.java.

00095                                                                                                       {
00096         setRelation(relation); // Need to do this first
00097         setValue(value);
00098         setConfidenceLevel(confidenceLevel);
00099         return this;
00100     }

Integer getId (  ) 

Definition at line 107 of file Point.java.

Referenced by YAxis.addPoint(), and Point.compareTo().

00107                            {
00108         return _localId;
00109     }

Point setId ( Integer  pointId  ) 

Definition at line 110 of file Point.java.

Referenced by YAxis.addPoint().

00110                                         {
00111         _localId = pointId;
00112         return this;
00113     }

Double getValue (  ) 

Definition at line 117 of file Point.java.

Referenced by Point.equals().

00117                              {
00118         return _value;
00119     }

Point setValue ( Double  value  ) 

Definition at line 120 of file Point.java.

00120                                         {
00121         _value = value;
00122         return this;
00123     }

Relation getRelation (  ) 

Get Relation.

Todo:
Provide string-based accessors for Castor

Definition at line 129 of file Point.java.

00129                                   {
00130         return _relation;
00131     }

Point setRelation ( Relation  relation  ) 

Definition at line 132 of file Point.java.

00132                                                 {
00133         _relation = relation;
00134         return this;
00135     }

Double getConfidenceLevel (  ) 

Definition at line 139 of file Point.java.

00139                                        {
00140         return _confidenceLevel;
00141     }

Point setConfidenceLevel ( Double  confidenceLevel  )  throws HDException

Definition at line 142 of file Point.java.

00142                                                                                {
00143         if (getRelation() != Relation.EQUALS) {
00144             _confidenceLevel = confidenceLevel;
00145         } else {
00146             _confidenceLevel = null;
00147         }
00148         return this;
00149     }

SortedSet<PointError> getErrors (  ) 

Definition at line 153 of file Point.java.

00153                                              {
00154         return _errors;
00155     }

Point setErrors ( SortedSet< PointError errors  ) 

Definition at line 156 of file Point.java.

00156                                                          {
00157         getErrors().clear();
00158         for (PointError e : errors) addError(e);
00159         return this;
00160     }

Point setErrors ( Collection< PointError errors  ) 

Definition at line 161 of file Point.java.

00161                                                           {
00162         log().debug("Calling setErrors(Collection<PointError>)");
00163         getErrors().clear();
00164         for (PointError e : errors) addError(e);
00165         return this;
00166     }

Point setErrors ( PointError[]  errors  ) 

Definition at line 167 of file Point.java.

00167                                                 {
00168         setErrors(Arrays.asList(errors));
00169         return this;
00170     }

Point addError ( PointError  error  ) 

Definition at line 171 of file Point.java.

References PointError.getId(), and PointError.setId().

00171                                             {
00172         if (error != null) {
00173             if (error.getId() == null) {
00174                 int highestId = 0;
00175                 if (getErrors().size() > 0) {
00176                     highestId = getErrors().last().getId();
00177                 }
00178                 log().debug("Incrementing point error ID: " + (highestId + 1));
00179                 error.setId(highestId + 1);
00180             }
00181             log().debug("Adding point error: ID = " + error.getId());
00182             _errors.add(error);
00183         } else {
00184             log().warn("Tried to add a null point error to a point");
00185         }
00186         return this;
00187     }

Point removeError ( PointError  error  ) 

Definition at line 188 of file Point.java.

00188                                                {
00189         if (error != null) {
00190             _errors.remove(error);
00191         } else {
00192             log().warn("Tried to remove a null point error from a point");
00193         }
00194         return this;
00195     }

YAxis getYAxis (  ) 

Get containing y-axis.

Definition at line 199 of file Point.java.

Referenced by Point.compareTo(), and Point.equals().

00199                             {
00200         return _yAxis;
00201     }

Point setYAxis ( YAxis  yAxis  ) 

Set containing y-axis.

Definition at line 203 of file Point.java.

References YAxis.getPoints().

Referenced by YAxis.addPoint(), and YAxis.removePoint().

00203                                        {
00204         _yAxis = yAxis;
00205         if (yAxis != null) yAxis.getPoints().add(this);
00206         return this;
00207     }

Set<Uncertainty> getDatasetErrors (  ) 

Get errors from parent Dataset.

Definition at line 214 of file Point.java.

00214                                                {
00215         if (getYAxis() != null) {
00216             return getYAxis().getDatasetErrors();
00217         } else {
00218             return new HashSet<Uncertainty>();
00219         }
00220     }

SortedSet<Uncertainty> getAxisErrors (  ) 

Get errors from parent YAxis.

Definition at line 222 of file Point.java.

00222                                                   {
00223         SortedSet<Uncertainty> axisErrors = new TreeSet<Uncertainty>();
00224         if (getYAxis() != null) {
00225             axisErrors.addAll( getYAxis().getErrors() );
00226         }
00227         return axisErrors;
00228     }

Set<Uncertainty> getPointErrors (  ) 

Get errors from this point (as generic Errors).

Definition at line 230 of file Point.java.

00230                                              {
00231         return new HashSet<Uncertainty>(getErrors());
00232     }

SortedSet<Uncertainty> getAllErrors (  ) 

Get all the errors that apply to this point.

Definition at line 234 of file Point.java.

00234                                                  {
00235         SortedSet<Uncertainty> allErrors = new TreeSet<Uncertainty>();
00236         allErrors.addAll(getErrors());
00237         allErrors.addAll(getAxisErrors());
00238         allErrors.addAll(getDatasetErrors());
00239         return allErrors;
00240     }

SortedSet<Bin> getBins (  ) 

Get the corresponding Bins from the x-axes in this Dataset.

Definition at line 247 of file Point.java.

References Dataset.getBins(), and YAxis.getDataset().

00247                                     {
00248         SortedSet<Bin> matchingBins = null;
00249         YAxis y = getYAxis();
00250         if (y != null) {
00251             Dataset d = y.getDataset();
00252             if (d != null) {
00253                 matchingBins = d.getBins(getId());
00254             }
00255         }
00256         return matchingBins;
00257     }

SortedSet<Point> getPoints (  ) 

Get all the y-axis Points which are in the same row as this one (inclusive).

Definition at line 260 of file Point.java.

References YAxis.getDataset(), and Dataset.getPoints().

00260                                         {
00261         SortedSet<Point> matchingPoints = null;
00262         YAxis y = getYAxis();
00263         if (y != null) {
00264             Dataset d = y.getDataset();
00265             if (d != null) {
00266                 matchingPoints = d.getPoints(getId());
00267             }
00268         }
00269         return matchingPoints;
00270     }

String toString (  ) 

String representation.

Reimplemented from Storeable.

Definition at line 277 of file Point.java.

00277                              {
00278         return toString(0);
00279     }

String toString ( Integer  indentBy  ) 

String representation with indent.

Definition at line 282 of file Point.java.

00282                                              {
00283         log().debug("Writing out point as a string");
00284         StringBuffer s = new StringBuffer();
00285         String indent = "";
00286         for (int i  = 0; i < indentBy; ++i) indent += " ";
00287 
00288         s.append(indent + "Point " + getId() + ": ");
00289         if (getAllErrors().size() > 0) s.append("( ");
00290         s.append(getValue());
00291         for (Uncertainty e : getAllErrors()) {
00292             s.append(" " + e.toString());
00293         }
00294         if (getAllErrors().size() > 0) s.append(" )");
00295         if (getYAxis() != null) {
00296             s.append(" " + getYAxis().getUnit().toString());
00297         }
00298         return s.toString();
00299     }

boolean equals ( Object  other  ) 

Override equals method with business key equality.

Todo:
Check that value comparison tolerances work

Definition at line 306 of file Point.java.

References YAxis.equals(), Point.getValue(), and Point.getYAxis().

00306                                         {
00307         if (this == other) return true;
00308         if (! (other instanceof Point)) return false;
00309 
00310         final Point test = (Point) other;
00311         if (test.getYAxis() != null && !test.getYAxis().equals(getYAxis()) ) return false;
00313         if (test.getValue() != null && getValue() != null &&
00314             Math.abs((test.getValue() - getValue())/getValue()) > 1e-6 ) return false;
00315 
00316         // If not proven guilty...
00317         return true;
00318     }

int hashCode (  ) 

Override hashcode method.

Definition at line 321 of file Point.java.

00321                           {
00322         int code = 0;
00323         if (getYAxis() != null) code += 100000 * getYAxis().hashCode();
00324         if (getValue() != null) code += getValue().hashCode();
00325         code *= 2; // ensure this is even
00326         return code;
00327     }

int compareTo ( Point  other  ) 

Compare points by comparing central values.

Definition at line 334 of file Point.java.

References Point.getId(), and Point.getYAxis().

00334                                       {
00335         log().debug("Comparing points...");
00336         if (getId() == null) {
00337             log().warn("Null Point ID");
00338             return 1; // Sort null points at the end
00339         } else if (getId() > other.getId()) {
00340             log().debug("Greater than");
00341             return 1;
00342         } else if (getId() < other.getId()) {
00343             log().debug("Less than");
00344             return -1;
00345         } else {
00346             log().debug("Point IDs are equal");
00347             if (getYAxis() != null && other.getYAxis() != null) {
00348                 return getYAxis().compareTo(other.getYAxis());
00349             } else {
00350                 return 0;
00351             }
00352         }
00353     }

Logger log (  )  [package, inherited]

Neat method to allow every class to get hold of a custom-named Logger.

Definition at line 14 of file Storeable.java.

Referenced by Uncertainty.compareTo(), Reference.compareTo(), PointError.compareTo(), Modification.compareTo(), Experiment.compareTo(), DatasetError.compareTo(), AxisError.compareTo(), Data.makeExample(), Data.makeExampleDataset(), Data.makeExampleExperiment(), Data.makeExamplePaper(), Data.makeExampleXAxes(), Data.makeExampleYAxes(), DatasetError.setNormType(), and Uncertainty.toString().

00014                  {
00015         return Logger.getLogger(this.getClass());
00016     }


The documentation for this class was generated from the following file:
Generated on Thu Sep 20 11:41:39 2007 by  doxygen 1.5.3