Public Member Functions | |
Bin () | |
Default constructor. | |
Bin (Double centralValue) | |
Bin (Double lowValue, Double highValue) | |
Bin (Double lowValue, Double highValue, Double focus) | |
Bin (XAxis xAxis) | |
Bin (XAxis xAxis, Double centralValue) | |
Bin (XAxis xAxis, Double lowValue, Double highValue) | |
Bin (XAxis xAxis, Double lowValue, Double highValue, Double focus) | |
Integer | getId () |
Get bin ID. | |
Bin | setId (Integer binId) |
Set bin ID. | |
Double | getFocus () |
Get the nominal central value, not necessarily the gemetric centre. | |
Bin | setFocus (Double focus) |
Set the nominal "central point" of the bin - not necessarily the geometric centre. | |
Relation | getRelation () |
Get bin-edge Relation. | |
Bin | setRelation (Relation relation) |
Set the bin relation - see the get method for details. | |
Double | getLowValue () |
Get low edge value. | |
Bin | setLowValue (Double lowValue) |
Set low edge value. | |
Double | getHighValue () |
Get high edge value. | |
Bin | setHighValue (Double highValue) |
Set high edge value. | |
Double | getWidth () |
Get bin width. | |
Bin | setWidth (Double width) |
Set bin width. | |
XAxis | getXAxis () |
Get containing x-axis. | |
Bin | setXAxis (XAxis xAxis) |
Set containing x-axis. | |
SortedSet< Bin > | getBins () |
Get all the x-axis Bins which are in the same row as this one (inclusive). | |
SortedSet< Point > | getPoints () |
Get the corresponding Points from the y-axes in this Dataset. | |
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 (Bin other) |
Compare bins by comparing Ids. | |
Package Functions | |
Logger | log () |
Neat method to allow every class to get hold of a custom-named Logger. |
Definition at line 18 of file Bin.java.
Bin | ( | Double | centralValue | ) |
Bin | ( | Double | lowValue, | |
Double | highValue | |||
) |
Definition at line 67 of file Bin.java.
00067 { 00068 setLowValue(lowValue); 00069 setHighValue(highValue); 00070 }
Bin | ( | Double | lowValue, | |
Double | highValue, | |||
Double | focus | |||
) |
Integer getId | ( | ) |
Get bin ID.
Definition at line 101 of file Bin.java.
Referenced by XAxis.addBin(), and Bin.compareTo().
Bin setId | ( | Integer | binId | ) |
Double getFocus | ( | ) |
Get the nominal central value, not necessarily the gemetric centre.
If the focus has not been defined, the geometric centre will be calculated.
Definition at line 113 of file Bin.java.
Referenced by Bin.equals().
00113 { 00114 if (_focus != null) return _focus; 00115 00116 // Fall back to calculating the geometric centre 00117 log().debug("Asked for focus, but focus is null."); 00118 if (getLowValue() != null && getHighValue() != null) { 00119 log().info("Calculating central value from high and low edges"); 00120 return (getLowValue() + getHighValue()) / 2.0; 00121 } else { 00122 log().warn("Could neither retrieve nor calculate bin focus."); 00123 return null; 00124 } 00125 }
Bin setFocus | ( | Double | focus | ) |
Relation getRelation | ( | ) |
Get bin-edge Relation.
The relation can give different meanings to the bin edge values: the normal EQUALS relation means the bin edges should be taken as low and high limits as normal.
A "greater-type" relation means that the bin extends from its low edge upwards to infinity and a "less-type" relation will extend the bin from the high edge down to the negative limit. The "unused" edges can be used in these cases to specify a realistic upper or lower limit as appropriate.
Obviously, use of non-EQUALS relations should be restricted to the lowest and highest bins on the axis.
Definition at line 147 of file Bin.java.
Double getLowValue | ( | ) |
Bin setLowValue | ( | Double | lowValue | ) |
Double getHighValue | ( | ) |
Bin setHighValue | ( | Double | highValue | ) |
Double getWidth | ( | ) |
Get bin width.
Definition at line 182 of file Bin.java.
00182 { 00183 if (_width == null) { 00184 log().info("Asked for width, but Width is null."); 00185 if (getHighValue() != null && getLowValue() != null) { 00186 log().info("Calculating width from high and low edges"); 00187 return Math.abs(getHighValue() - getLowValue()); 00188 } 00189 } 00190 return _width; 00191 }
Bin setWidth | ( | Double | width | ) |
XAxis getXAxis | ( | ) |
Get containing x-axis.
Definition at line 202 of file Bin.java.
Referenced by Bin.compareTo(), and Bin.equals().
Set containing x-axis.
Definition at line 206 of file Bin.java.
References XAxis.getBins().
Referenced by XAxis.addBin(), and XAxis.removeBin().
00206 { 00207 _xAxis = xAxis; 00208 if (getXAxis() != null) getXAxis().getBins().add(this); 00209 return this; 00210 }
SortedSet<Bin> getBins | ( | ) |
Get all the x-axis Bins which are in the same row as this one (inclusive).
Definition at line 217 of file Bin.java.
References Dataset.getBins(), and XAxis.getDataset().
00217 { 00218 SortedSet<Bin> matchingBins = null; 00219 XAxis x = getXAxis(); 00220 if (x != null) { 00221 Dataset d = x.getDataset(); 00222 if (d != null) { 00223 matchingBins = d.getBins(getId()); 00224 } 00225 } 00226 return matchingBins; 00227 }
SortedSet<Point> getPoints | ( | ) |
Get the corresponding Points from the y-axes in this Dataset.
Definition at line 230 of file Bin.java.
References XAxis.getDataset(), and Dataset.getPoints().
00230 { 00231 SortedSet<Point> matchingPoints = null; 00232 XAxis x = getXAxis(); 00233 if (x != null) { 00234 Dataset d = x.getDataset(); 00235 if (d != null) { 00236 matchingPoints = d.getPoints(getId()); 00237 } 00238 } 00239 return matchingPoints; 00240 }
String toString | ( | ) |
String toString | ( | Integer | indentBy | ) |
String representation with indent.
Definition at line 252 of file Bin.java.
00252 { 00253 log().debug("Writing out x-axis as a string"); 00254 StringBuffer s = new StringBuffer(); 00255 String indent = ""; 00256 for (int i = 0; i < indentBy; ++i) indent += " "; 00257 00258 s.append(indent + "Bin " + getId() + ": "); 00259 if (getLowValue() != null && getHighValue() != null) { 00260 s.append(getLowValue() + " - " + getHighValue()); 00261 } else if (getFocus() != null) { 00262 s.append(getFocus()); 00263 if (getWidth() != null) { 00264 s.append(" (width = " + getWidth() + ")"); 00265 } 00266 } 00267 return s.toString(); 00268 }
boolean equals | ( | Object | other | ) |
Override equals method with business key equality.
Definition at line 275 of file Bin.java.
References XAxis.equals(), Bin.getFocus(), and Bin.getXAxis().
00275 { 00276 if (this == other) return true; 00277 if (! (other instanceof Bin)) return false; 00278 00279 final Bin test = (Bin) other; 00280 if (test.getXAxis() != null && !test.getXAxis().equals(getXAxis()) ) return false; 00282 if (test.getFocus() != null && getFocus() != null && 00283 (test.getFocus() - getFocus())/getFocus() > 1e-6 ) return false; 00284 00285 // If not proven guilty... 00286 return true; 00287 }
int hashCode | ( | ) |
Override hashcode method.
Definition at line 291 of file Bin.java.
00291 { 00292 int code = 0; 00293 if (getXAxis() != null) code += 100000 * getXAxis().hashCode(); 00294 if (getFocus() != null) code += (int) (1000 * getFocus()); 00295 code *= 2; ++code; // ensure this is odd 00296 return code; 00297 }
int compareTo | ( | Bin | other | ) |
Compare bins by comparing Ids.
Definition at line 304 of file Bin.java.
References Bin.getId(), and Bin.getXAxis().
00304 { 00305 log().debug("Comparing bins..."); 00306 if (getId() == null) { 00307 log().warn("Null Bin ID"); 00309 return 1; // Sort null bins at the end 00310 } else if (getId() > other.getId()) { 00311 log().debug("Greater than"); 00312 return 1; 00313 } else if (getId() < other.getId()) { 00314 log().debug("Less than"); 00315 return -1; 00316 } else { 00317 log().debug("Bin IDs are equal"); 00318 if (getXAxis() != null && other.getXAxis() != null) { 00319 return getXAxis().compareTo(other.getXAxis()); 00320 } else { 00321 return 0; 00322 } 00323 } 00324 }
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().