XAxis Class Reference

An XAxis contains header information and a set of Bins. More...

Inheritance diagram for XAxis:

Inheritance graph
[legend]

Collaboration diagram for XAxis:

Collaboration graph
[legend]

List of all members.


Public Member Functions

 XAxis ()
 Default constructor.
 XAxis (String header)
 XAxis (String header, Unit unit)
 XAxis (Dataset dataset)
 XAxis (Dataset dataset, String header)
 XAxis (Dataset dataset, String header, Unit unit)
Paper getPaper ()
 Get the Paper that this axis belongs to.
Integer getId ()
XAxis setId (Integer xAxisId)
Dataset getDataset ()
 Get the Dataset that this axis belongs to.
XAxis setDataset (Dataset dataset)
 Over-ride dataset assignment, to get null IDs right.
SortedSet< YAxisgetYAxes ()
 Get associated y-axes.
SortedSet< BingetBins ()
 Get this axis' bins.
Bin getBin (Integer binId)
 Get a specific bin from this axis by bin ID code.
XAxis setBins (SortedSet< Bin > bins)
 Set this axis' bins explicitly from a SortedSet (to keep reflection apps happy).
XAxis addBin (Bin bin)
 Set this axis' bins from a generic collection.
XAxis removeBin (Bin bin)
 Remove a bin from this axis.
int compareTo (XAxis other)
String toString ()
 String representation.
String toString (Integer indentBy)
 String representation with indent.
boolean equals (Object other)
 Inheritance means that we need to override equals().
int hashCode ()
 Inheritance means that we need to override equals().
String getHeader ()
 Get the axis header.
Axis setHeader (String header)
 Set the axis header.
Unit getUnit ()
 Get the Unit in which values on this axis are measured.
Axis setUnit (Unit unit)
 Set the Unit in which values on this axis are measured.

Protected Attributes

Dataset _dataset
 Parent dataset.

Package Functions

.hibernate.annotations. Fetch (value=org.hibernate.annotations.FetchMode.JOIN)@org.hibernate.annotations.Cascade(value
 Collection of bins.
.hibernate.annotations. Type (type="cedar.hepdata.db.UnitUserType") private Unit _unit
 Unit which the points on this axis are measured in.
Logger log ()
 Neat method to allow every class to get hold of a custom-named Logger.

Detailed Description

An XAxis contains header information and a set of Bins.

A Dataset has one or more XAxes.

Author:
Andy Buckley
Version:
Date
Revision

Definition at line 23 of file XAxis.java.


Constructor & Destructor Documentation

XAxis (  ) 

Default constructor.

Definition at line 46 of file XAxis.java.

00046                    {
00047         super();
00048         log().debug("Making an XAxis (No dataset, 0 arg constructor)");
00049     }

XAxis ( String  header  ) 

Definition at line 51 of file XAxis.java.

00051                                 {
00052         super(header);
00053         log().debug("Making an XAxis (No dataset, 1 arg constructor)");
00054     }

XAxis ( String  header,
Unit  unit 
)

Definition at line 56 of file XAxis.java.

00056                                            {
00057         super(header, unit);
00058         log().debug("Making an XAxis (No dataset, 2 arg constructor)");
00059     }

XAxis ( Dataset  dataset  ) 

Definition at line 61 of file XAxis.java.

00061                                   {
00062         this();
00063         setDataset(dataset);
00064         log().debug("Making an XAxis (With dataset, 1 arg constructor)");
00065     }

XAxis ( Dataset  dataset,
String  header 
)

Definition at line 67 of file XAxis.java.

00067                                                  {
00068         this(header);
00069         setDataset(dataset);
00070         log().debug("Making an XAxis (With dataset, 2 arg constructor)");
00071     }

XAxis ( Dataset  dataset,
String  header,
Unit  unit 
)

Definition at line 73 of file XAxis.java.

00073                                                             {
00074         this(header, unit);
00075         setDataset(dataset);
00076         log().debug("Making an XAxis (With dataset, 3 arg constructor)");
00077     }


Member Function Documentation

.hibernate.annotations. Fetch ( value  = org.hibernate.annotations.FetchMode.JOIN  )  [package]

Collection of bins.

Paper getPaper (  ) 

Get the Paper that this axis belongs to.

Note two degrees of separation, since there's a dataset in-between: watch out for null returns during hierarchy construction, e.g. in unpersisting from XML or database.

Definition at line 86 of file XAxis.java.

Referenced by XAxis.equals().

00086                             {
00087         if (getDataset() != null) {
00088             return getDataset().getPaper();
00089         } else {
00090             return null;
00091         }
00092     }

Integer getId (  ) 

Definition at line 96 of file XAxis.java.

Referenced by Dataset.addXAxis(), and XAxis.compareTo().

00096                            {
00097         return _localId;
00098     }

XAxis setId ( Integer  xAxisId  ) 

Definition at line 99 of file XAxis.java.

Referenced by Dataset.addXAxis().

00099                                         {
00100         _localId = xAxisId;
00101         return this;
00102     }

Dataset getDataset (  ) 

Get the Dataset that this axis belongs to.

Definition at line 106 of file XAxis.java.

Referenced by XAxis.equals(), Bin.getBins(), and Bin.getPoints().

00106                                 {
00107         return _dataset;
00108     }

XAxis setDataset ( Dataset  dataset  ) 

Over-ride dataset assignment, to get null IDs right.

Definition at line 110 of file XAxis.java.

References Dataset.getXAxes().

Referenced by Dataset.addXAxis(), and Dataset.removeXAxis().

00110                                              {
00111         log().debug("Calling setDataset()");
00112         _dataset = dataset;
00113         if (dataset != null) {
00114             if (getId() == null) {
00115                 int highestId = 0;
00116                 if (dataset.getXAxes().size() > 0) {
00117                     highestId = dataset.getXAxes().last().getId();
00118                 }
00119                 log().debug("Incrementing x-axis ID: " + (highestId + 1));
00120                 setId(highestId + 1);
00121 
00122             }
00123             log().debug("Adding myself to a Dataset");
00124             dataset.getXAxes().add(this);
00125         } else {
00126             log().warn("Tried to attach a XAxis to a null Dataset");
00127         }
00128         return this;
00129     }

SortedSet<YAxis> getYAxes (  ) 

Get associated y-axes.

Definition at line 133 of file XAxis.java.

00133                                        {
00134         if (getDataset() != null) {
00135             return getDataset().getYAxes();
00136         } else {
00137             return null;
00138         }
00139     }

SortedSet<Bin> getBins (  ) 

Get this axis' bins.

Definition at line 143 of file XAxis.java.

Referenced by Bin.setXAxis().

00143                                     {
00144         return _bins;
00145     }

Bin getBin ( Integer  binId  ) 

Get a specific bin from this axis by bin ID code.

Definition at line 147 of file XAxis.java.

00147                                      {
00148         Bin theBin = null;
00149         for (Bin b : getBins()) {
00150             if (b.getId() == binId) {
00151                 theBin = b;
00152                 break;
00153             }
00154         }
00155         return theBin;
00156     }

XAxis setBins ( SortedSet< Bin bins  ) 

Set this axis' bins explicitly from a SortedSet (to keep reflection apps happy).

Definition at line 158 of file XAxis.java.

00158                                               {
00159         _bins = bins;
00160         return this;
00161     }

XAxis addBin ( Bin  bin  ) 

Set this axis' bins from a generic collection.

Set this axis' bins from an array Add a bin to this axis

Definition at line 176 of file XAxis.java.

References Bin.getId(), Bin.setId(), and Bin.setXAxis().

Referenced by Data.makeExampleXAxes().

00176                                  {
00177         if (bin != null) {
00178             if (bin.getId() == null) {
00179                 int highestId = 0;
00180                 if (getBins().size() > 0) {
00181                     highestId = getBins().last().getId();
00182                 }
00183                 log().debug("Incrementing bin ID: " + (highestId + 1));
00184                 bin.setId(highestId + 1);
00185             }
00186             log().debug("Adding bin: ID = " + bin.getId());
00187             bin.setXAxis(this);
00188         } else {
00189             log().warn("Tried to add a null Bin to an XAxis");
00190         }
00191         return this;
00192     }

XAxis removeBin ( Bin  bin  ) 

Remove a bin from this axis.

Todo:
Data orphaning: cascade should handle this. CHECK

Definition at line 194 of file XAxis.java.

References Bin.setXAxis().

00194                                     {
00195         if (bin != null) {
00196             bin.setXAxis(null); 
00197             _bins.remove(bin);
00198         } else {
00199             log().warn("Tried to remove a null Bin from an XAxis");
00200         }
00201         return this;
00202     }

int compareTo ( XAxis  other  ) 

Definition at line 208 of file XAxis.java.

References XAxis.getId().

00208                                       {
00209         log().debug("Comparing x-axes...");
00210         if (getId() == null) {
00211             log().warn("Null XAxis ID");
00212             return 1; // Sort null x-axes at the end
00213         } else if (getId() > other.getId()) {
00214             log().debug("Greater than");
00215             return 1;
00216         } else if (getId() < other.getId()) {
00217             log().debug("Less than");
00218             return -1;
00219         } else {
00220             log().debug("Equal to");
00221             return 0;
00222         }
00223     }

String toString (  ) 

String representation.

Reimplemented from Axis.

Definition at line 230 of file XAxis.java.

00230                              {
00231         return toString(0);
00232     }

String toString ( Integer  indentBy  ) 

String representation with indent.

Definition at line 235 of file XAxis.java.

00235                                              {
00236         log().debug("Writing out x-axis as a string");
00237         StringBuffer s = new StringBuffer();
00238         String indent = "";
00239         for (int i  = 0; i < indentBy; ++i) indent += " ";
00240 
00241         s.append(indent + "X-axis ID: " + getId() + "\n");
00242         s.append(indent + "Header: " + getHeader());
00243         for (Bin bin : getBins()) {
00244             s.append("\n" + bin.toString(indentBy + 2));
00245         }
00246         return s.toString();
00247     }

boolean equals ( Object  other  ) 

Inheritance means that we need to override equals().

Definition at line 254 of file XAxis.java.

References XAxis.getDataset(), Axis.getHeader(), XAxis.getPaper(), and Axis.getUnit().

Referenced by Bin.equals().

00254                                         {
00255         if (this == other) return true;
00256         if (! (other instanceof XAxis)) return false;
00257 
00258         final XAxis test = (XAxis) other;
00259         if (! test.getPaper().equals(getPaper()) ) return false;
00260         if (! test.getDataset().equals(getDataset()) ) return false;
00261         if (! test.getHeader().equals(getHeader()) ) return false;
00262         if (! test.getUnit().equals(getUnit()) ) return false;
00263         return true;
00264     }

int hashCode (  ) 

Inheritance means that we need to override equals().

Definition at line 268 of file XAxis.java.

00268                           {
00269         int code = 0;
00270         if (getPaper()   != null) code += 1000000 * getPaper().hashCode();
00271         if (getDataset() != null) code += 100 * getDataset().hashCode();
00272         if (getHeader()  != null) code += 10 * getHeader().hashCode();
00273         if (getUnit()    != null) code += getUnit().hashCode();
00274         code *= 2; ++code; // ensure this is odd
00275         return code;
00276     }

.hibernate.annotations. Type ( type  = "cedar.hepdata.db.UnitUserType"  )  [package, inherited]

Unit which the points on this axis are measured in.

String getHeader (  )  [inherited]

Get the axis header.

Definition at line 55 of file Axis.java.

Referenced by YAxis.equals(), and XAxis.equals().

00055                               {
00056         return _header;
00057     }

Axis setHeader ( String  header  )  [inherited]

Set the axis header.

Definition at line 59 of file Axis.java.

00059                                          {
00060         _header = header;
00061         return this;
00062     }

Unit getUnit (  )  [inherited]

Get the Unit in which values on this axis are measured.

Definition at line 66 of file Axis.java.

Referenced by YAxis.equals(), and XAxis.equals().

00066                           {
00067         return _unit;
00068     }

Axis setUnit ( Unit  unit  )  [inherited]

Set the Unit in which values on this axis are measured.

Definition at line 71 of file Axis.java.

00071                                    {
00072         _unit = unit;
00073         return this;
00074     }

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     }


Member Data Documentation

Dataset _dataset [protected]

Parent dataset.

Definition at line 39 of file XAxis.java.


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