~ubuntu-branches/ubuntu/quantal/libpal-java/quantal

« back to all changes in this revision

Viewing changes to src/pal/misc/TOCDSampleInformation.java

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2012-01-27 13:57:54 UTC
  • Revision ID: package-import@ubuntu.com-20120127135754-d63l3581f65fw9pk
Tags: upstream-1.5.1
ImportĀ upstreamĀ versionĀ 1.5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// TOCDSampleInformation.java
 
2
//
 
3
// (c) 1999-2004 PAL Development Core Team
 
4
//
 
5
// This package may be distributed under the
 
6
// terms of the Lesser GNU General Public License (LGPL)
 
7
 
 
8
package pal.misc;
 
9
 
 
10
/**
 
11
 * <p>Title: TOCDSampleInformation </p>
 
12
 * <p>Description: A wrapper over the old style TimeOrderCharacterData object for the new SampleInformation object </p>
 
13
 * @author Matthew Goode
 
14
 * @version 1.0
 
15
 */
 
16
 
 
17
public class TOCDSampleInformation implements SampleInformation {
 
18
  private final TimeOrderCharacterData base_;
 
19
        private final boolean hasTimes_;
 
20
        public TOCDSampleInformation(TimeOrderCharacterData base) {
 
21
                this.base_ = base;
 
22
                this.hasTimes_ = base.hasTimes();
 
23
  }
 
24
        public int getNumberOfSamples() {
 
25
          return base_.getOrdinalCount();
 
26
        }
 
27
        public int getSampleOrdinal(String leafID) {
 
28
          return base_.getTimeOrdinal(leafID);
 
29
        }
 
30
 
 
31
        public double getHeight(int sample) {
 
32
          if(hasTimes_) {
 
33
                        return base_.getOrdinalTime( sample );
 
34
                }
 
35
                return sample;
 
36
        }
 
37
        public int getHeightUnits() {
 
38
          if(hasTimes_) {
 
39
                  return base_.getUnits();
 
40
                }
 
41
                return Units.SAMPLE;
 
42
        }
 
43
 
 
44
        public double getMaxHeight() {
 
45
                if(hasTimes_) {
 
46
                        return base_.getMaximumTime();
 
47
                } else {
 
48
                  return base_.getOrdinalCount()-1;
 
49
                }
 
50
        }
 
51
 
 
52
}
 
 
b'\\ No newline at end of file'