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 setBins (Collection< Bin > bins)
 Set this axis' bins from a generic collection.
XAxis setBins (Bin[] bins)
 Set this axis' bins from an array.
XAxis addBin (Bin bin)
 Add a bin to this axis.
XAxis removeBin (Bin bin)
 Remove a bin from this axis.
XAxis setBins (double[] binposns)
 Set bins from an array of doubles (for convenience).
XAxis addBin (double binpos)
 Add a bin to this axis as a double (for convenience).
XAxis removeBin (double binpos)
 Remove a bin from this axis as a double (for convenience).
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
2007-10-26 18:14:44 +0100 (Fri, 26 Oct 2007)
Revision
1110

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.

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 XAxis.compareTo(), and Bin.setXAxis().

00096                            {
00097         return _localId;
00098     }

XAxis setId ( Integer  xAxisId  ) 

Definition at line 99 of file XAxis.java.

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 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().

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.

Referenced by Data.makeExampleXAxes().

00158                                               {
00159         getBins().clear();
00160         for (Bin b : bins) addBin(b);
00161         return this;
00162     }

XAxis setBins ( Collection< Bin bins  ) 

Set this axis' bins from a generic collection.

Definition at line 164 of file XAxis.java.

00164                                                {
00165         getBins().clear();
00166         for (Bin b : bins) addBin(b);
00167         return this;
00168     }

XAxis setBins ( Bin[]  bins  ) 

Set this axis' bins from an array.

Definition at line 170 of file XAxis.java.

00170                                      {
00171         log().debug("Setting bins from array");
00172         setBins(Arrays.asList(bins));
00173         return this;
00174     }

XAxis addBin ( Bin  bin  ) 

Add a bin to this axis.

Definition at line 177 of file XAxis.java.

References Bin.setXAxis().

00177                                  {
00178         if (bin != null) {
00179             bin.setXAxis(this);
00180         } else {
00181             log().warn("Tried to add a null Bin to an XAxis");
00182         }
00183         return this;
00184     }

XAxis removeBin ( Bin  bin  ) 

Remove a bin from this axis.

Definition at line 186 of file XAxis.java.

References Bin.setXAxis().

00186                                     {
00187         if (bin != null) {
00188             bin.setXAxis(null);
00189             _bins.remove(bin);
00190         } else {
00191             log().warn("Tried to remove a null Bin from an XAxis");
00192         }
00193         return this;
00194     }

XAxis setBins ( double[]  binposns  ) 

Set bins from an array of doubles (for convenience).

Definition at line 198 of file XAxis.java.

00198                                             {
00199         log().debug("Setting bins from array");
00200         getBins().clear();
00201         for (Double bp : binposns) addBin(bp);
00202         return this;
00203     }

XAxis addBin ( double  binpos  ) 

Add a bin to this axis as a double (for convenience).

Definition at line 205 of file XAxis.java.

00205                                        {
00206         return addBin(new Bin(binpos));
00207     }

XAxis removeBin ( double  binpos  ) 

Remove a bin from this axis as a double (for convenience).

Definition at line 209 of file XAxis.java.

00209                                           {
00210         return removeBin(new Bin(binpos));
00211     }

int compareTo ( XAxis  other  ) 

Definition at line 218 of file XAxis.java.

References XAxis.getId().

00218                                       {
00219         log().debug("Comparing x-axes...");
00220         if (getId() == null) {
00221             log().warn("Null XAxis ID");
00222             return 1; // Sort null x-axes at the end
00223         } else if (getId() > other.getId()) {
00224             log().debug("Greater than");
00225             return 1;
00226         } else if (getId() < other.getId()) {
00227             log().debug("Less than");
00228             return -1;
00229         } else {
00230             log().debug("Equal to");
00231             return 0;
00232         }
00233     }

String toString (  ) 

String representation.

Reimplemented from Axis.

Definition at line 240 of file XAxis.java.

00240                              {
00241         return toString(0);
00242     }

String toString ( Integer  indentBy  ) 

String representation with indent.

Definition at line 245 of file XAxis.java.

00245                                              {
00246         log().debug("Writing out x-axis as a string");
00247         StringBuffer s = new StringBuffer();
00248         String indent = "";
00249         for (int i  = 0; i < indentBy; ++i) indent += " ";
00250 
00251         s.append(indent + "X-axis ID: " + getId() + "\n");
00252         s.append(indent + "Header: " + getHeader());
00253         for (Bin bin : getBins()) {
00254             s.append("\n" + bin.toString(indentBy + 2));
00255         }
00256         return s.toString();
00257     }

boolean equals ( Object  other  ) 

Inheritance means that we need to override equals().

Definition at line 264 of file XAxis.java.

00264                                         {
00265         if (this == other) return true;
00266         if (! (other instanceof XAxis)) return false;
00267         return hashCode() == other.hashCode();
00268     }

int hashCode (  ) 

Inheritance means that we need to override equals().

Definition at line 272 of file XAxis.java.

00272                           {
00273         int code = 341;
00274         if (getDataset() != null) code ^= getDataset().hashCode();
00275         if (getHeader()  != null) code ^= getHeader().hashCode();
00276         if (getUnit()    != null) code ^= getUnit().hashCode();
00277         code = 2*code + 1; // ensure this is odd
00278         return code;
00279     }

.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.

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.

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]


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 Tue Apr 21 15:54:51 2009 for HepData object model by  doxygen 1.5.5