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
 Set the relation, value and confidence level all at the same time, if this value is a limit.
Integer getId ()
 Get the point ID.
Point setId (Integer pointId)
 Set the point ID.
Double getValue ()
 Get the point value.
Point setValue (Double value)
 Set the point value.
Relation getRelation ()
 Get the relation type (equal, less than, greater than).
Point setRelation (Relation relation)
 Set the relation type (equal, less than, greater than).
Double getConfidenceLevel ()
 Get the confidence level.
Point setConfidenceLevel (Double confidenceLevel) throws HDException
 Set the confidence level.
SortedSet< PointErrorgetErrors ()
 Get the point errors.
Point setErrors (SortedSet< PointError > errors)
 Set the point errors.
Point setErrors (Collection< PointError > errors)
 Set the point errors (from generic collection).
Point setErrors (PointError[] errors)
 Set the point errors (from array).
Point addError (PointError error)
 Add a point error.
Point removeError (PointError error)
 Remove a point 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
2006-02-02 16:35:56 +0000 (Thu, 02 Feb 2006)
Revision
500

Definition at line 21 of file Point.java.


Constructor & Destructor Documentation

Point (  ) 

No-arg constructor for Hibernate.

Definition at line 60 of file Point.java.

00060 {}

Point ( Double  value  ) 

Constructor for a value.

Definition at line 63 of file Point.java.

00063                                {
00064         setValue(value);
00065     }

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

Constructor for a limit.

Definition at line 68 of file Point.java.

00068                                                                                              {
00069         setLimit(relation, value, confidenceLevel);
00070     }

Point ( YAxis  yAxis  ) 

Constructor binding to a particular axis.

Definition at line 73 of file Point.java.

00073                               {
00074         setYAxis(yAxis);
00075     }

Point ( YAxis  yAxis,
Double  value 
)

Constructor for a value, binding to a particular axis.

Definition at line 78 of file Point.java.

00078                                             {
00079         this(yAxis);
00080         setValue(value);
00081     }

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

Constructor for a limit, binding to a particular axis.

Definition at line 84 of file Point.java.

00084                                                                                                           {
00085         this(yAxis);
00086         setLimit(relation, value, confidenceLevel);
00087     }


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

Set the relation, value and confidence level all at the same time, if this value is a limit.

Definition at line 94 of file Point.java.

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

Integer getId (  ) 

Get the point ID.

Definition at line 106 of file Point.java.

Referenced by Point.compareTo().

00106                            {
00107         return _localId;
00108     }

Point setId ( Integer  pointId  ) 

Set the point ID.

Definition at line 110 of file Point.java.

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

Double getValue (  ) 

Get the point value.

Definition at line 117 of file Point.java.

00117                              {
00118         return _value;
00119     }

Point setValue ( Double  value  ) 

Set the point value.

Definition at line 121 of file Point.java.

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

Relation getRelation (  ) 

Get the relation type (equal, less than, greater than).

Definition at line 128 of file Point.java.

00128                                   {
00129         return _relation;
00130     }

Point setRelation ( Relation  relation  ) 

Set the relation type (equal, less than, greater than).

Definition at line 133 of file Point.java.

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

Double getConfidenceLevel (  ) 

Get the confidence level.

Definition at line 140 of file Point.java.

00140                                        {
00141         return _confidenceLevel;
00142     }

Point setConfidenceLevel ( Double  confidenceLevel  )  throws HDException

Set the confidence level.

Definition at line 145 of file Point.java.

00145                                                                                {
00146         if (getRelation() != Relation.EQUALS) {
00147             _confidenceLevel = confidenceLevel;
00148         } else {
00149             _confidenceLevel = null;
00150         }
00151         return this;
00152     }

SortedSet<PointError> getErrors (  ) 

Get the point errors.

Definition at line 156 of file Point.java.

Referenced by PointError.setPoint().

00156                                              {
00157         return _errors;
00158     }

Point setErrors ( SortedSet< PointError errors  ) 

Set the point errors.

Definition at line 161 of file Point.java.

00161                                                          {
00162         getErrors().clear();
00163         for (PointError e : errors) addError(e);
00164         return this;
00165     }

Point setErrors ( Collection< PointError errors  ) 

Set the point errors (from generic collection).

Definition at line 168 of file Point.java.

00168                                                           {
00169         log().debug("Calling setErrors(Collection<PointError>)");
00170         getErrors().clear();
00171         for (PointError e : errors) addError(e);
00172         return this;
00173     }

Point setErrors ( PointError[]  errors  ) 

Set the point errors (from array).

Definition at line 176 of file Point.java.

00176                                                 {
00177         setErrors(Arrays.asList(errors));
00178         return this;
00179     }

Point addError ( PointError  error  ) 

Add a point error.

Definition at line 182 of file Point.java.

References PointError.setPoint().

00182                                             {
00183         if (error != null) {
00184             error.setPoint(this);
00185         } else {
00186             log().warn("Tried to add a null point error to a point");
00187         }
00188         return this;
00189     }

Point removeError ( PointError  error  ) 

Remove a point error.

Definition at line 192 of file Point.java.

00192                                                {
00193         if (error != null) {
00194             _errors.remove(error);
00195         } else {
00196             log().warn("Tried to remove a null point error from a point");
00197         }
00198         return this;
00199     }

YAxis getYAxis (  ) 

Get containing y-axis.

Definition at line 203 of file Point.java.

Referenced by Point.compareTo().

00203                             {
00204         return _yAxis;
00205     }

Point setYAxis ( YAxis  yAxis  ) 

Set containing y-axis.

Definition at line 207 of file Point.java.

References YAxis.getId(), and YAxis.getPoints().

Referenced by YAxis.addPoint().

00207                                        {
00208         _yAxis = yAxis;
00209         if (yAxis != null) {
00210             if (getId() == null) {
00211                 int highestId = 0;
00212                 if (yAxis.getPoints().size() > 0) {
00213                     highestId = yAxis.getPoints().last().getId();
00214                 }
00215                 log().debug("Incrementing point ID: " + (highestId + 1));
00216                 setId(highestId + 1);
00217             }
00218             log().debug("Adding point to y-axis " + yAxis.getId() + ": ID = " + getId());
00219             yAxis.getPoints().add(this);
00220         }
00221         return this;
00222     }

Set<Uncertainty> getDatasetErrors (  ) 

Get errors from parent Dataset.

Definition at line 229 of file Point.java.

00229                                                {
00230         if (getYAxis() != null) {
00231             return getYAxis().getDatasetErrors();
00232         } else {
00233             return new HashSet<Uncertainty>();
00234         }
00235     }

SortedSet<Uncertainty> getAxisErrors (  ) 

Get errors from parent YAxis.

Definition at line 237 of file Point.java.

00237                                                   {
00238         SortedSet<Uncertainty> axisErrors = new TreeSet<Uncertainty>();
00239         if (getYAxis() != null) {
00240             axisErrors.addAll( getYAxis().getErrors() );
00241         }
00242         return axisErrors;
00243     }

Set<Uncertainty> getPointErrors (  ) 

Get errors from this point (as generic Errors).

Definition at line 245 of file Point.java.

00245                                              {
00246         return new HashSet<Uncertainty>(getErrors());
00247     }

SortedSet<Uncertainty> getAllErrors (  ) 

Get all the errors that apply to this point.

Definition at line 249 of file Point.java.

00249                                                  {
00250         SortedSet<Uncertainty> allErrors = new TreeSet<Uncertainty>();
00251         allErrors.addAll(getErrors());
00252         allErrors.addAll(getAxisErrors());
00253         allErrors.addAll(getDatasetErrors());
00254         return allErrors;
00255     }

SortedSet<Bin> getBins (  ) 

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

Definition at line 262 of file Point.java.

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

00262                                     {
00263         SortedSet<Bin> matchingBins = null;
00264         YAxis y = getYAxis();
00265         if (y != null) {
00266             Dataset d = y.getDataset();
00267             if (d != null) {
00268                 matchingBins = d.getBins(getId());
00269             }
00270         }
00271         return matchingBins;
00272     }

SortedSet<Point> getPoints (  ) 

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

Definition at line 275 of file Point.java.

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

Referenced by YAxis.setPoints().

00275                                         {
00276         SortedSet<Point> matchingPoints = null;
00277         YAxis y = getYAxis();
00278         if (y != null) {
00279             Dataset d = y.getDataset();
00280             if (d != null) {
00281                 matchingPoints = d.getPoints(getId());
00282             }
00283         }
00284         return matchingPoints;
00285     }

String toString (  ) 

String representation.

Reimplemented from Storeable.

Definition at line 292 of file Point.java.

00292                              {
00293         return toString(0);
00294     }

String toString ( Integer  indentBy  ) 

String representation with indent.

Definition at line 297 of file Point.java.

00297                                              {
00298         log().debug("Writing out point as a string");
00299         StringBuffer s = new StringBuffer();
00300         String indent = "";
00301         for (int i  = 0; i < indentBy; ++i) indent += " ";
00302 
00303         s.append(indent + "Point " + getId() + ": ");
00304         if (getAllErrors().size() > 0) s.append("( ");
00305         s.append(getValue());
00306         for (Uncertainty e : getAllErrors()) {
00307             s.append(" " + e.toString());
00308         }
00309         if (getAllErrors().size() > 0) s.append(" )");
00310         if (getYAxis() != null) {
00311             s.append(" " + getYAxis().getUnit().toString());
00312         }
00313         return s.toString();
00314     }

boolean equals ( Object  other  ) 

Override equals method with business key equality.

Definition at line 321 of file Point.java.

00321                                         {
00322         if (this == other) return true;
00323         if (! (other instanceof Point)) return false;
00324         return hashCode() == other.hashCode();
00325     }

int hashCode (  ) 

Override hashcode method.

Definition at line 329 of file Point.java.

Referenced by PointError.hashCode().

00329                           {
00330         int code = 57;
00331         if (getYAxis() != null) code ^= getYAxis().hashCode();
00332         if (getValue() != null) code ^= getValue().hashCode();
00333         if (getId() != null)    code ^= getId().hashCode();
00334         return code;
00335     }

int compareTo ( Point  other  ) 

Compare points by comparing central values.

Definition at line 342 of file Point.java.

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

00342                                       {
00343         log().debug("Comparing points...");
00344         if (getId() == null) {
00345             log().warn("Null Point ID");
00346             return 1; // Sort null points at the end
00347         } else if (getId() > other.getId()) {
00348             log().debug("Greater than");
00349             return 1;
00350         } else if (getId() < other.getId()) {
00351             log().debug("Less than");
00352             return -1;
00353         } else {
00354             log().debug("Point IDs are equal");
00355             if (getYAxis() != null && other.getYAxis() != null) {
00356                 return getYAxis().compareTo(other.getYAxis());
00357             } else {
00358                 return 0;
00359             }
00360         }
00361     }

Logger log (  )  [package, inherited]


The documentation for this class was generated from the following file:


Generated on Tue Apr 21 15:54:48 2009 for HepData object model by  doxygen 1.5.5