source: ether_megapoli/trunk/service/implementation/gov2/noaa/pmel/sgt/plot/PlotLayerHints.java @ 192

Last change on this file since 192 was 192, checked in by vmipsl, 13 years ago

Servlet _ Contour en cours _ package gov2

File size: 7.5 KB
Line 
1/*
2 * $Id: PlotLayerHints.java,v 1.3 2003/08/22 23:02:39 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 */
12package gov.noaa.pmel.sgt.plot;
13
14import java.util.Map;
15import java.util.Set;
16import java.util.Collection;
17import java.util.Collections;
18import java.util.HashMap;
19import java.util.Iterator;
20
21/**
22 * @since 2.x
23 */
24public class PlotLayerHints implements Map, Cloneable {
25  HashMap hintmap = new HashMap(5);
26
27  /**
28   * PlotKey Type hint key
29   */
30  public static final String KEY_PLOTKEY_TYPE = "PlotKeyType";
31  /**
32   * PlotKey Type hint values -- on layer
33   */
34  public static final String VALUE_PLOTKEY_ON_LAYER = "OnLayer";
35  /**
36   * PlotKey Type hint values -- on seperate layer
37   */
38  public static final String VALUE_PLOTKEY_ON_SEPERATE_LAYER = "OnSeperateLayer";
39  /**
40   * PlotKey Type hint values -- in pop-up window
41   */
42  public static final String VALUE_PLOTKEY_IN_POPUP = "InPopUp";
43  /**
44   * PlotKey Type hint values -- in JTable
45   */
46  public static final String VALUE_PLOTKEY_IN_TABLE = "InTable";
47  /**
48   * PlotKey Type hint values -- no key
49   */
50  public static final String VALUE_PLOTKEY_NONE = "None";
51
52  /**
53   * PlotKey location hint key
54   */
55  public static final String KEY_PLOTKEY_LOCATION = "PlotKeyLocation";
56
57  /**
58   * Layer Placement hint key
59   */
60  public static final String KEY_LAYER_PLACEMENT = "LayerPlacement";
61  /**
62   * Layer Placement hint values -- overlay
63   */
64  public static final String VALUE_LAYER_PLACEMENT_OVERLAY = "Overlay";
65
66  /**
67   * AspectRatio hint key
68   */
69  public static final String KEY_ASPECT_RATIO = "AspectRatio";
70  /**
71   * AspecRatio hint values -- lock X and Y scales
72   */
73  public static final String VALUE_ASPECT_RATIO_LOCK = "Lock";
74  /**
75   * AspecRatio hint values -- dont lock X and Y scales (during resize)
76   */
77  public static final String VALUE_ASPECT_RATIO_NO_LOCK = "NoLock";
78
79  /**
80   * Axis location should actually go through a series of steps
81   *
82   * X Axis Location
83   * 1) bottom of plot region
84   * 2) top of plot region
85   * 3) below bottom axis (increase border if needed)
86   * 4) above top axis (increase border if needed)
87   *
88   * Y Axis Locations
89   * 1) left of plot region
90   * 2) right of plot region
91   * 3) outside left axis (increase border if needed)
92   * 4) outside right axis (increase border if needed)
93   *
94   *
95   * X Axis Location hint key
96   */
97  public static final String KEY_X_AXIS_LOCATION = "XAxisLocation";
98  /**
99   * X Axis Location hint values -- default
100   * First try bottom, top, below bottom, then above top
101   */
102  public static final String VALUE_X_AXIS_LOCATION_DEFAULT = "Default";
103  /**
104   * X Axis Location hint values -- bottom
105   */
106  public static final String VALUE_X_AXIS_LOCATION_BOTTOM = "Bottom";
107  /**
108   * X Axis Location hint values -- top
109   */
110  public static final String VALUE_X_AXIS_LOCATION_TOP = "Top";
111
112  /**
113   * Y Axis Location hint key
114   */
115  public static final String KEY_Y_AXIS_LOCATION = "YAxis Location";
116  /**
117   * Y Axis Location hint values -- default
118   * First try left, right, outside right, then outside left
119   */
120  public static final String VALUE_Y_AXIS_LOCATION_DEFAULT = "Default";
121  /**
122   * Y Axis Location hint values -- left
123   */
124  public static final String VALUE_Y_AXIS_LOCATION_LEFT = "Left";
125  /**
126   * Y Axis Location hint values -- right
127   */
128  public static final String VALUE_Y_AXIS_LOCATION_RIGHT = "Right";
129
130  /**
131   * Decision to create a new transform or re-use an existing
132   * transform should follow the following steps
133   *
134   * 1) Use transform from same LayerStack
135   * 2) Use transform from same JPlotPane
136   * 3) Create a new transform
137   *
138   * to use existing transform
139   * 1) both must be space or both time (test cant be defeated)
140   * 2) must have units that are convertable to existing transform
141   * 3) must have identical units
142   *
143   *
144   * X Transform hint key
145   */
146  public static final String KEY_X_TRANSFORM = "XTransform";
147  /**
148   * X Transform hint values -- default
149   * First try LayerStack, JPlotPane, then create new transform
150   */
151  public static final String VALUE_X_TRANSFORM_DEFAULT = "Default";
152  /**
153   * X Transform hint values -- new
154   */
155  public static final String VALUE_X_TRANSFORM_NEW = "New";
156  /**
157   * X Transform hint values -- use JPlotPane
158   */
159  public static final String VALUE_X_TRANSFORM_USEPLOTPANE = "UsePlotPane";
160
161  /**
162   * Y Transform hint key
163   */
164  public static final String KEY_Y_TRANSFORM = "YTransform";
165  /**
166   * Y Transform hint values -- default
167   * First try LayerStack, JPlotPane, then create new transform
168   */
169  public static final String VALUE_Y_TRANSFORM_DEFAULT = "Default";
170  /**
171   * Y Transform hint values -- new
172   */
173  public static final String VALUE_Y_TRANSFORM_NEW = "New";
174  /**
175   * Y Transform hint values -- use JPlotPane
176   */
177  public static final String VALUE_Y_TRANSFORM_USEPLOTPANE = "UsePlotPane";
178
179  public PlotLayerHints(Map init) {
180    if(init != null) {
181      hintmap.putAll(init);
182    }
183  }
184
185  public PlotLayerHints(String key, String value) {
186    hintmap.put(key, value);
187  }
188
189  public int size() {
190    return hintmap.size();
191  }
192
193  public boolean isEmpty() {
194    return hintmap.isEmpty();
195  }
196
197  public boolean containsKey(Object key) {
198    return hintmap.containsKey((String)key);
199  }
200
201  public boolean containsValue(Object value) {
202    return hintmap.containsValue((String)value);
203  }
204
205  public Object get(Object key) {
206    return hintmap.get((String)key);
207  }
208
209  public Object put(Object key, Object value) {
210    return hintmap.put((String) key, (String)value);
211  }
212
213  public void add(PlotLayerHints hints) {
214    hintmap.putAll(hints.hintmap);
215  }
216
217  public void clear() {
218    hintmap.clear();
219  }
220
221  public Object remove(Object key) {
222    return hintmap.remove((String)key);
223  }
224
225  public void putAll(Map m) {
226    if(m instanceof PlotLayerHints) {
227      hintmap.putAll(((PlotLayerHints)m).hintmap);
228    } else {
229      // Funnel each key/value pair though our method
230      Iterator iter = m.entrySet().iterator();
231      while(iter.hasNext()) {
232        Map.Entry entry = (Map.Entry) iter.next();
233        put(entry.getKey(), entry.getValue());
234      }
235    }
236  }
237
238  public Set keySet() {
239    return hintmap.keySet();
240  }
241
242  public Collection values() {
243    return hintmap.values();
244  }
245
246  public Set entrySet() {
247    return Collections.unmodifiableMap(hintmap).entrySet();
248  }
249
250  public boolean equals(Object o) {
251    if(o instanceof PlotLayerHints) {
252      return hintmap.equals(((PlotLayerHints)o).hintmap);
253    } else if(o instanceof Map) {
254      return hintmap.equals(o);
255    }
256    return false;
257  }
258
259  public int hashCode() {
260    return hintmap.hashCode();
261  }
262
263  public Object clone() {
264    PlotLayerHints plh;
265    try {
266      plh = (PlotLayerHints) super.clone();
267      if(hintmap != null) {
268        plh.hintmap = (HashMap) hintmap.clone();
269      }
270    } catch (CloneNotSupportedException e) {
271      // this shouldnt happend since we are Cloneable
272      throw new InternalError();
273    }
274    return plh;
275  }
276
277  public String toString() {
278    if(hintmap == null) {
279      return getClass().getName() +
280          "@" +
281          Integer.toHexString(hashCode()) +
282          " (0 hints)";
283    }
284    return hintmap.toString();
285  }
286
287}
Note: See TracBrowser for help on using the repository browser.