AxisReaction Class Reference

A Reaction with attached y-axes. More...

Inheritance diagram for AxisReaction:

Inheritance graph
[legend]

Collaboration diagram for AxisReaction:

Collaboration graph
[legend]

List of all members.


Public Member Functions

 AxisReaction ()
 No-arg constructor.
YAxis getYAxis ()
 Get the y-axis.
AxisReaction setYAxis (YAxis yAxis)
 Set the y-axis.
Set< ParticlegetInitialState ()
 Get initial state.
Reaction setInitialState (Set< Particle > initialState)
 Set initial state.
Reaction addToInitialState (Particle particle)
 Add a particle (with multiplicity) into the initial state.
Reaction removeFromInitialState (Particle particle)
 Remove a particle (with multiplicity) from the initial state: this will only remove the corresponding multiplicity from the state, without going negative.
Reaction purgeFromInitialState (Particle particle)
 Remove all particles of this type from the initial state.
Set< ParticlegetFinalState ()
 Get final state.
Reaction setFinalState (Set< Particle > finalState)
 Set final state.
Reaction addToFinalState (Particle particle)
 Add a particle (with multiplicity) into the final state.
Reaction removeFromFinalState (Particle particle)
 Remove a particle (with multiplicity) from the final state: this will only remove the corresponding multiplicity from the state, without going negative.
Reaction purgeFromFinalState (Particle particle)
 Remove all particles of this type from the final state.
Set< ReactionGroupgetReactionGroups ()
 Get the set of ReactionGroups.
Reaction setReactionGroups (Set< ReactionGroup > reactionGroups)
 Define the set of ReactionGroups.
Reaction addReactionGroup (ReactionGroup reactionGroup)
 Add a ReactionGroup.
Reaction removeReactionGroup (ReactionGroup reactionGroup)
 Remove a ReactionGroup.
boolean equals (Object other)
 Compare reactions for equality.
String initialStateToString ()
 String representation of the initial state.
String finalStateToString ()
 String representation of the final state.
String toString ()
 String representation of this Reaction.

Package Functions

.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId (columns=@Column(name="InitialStateId"), type=@org.hibernate.annotations.Type(type="long"), generator="sequence") private Set< Particle > initialState
 A collection of particles and multiplicities in the initial state.
.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId (columns=@Column(name="FinalStateId"), type=@org.hibernate.annotations.Type(type="long"), generator="sequence") private Set< Particle > finalState
 A collection of particles and multiplicities in the final state.
Logger log ()
 Neat method to allow every class to get hold of a custom-named Logger.

Detailed Description

A Reaction with attached y-axes.

Author:
Andy Buckley
Version:
Date
Revision

Definition at line 16 of file AxisReaction.java.


Constructor & Destructor Documentation

AxisReaction (  ) 

No-arg constructor.

Definition at line 26 of file AxisReaction.java.

00026                           {
00027         super();
00028     }


Member Function Documentation

YAxis getYAxis (  ) 

Get the y-axis.

Definition at line 36 of file AxisReaction.java.

00036                             {
00037         return _yAxis;
00038     }

AxisReaction setYAxis ( YAxis  yAxis  ) 

Set the y-axis.

Definition at line 41 of file AxisReaction.java.

Referenced by YAxis.addReaction(), and YAxis.removeReaction().

00041                                               {
00042         if (getYAxis() != null) {
00043             getYAxis().getReactions().add(this);
00044         }
00045         _yAxis = yAxis;
00046         return this;
00047     }

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

A collection of particles and multiplicities in the initial state.

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

A collection of particles and multiplicities in the final state.

Set<Particle> getInitialState (  )  [inherited]

Get initial state.

Definition at line 57 of file Reaction.java.

Referenced by Reaction.equals().

00057                                            {
00058         return initialState;
00059     }

Reaction setInitialState ( Set< Particle initialState  )  [inherited]

Set initial state.

Definition at line 61 of file Reaction.java.

00061                                                                 {
00062         this.initialState = initialState;
00063         return this;
00064     }

Reaction addToInitialState ( Particle  particle  )  [inherited]

Add a particle (with multiplicity) into the initial state.

If a particle of the same type already exists, the multiplicities will be combined.

Definition at line 69 of file Reaction.java.

References Particle.getMultiplicity().

00069                                                          {
00070         boolean foundType = false;
00071         for (Particle p : this.initialState) {
00072             if (Particle.sameType(p, particle)) {
00073                 foundType = true;
00074                 p.setMultiplicity(p.getMultiplicity() + particle.getMultiplicity());
00075                 break;
00076             }
00077         }
00078         if (!foundType) this.initialState.add(particle);
00079         return this;
00080     }

Reaction removeFromInitialState ( Particle  particle  )  [inherited]

Remove a particle (with multiplicity) from the initial state: this will only remove the corresponding multiplicity from the state, without going negative.

If you want to remove all the particles of a given type from the state, use purgeFromInitialState().

Definition at line 87 of file Reaction.java.

References Particle.getMultiplicity().

00087                                                               {
00088         for (Particle p : this.initialState) {
00089             if (Particle.sameType(p, particle)) {
00090                 int newMult = p.getMultiplicity() - particle.getMultiplicity();
00091                 if (newMult <= 0) {
00092                     this.initialState.remove(p);
00093                 } else {
00094                     p.setMultiplicity(newMult);
00095                 }
00096                 break;
00097             }
00098         }
00099         return this;
00100     }

Reaction purgeFromInitialState ( Particle  particle  )  [inherited]

Remove all particles of this type from the initial state.

Definition at line 102 of file Reaction.java.

00102                                                              {
00103         for (Particle p : this.initialState) {
00104             if (Particle.sameType(p, particle)) {
00105                 this.initialState.remove(p);
00106             }
00107         }
00108         return this;
00109     }

Set<Particle> getFinalState (  )  [inherited]

Get final state.

Definition at line 113 of file Reaction.java.

Referenced by Reaction.equals().

00113                                          {
00114         return finalState;
00115     }

Reaction setFinalState ( Set< Particle finalState  )  [inherited]

Set final state.

Definition at line 117 of file Reaction.java.

00117                                                             {
00118         this.finalState = finalState;
00119         return this;
00120     }

Reaction addToFinalState ( Particle  particle  )  [inherited]

Add a particle (with multiplicity) into the final state.

If a particle of the same type already exists, the multiplicities will be combined.

Definition at line 125 of file Reaction.java.

References Particle.getMultiplicity().

00125                                                        {
00126         boolean foundType = false;
00127         for (Particle p : this.finalState) {
00128             if (Particle.sameType(p, particle)) {
00129                 foundType = true;
00130                 p.setMultiplicity(p.getMultiplicity() + particle.getMultiplicity());
00131                 break;
00132             }
00133         }
00134         if (!foundType) this.finalState.add(particle);
00135         return this;
00136     }

Reaction removeFromFinalState ( Particle  particle  )  [inherited]

Remove a particle (with multiplicity) from the final state: this will only remove the corresponding multiplicity from the state, without going negative.

If you want to remove all the particles of a given type from the state, use purgeFromFinalState().

Definition at line 143 of file Reaction.java.

References Particle.getMultiplicity().

00143                                                             {
00144         for (Particle p : this.finalState) {
00145             if (Particle.sameType(p, particle)) {
00146                 int newMult = p.getMultiplicity() - particle.getMultiplicity();
00147                 if (newMult <= 0) {
00148                     this.finalState.remove(p);
00149                 } else {
00150                     p.setMultiplicity(newMult);
00151                 }
00152                 break;
00153             }
00154         }
00155         return this;
00156     }

Reaction purgeFromFinalState ( Particle  particle  )  [inherited]

Remove all particles of this type from the final state.

Definition at line 158 of file Reaction.java.

00158                                                            {
00159         for (Particle p : this.finalState) {
00160             if (Particle.sameType(p, particle)) {
00161                 this.finalState.remove(p);
00162             }
00163         }
00164         return this;
00165     }

Set<ReactionGroup> getReactionGroups (  )  [inherited]

Get the set of ReactionGroups.

Definition at line 170 of file Reaction.java.

Referenced by ReactionGroup.addReaction(), and ReactionGroup.removeReaction().

00170                                                   {
00171         return reactionGroups;
00172     }

Reaction setReactionGroups ( Set< ReactionGroup reactionGroups  )  [inherited]

Define the set of ReactionGroups.

Definition at line 174 of file Reaction.java.

00174                                                                          {
00175         this.reactionGroups = reactionGroups;
00176         Set<ReactionGroup> toAdd = new HashSet<ReactionGroup>();
00177         Set<ReactionGroup> toRemove = new HashSet<ReactionGroup>();
00178         for (ReactionGroup r : this.reactionGroups) {
00179             if (! reactionGroups.contains(r)) toRemove.add(r);
00180         }
00181         for (ReactionGroup r : reactionGroups) {
00182             if (! this.reactionGroups.contains(r)) toAdd.add(r);
00183         }
00184         for (ReactionGroup r : toRemove) removeReactionGroup(r);
00185         for (ReactionGroup r : toAdd) addReactionGroup(r);
00186         return this;
00187     }

Reaction addReactionGroup ( ReactionGroup  reactionGroup  )  [inherited]

Add a ReactionGroup.

Definition at line 189 of file Reaction.java.

References ReactionGroup.getReactions().

00189                                                                   {
00190         if (reactionGroup != null) {
00191             reactionGroup.getReactions().add(this);
00192             this.reactionGroups.add(reactionGroup);
00193         } else {
00194             log().warn("Tried to add a null reaction group to a reaction");
00195         }
00196         return this;
00197     }

Reaction removeReactionGroup ( ReactionGroup  reactionGroup  )  [inherited]

Remove a ReactionGroup.

Definition at line 199 of file Reaction.java.

References ReactionGroup.getReactions().

00199                                                                      {
00200         if (reactionGroup != null) {
00201             reactionGroup.getReactions().remove(this);
00202             this.reactionGroups.remove(reactionGroup);
00203         } else {
00204             log().warn("Tried to remove a null reaction group from a reaction");
00205         }
00206         return this;
00207     }

boolean equals ( Object  other  )  [inherited]

Compare reactions for equality.

Todo:
Also check YAxis and ReactionGroup relations?

Definition at line 214 of file Reaction.java.

References Reaction.getFinalState(), and Reaction.getInitialState().

00214                                         {
00215         log().debug("Comparing reactions...");
00216         if (this == other) return true;
00217         if (! (other instanceof Reaction)) return false;
00218         final Reaction test = (Reaction) other;
00219 
00220         if (! this.getInitialState().equals( test.getInitialState() )) return false;
00221         if (test.getInitialState() != null && this.getInitialState() != null) {
00222             Set<Particle> is1 = this.getInitialState();
00223             Set<Particle> is2 = test.getInitialState();
00224             if (is1.size() != is2.size()) return false;
00225             for (Particle p : is1) {
00226                 if (! is2.contains(p)) return false;
00227             }
00228         }
00229 
00230         if (! this.getFinalState().equals( test.getFinalState() )) return false;
00231         if (test.getFinalState() != null && this.getFinalState() != null) {
00232             Set<Particle> fs1 = this.getFinalState();
00233             Set<Particle> fs2 = test.getFinalState();
00234             if (fs1.size() != fs2.size()) return false;
00235             for (Particle p : fs1) {
00236                 if (! fs2.contains(p)) return false;
00237             }
00238         }
00239 
00240 
00242 
00243 
00244         // If not proven guilty...
00245         return true;
00246     }

String initialStateToString (  )  [inherited]

String representation of the initial state.

Definition at line 255 of file Reaction.java.

00255                                          {
00256         StringBuffer s = new StringBuffer();
00257         for (Particle ispart : getInitialState()) {
00258             s.append(" " + ispart.toString());
00259         }
00260         return s.toString().trim();
00261     }

String finalStateToString (  )  [inherited]

String representation of the final state.

Definition at line 265 of file Reaction.java.

00265                                        {
00266         StringBuffer s = new StringBuffer();
00267         for (Particle fspart : getFinalState()) {
00268             s.append(" " + fspart.toString());
00269         }
00270         return s.toString().trim();
00271     }

String toString (  )  [inherited]

String representation of this Reaction.

Reimplemented from Storeable.

Definition at line 275 of file Reaction.java.

00275                              {
00276         StringBuffer s = new StringBuffer();
00277         s.append(initialStateToString());
00278         s.append(" -> ");
00279         s.append(finalStateToString());
00280         return s.toString().trim();
00281     }

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:38 2007 by  doxygen 1.5.3