source: ether_statistics/service/implementation/gov/noaa/pmel/sgt/dm/Collection.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 4.1 KB
Line 
1/*
2 * $Id: Collection.java,v 1.8 2001/10/10 19:05:01 dwd Exp $
3 *
4 * This software is provided by NOAA for full, free and open release.  It is
5 * understood by the recipient/user that NOAA assumes no liability for any
6 * errors contained in the code.  Although this software is released without
7 * conditions or restrictions in its use, it is expected that appropriate
8 * credit be given to its author and to the National Oceanic and Atmospheric
9 * Administration should the software be included by the recipient as an
10 * element in other product development.
11 */
12
13package gov.noaa.pmel.sgt.dm;
14
15import gov.noaa.pmel.sgt.SGLabel;
16import gov.noaa.pmel.util.SoTRange;
17
18import java.util.Vector;
19import java.util.Enumeration;
20import java.beans.PropertyChangeSupport;
21import java.beans.PropertyChangeListener;
22
23/**
24 * <code>Collection</code> is an extension to <code>Vector</code>
25 * designed to hold <code>SGTData</code> objects. These objects must
26 * have consistent x and y coordinate types.  Otherwise, the
27 * <code>isXTime()</code>, <code>isYTime()</code>,
28 * <code>getXMetaData()</code>, <code>getYMetaData()</code>, and
29 * <code>get?Ranges()</code> methods will fail.
30 *
31 * @author Donald Denbo
32 * @version $Revision: 1.8 $, $Date: 2001/10/10 19:05:01 $
33 * @since 1.0
34 * @see SGTData
35 * @see SGTPoint
36 * @see SGTLine
37 * @see SGTGrid
38 * @see SGTVector
39 */
40public class Collection extends Vector implements SGTData, Cloneable {
41  private String title_;
42  private SGLabel keyTitle_ = null;
43  private String id_ = null;
44  private PropertyChangeSupport changes_ = new PropertyChangeSupport(this);
45  private SoTRange xRange_ = null;
46  private SoTRange yRange_ = null;
47  private int colLen_ = 0;
48
49  public Collection() {
50    this("");
51  }
52  public Collection(String title) {
53    super();
54    title_ = title;
55  }
56  public Collection(String title, int initialCapacity) {
57    super(initialCapacity);
58    title_ = title;
59  }
60  public Collection(String title, int initialCapacity, int increment) {
61    super(initialCapacity, increment);
62    title_ = title;
63  }
64  /**
65   * Create a copy.
66   *
67   * @see SGTData
68   */
69  public SGTData copy() {
70    Collection newCollection;
71    newCollection = (Collection)clone();
72    return (SGTData)newCollection;
73  }
74  /**
75   * Get the title.
76   */
77  public String getTitle() {
78    return title_;
79  }
80  /**
81   * Set the title.
82   */
83  public void setTitle(String title) {
84    title_ = title;
85  }
86  public SGLabel getKeyTitle() {
87    return keyTitle_;
88  }
89  public void setKeyTitle(SGLabel title) {
90    keyTitle_ = title;
91  }
92  /**
93   * Get the unique identifier.  The presence of the identifier
94   * is optional, but if it is present it should be unique.  This
95   * field is used to search for the layer that contains the data.
96   *
97   * @return unique identifier
98   * @see gov.noaa.pmel.sgt.Pane
99   * @see gov.noaa.pmel.sgt.Layer
100   */
101  public String getId() {
102    return id_;
103  }
104  /**
105   * Set the unique identifier.
106   */
107  public void setId(String ident) {
108    id_ = ident;
109  }
110  public boolean isXTime() {
111    return ((SGTData)firstElement()).isXTime();
112  }
113  public boolean isYTime() {
114    return ((SGTData)firstElement()).isYTime();
115  }
116  public SGTMetaData getXMetaData() {
117    return ((SGTData)firstElement()).getXMetaData();
118  }
119  public SGTMetaData getYMetaData() {
120    return ((SGTData)firstElement()).getYMetaData();
121  }
122  public SoTRange getXRange() {
123    computeRange();
124    return xRange_.copy();
125  }
126  public SoTRange getYRange() {
127    computeRange();
128    return yRange_.copy();
129  }
130  private void computeRange() {
131    if(colLen_ == size()) return;
132    colLen_ = size();
133    xRange_ = ((SGTData)firstElement()).getXRange();
134    yRange_ = ((SGTData)firstElement()).getYRange();
135
136    Enumeration enumeration = elements();
137    while(enumeration.hasMoreElements()) {
138      SGTData data = (SGTData)enumeration.nextElement();
139      xRange_.add(data.getXRange());
140      yRange_.add(data.getYRange());
141    }
142  }
143  public void addPropertyChangeListener(PropertyChangeListener l) {
144    changes_.addPropertyChangeListener(l);
145  }
146  public void removePropertyChangeListener(PropertyChangeListener l) {
147    changes_.removePropertyChangeListener(l);
148  }
149}
Note: See TracBrowser for help on using the repository browser.