source: ether_megapoli/trunk/service/implementation/gov2/noaa/pmel/sgt/beans/AxisHolder.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: 26.1 KB
Line 
1/*
2 * $Id: AxisHolder.java,v 1.3 2003/09/18 21:01:14 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.beans;
14
15import gov.noaa.pmel.sgt.*;
16import gov.noaa.pmel.util.*;
17import java.awt.*;
18import java.beans.*;
19import java.io.*;
20import java.util.*;
21import javax.swing.event.*;
22
23/**
24 * Contains the data necessary to instantiate an axis.
25 * This class is used with <code>DataGroup</code>.
26 *
27 * @author Donald Denbo
28 * @version $Revision: 1.3 $, $Date: 2003/09/18 21:01:14 $
29 * @since 3.0
30 **/
31public class AxisHolder implements Serializable {
32  private Vector changeListeners;
33
34  /**
35   * @label dataGroup
36   */
37  private DataGroup dataGroup_;
38  transient private ChangeEvent changeEvent_ = new ChangeEvent(this);
39  // general axis properties
40  /**
41   * axisType = DataGroup.PLAIN, DataGroup.TIME, or DataGroup.LOG
42   */
43  private int axisType = -1; // must be defined
44  /**
45   * axisOrientation = DataGroup.X_DIR or DataGroup.Y_DIR
46   */
47  private int axisOrientation = -1; // must be defined
48  /**
49   * transformType = DataGroup.LINEAR, DataGroup.LOG, DataGroup.REFERENCE
50   */
51  private int transformType = DataGroup.LINEAR;
52  private String transformGroup = "";
53  /**
54   * <pre>
55   * axisPosition = DataGroup.TOP, DataGroup.BOTTOM, (for x axes)
56   *                DataGroup.LEFT, DataGroup.RIGHT, (for y axes)
57   *                DataGroup.MANUAL
58   * </pre>
59   */
60  private int axisPosition = -1;
61  /**
62   * used if axisPosition = MANUAL, always computed
63   */
64  private Point2D.Double axisOriginP = new Point2D.Double(0.0, 0.0);
65  private boolean locationAtOrigin = false;
66  private Color axisColor = Color.black;
67  private boolean autoRange = true;
68  /**
69   * used if axisPosition = MANUAL, always computed
70   */
71  private Rectangle2D boundsP = new Rectangle2D.Double(0.0, 0.0, 0.0, 0.0);
72//  private double originP = 0.0;  //  y origin for X_DIR, x origin for Y_DIR if axisPosition = MANUAL
73  private SoTRange userRange = new SoTRange.Double(1.0, 10.0, 1.0);
74  private Color labelColor = Color.black;
75  private Font labelFont = new Font("Helvetica", Font.ITALIC, 10);
76  private double labelHeightP = 0.15;
77  /**
78   * <pre>
79   * labelPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
80   *                 Axis.NEGATIVE_SIDE, Axis.NO_LABEL
81   * </pre>
82   */
83  private int labelPosition = Axis.AUTO; // Expert
84  private double largeTicHeightP = 0.1; // Expert
85  private double smallTicHeightP = 0.05; // Expert
86  private int numSmallTics = 0;
87  private double thickTicWidth = 0.025; // Expert
88  /**
89   * <pre>
90   * ticPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
91   *               Axis.NEGATIVE_SIDE, Axis.BOTH_SIDES
92   * </pre>
93   */
94  private int ticPosition = Axis.AUTO; // Expert
95  private SGLabel title = new SGLabel("title", "", 0.20,
96                                      new Point2D.Double(0.0, 0.0),
97                                      SGLabel.BOTTOM, SGLabel.LEFT);
98  private boolean titleAuto = true;
99  private boolean selectable = true;
100  private boolean visible = true;
101  // SpaceAxis properties
102  private String labelFormat = ""; // Expert
103  private int labelInterval = 2;
104  private int labelSignificantDigits = 2;
105  // TimeAxis properties defaults appropriate for MONTH_YEAR
106  private String minorFormat = "MMM"; // Expert
107  private String majorFormat = "yyyy"; // Expert
108  private int minorInterval = 2; // Expert
109  private int majorInterval = 1; // Expert
110  /**
111   * <pre>
112   * timeAxisStyle = TimeAxis.AUTO, TimeAxis.DAY_MONTH, TimeAxis.HOUR_DAY,
113   *                 TimeAxis.MINUTE_HOUR, TimeAxis.MONTH_YEAR,
114   *                 TimeAxis.YEAR_DECADE
115   * </pre>
116   */
117  private int timeAxisStyle = TimeAxis.AUTO;
118
119  private boolean suppressEvent_ = false;
120
121  /**
122   * Static code to make sure that dataGroup doesn't get serialized by
123   * XMLEncode
124   */
125  static {
126    try {
127      BeanInfo info = Introspector.getBeanInfo(AxisHolder.class);
128      PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
129      for(int i=0; i < descriptors.length; i++) {
130        PropertyDescriptor pd = descriptors[i];
131        if(pd.getName().equals("dataGroup")) {
132          pd.setValue("transient", Boolean.TRUE);
133        }
134      }
135    } catch (IntrospectionException ie) {
136      ie.printStackTrace();
137    }
138  }
139
140  /**
141   * Default constructor.  The methods setAxisType, setAxisOrientation, and
142   * setDataGroup must be called.
143   */
144  public AxisHolder() {
145    title.setColor(Color.black);
146  }
147
148  /**
149   * Construct a new <code>AxisHolder</code>. This constructor includes the
150   * necessary fields.
151   *
152   * @param type Type of axis
153   * @param dir Direction of axis
154   * @param dataGroup DataGroup parent
155   * @see #setAxisType setAxisType
156   * @see #setAxisOrientation setAxisOrientation
157   * @see #setDataGroup setDataGroup
158   */
159  public AxisHolder(int type, int dir, DataGroup dataGroup) {
160    axisType = type;
161    axisOrientation = dir;
162    dataGroup_ = dataGroup;
163    if(axisOrientation == DataGroup.X_DIR) {
164      title.setText("X Axis");
165      axisPosition = DataGroup.BOTTOM;
166    } else {
167      title.setText("Y Axis");
168      axisPosition = DataGroup.LEFT;
169    }
170    transformGroup = dataGroup.getId();
171    title.setColor(Color.black);
172  }
173
174  /**
175   * Get the <code>DataGroup</code> parent.
176   * @return DataGroup parent
177   */
178  public DataGroup getDataGroup() {
179    return dataGroup_;
180  }
181
182  /**
183   * Set the parent <code>DataGroup</code>. No default.
184   *
185   * @param dataGroup Parent object to AxisHolder
186   */
187  public void setDataGroup(DataGroup dataGroup) {
188    dataGroup_ = dataGroup;
189    transformGroup = dataGroup_.getId();
190  }
191
192  /**
193   * Test if the axis time.
194   * @return True if axis is time.
195   */
196  public boolean isTime() {
197    return axisType == DataGroup.TIME;
198  }
199
200  /**
201   * Remove a <code>ChangeListener</code>.
202   * @param l ChangeListener to remove
203   */
204  public synchronized void removeChangeListener(ChangeListener l) {
205    if (changeListeners != null && changeListeners.contains(l)) {
206      Vector v = (Vector) changeListeners.clone();
207      v.removeElement(l);
208      changeListeners = v;
209    }
210  }
211
212  /**
213   * Add a <code>ChangeListener</code>.  Listener will be notified if a change
214   * occurs.
215   * @param l ChangeListener to add.
216   */
217  public synchronized void addChangeListener(ChangeListener l) {
218    Vector v = changeListeners == null ? new Vector(2) : (Vector) changeListeners.clone();
219    if (!v.contains(l)) {
220      v.addElement(l);
221      changeListeners = v;
222    }
223  }
224
225  /**
226   * Remove all <code>ChangeListener</code>s that implement the
227   * <code>DesignListener</code> interface.
228   *
229   * @see DesignListener
230   */
231  public synchronized void removeDesignChangeListeners() {
232    if(changeListeners != null) {
233      Vector v = (Vector) changeListeners.clone();
234      Iterator iter = v.iterator();
235      while(iter.hasNext()) {
236        Object obj = iter.next();
237        if(obj instanceof DesignListener) changeListeners.removeElement(obj);
238      }
239    }
240  }
241
242  /**
243   * Remove all <code>ChangeListener</code>s.
244   */
245  public void removeAllChangeListeners() {
246    changeListeners.removeAllElements();
247  }
248
249  void fireStateChanged() {
250    if(suppressEvent_) return;
251    if (changeListeners != null) {
252      Vector listeners = changeListeners;
253      int count = listeners.size();
254      for (int i = 0; i < count; i++) {
255        ((ChangeListener) listeners.elementAt(i)).stateChanged(changeEvent_);
256      }
257    }
258  }
259  // general axis properties
260
261  /**
262   * Set the axis type.  The possible types include:
263   * <pre>
264   * axisType = DataGroup.PLAIN, DataGroup.TIME, or DataGroup.LOG
265   * </pre>
266   * No default.
267   * @param axisType (see above)
268   */
269  public void setAxisType(int axisType) {
270    int saved = this.axisType;
271    this.axisType = axisType;
272    if(saved != this.axisType) fireStateChanged();
273  }
274
275  /**
276   * Get the axis type.
277   * @return axis type
278   */
279  public int getAxisType() {
280    return axisType;
281  }
282
283  /**
284   * Get the axis orientation.
285   * @return axis orientation.
286   */
287  public int getAxisOrientation() {
288    return axisOrientation;
289  }
290
291  /**
292   * Set the axis orientation.  Orientations are:
293   * <pre>
294   * axisOrientation = DataGroup.X_DIR or DataGroup.Y_DIR
295   * </pre>
296   * No default.
297   * @param dir axis orientation
298   */
299  public void setAxisOrientation(int dir) {
300    axisOrientation = dir;
301    if(axisOrientation == DataGroup.X_DIR) {
302      title.setText("X Axis");
303      axisPosition = DataGroup.BOTTOM;
304    } else {
305      title.setText("Y Axis");
306      axisPosition = DataGroup.LEFT;
307    }
308  }
309
310  /**
311   * Set axis color. Default = black.
312   * @param axisColor axis color
313   */
314  public void setAxisColor(Color axisColor) {
315    Color saved = new Color(this.axisColor.getRed(),
316                            this.axisColor.getGreen(),
317                            this.axisColor.getBlue(),
318                            this.axisColor.getAlpha());
319    this.axisColor = axisColor;
320    if(!saved.equals(this.axisColor)) fireStateChanged();
321  }
322
323  /**
324   * Get the axis color.
325   * @return axis color
326   */
327  public Color getAxisColor() {
328    return axisColor;
329  }
330
331  /**
332   * Set autoRange property. True to automatically compute the axis range from
333   * the data. Default = true.
334   * @param autoRange auto range
335   */
336  public void setAutoRange(boolean autoRange) {
337    boolean saved = this.autoRange;
338    this.autoRange = autoRange;
339    if(saved != autoRange) fireStateChanged();
340  }
341
342  /**
343   * Test if the axis in autoRange mode.
344   * @return True, if in autoRange mode.
345   */
346  public boolean isAutoRange() {
347    return autoRange;
348  }
349
350  /**
351   * Set the user range. User range is only used if autoRange is false.
352   * Default = (1, 10, 1)
353   * @param userRange user supplied range
354   */
355  public void setUserRange(SoTRange userRange) {
356    SoTRange saved = userRange.copy();
357    this.userRange = userRange;
358    if(!saved.equals(this.userRange)) fireStateChanged();
359  }
360
361 /**
362  * Get the user range.
363  * @return user range
364  */
365  public SoTRange getUserRange() {
366    return userRange;
367  }
368
369  /**
370   * Set axis label color. Default = black.
371   * @param labelColor label color
372   */
373  public void setLabelColor(Color labelColor) {
374    Color saved = new Color(this.labelColor.getRed(),
375                            this.labelColor.getGreen(),
376                            this.labelColor.getBlue(),
377                            this.labelColor.getAlpha());
378    this.labelColor = labelColor;
379    if(!saved.equals(this.labelColor)) fireStateChanged();
380  }
381
382  /**
383   * Get the axis label color.
384   * @return axis label color
385   */
386  public Color getLabelColor() {
387    return labelColor;
388  }
389
390  /**
391   * Set the axis label font. Default = ("Helvetica", ITALIC, 10).
392   * @param labelFont  label font
393   */
394  public void setLabelFont(Font labelFont) {
395    Font saved = new Font(this.labelFont.getName(),
396                          this.labelFont.getStyle(),
397                          this.labelFont.getSize());
398    this.labelFont = labelFont;
399    if(!saved.equals(this.labelFont)) fireStateChanged();
400  }
401
402  /**
403   * Get the axis label font.
404   * @return axis label font
405   */
406  public Font getLabelFont() {
407    return labelFont;
408  }
409
410  /**
411   * Set label height in physical coordinates (inches). Default = 0.15.
412   * @param labelHeightP  label height
413   */
414  public void setLabelHeightP(double labelHeightP) {
415    double saved = this.labelHeightP;
416    this.labelHeightP = labelHeightP;
417    if(saved != this.labelHeightP) fireStateChanged();
418  }
419
420  /**
421   * Get label height.
422   * @return label height in physical coordinates
423   */
424  public double getLabelHeightP() {
425    return labelHeightP;
426  }
427
428  /**
429   * Set the label position.  Label position can be:
430   * <pre>
431   * labelPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
432   *                 Axis.NEGATIVE_SIDE, Axis.NO_LABEL
433   * </pre>
434   * Default = AUTO.
435   * @param labelPosition label position
436   */
437  public void setLabelPosition(int labelPosition) {
438    int saved = this.labelPosition;
439    this.labelPosition = labelPosition;
440    if(saved != this.labelPosition) fireStateChanged();
441  }
442
443/**
444 * Test if label position in auto mode.
445 * @return true if in auto mode
446 */
447  public boolean isLabelPositionAuto() {
448    return labelPosition == Axis.AUTO;
449  }
450
451  /**
452   * If labelPosition is AUTO then return computed labelPosition,
453   * otherwise return stored value
454   * @return label position
455   */
456  public int getLabelPosition() {
457    int labPos = Axis.NEGATIVE_SIDE;
458    if(isLabelPositionAuto()) {
459      switch(axisPosition) {
460        case DataGroup.MANUAL:
461        case DataGroup.BOTTOM:
462        case DataGroup.LEFT:
463          labPos = Axis.NEGATIVE_SIDE;
464          break;
465        case DataGroup.TOP:
466        case DataGroup.RIGHT:
467          labPos = Axis.POSITIVE_SIDE;
468          break;
469      }
470    } else {
471      labPos = labelPosition;
472    }
473    return labPos;
474  }
475
476  /**
477   * Set bounds of axis in physical coordinates.  Default = (0, 0, 0, 0).
478   * @param boundsP axis bounds
479   */
480  public void setBoundsP(Rectangle2D boundsP) {
481    Rectangle2D saved = getBoundsP();
482//    if(this.boundsP != null) saved = this.boundsP.copy();
483    this.boundsP = boundsP;
484    boolean changed = true;
485    if(saved != null) changed = !saved.equals(this.boundsP);
486    if(changed) fireStateChanged();
487  }
488
489  /**
490   * Get axis bounds.
491   * @return axis bounds in physical coordinates.
492   */
493  public Rectangle2D getBoundsP() {
494    return boundsP;
495    /** @todo bounds isn't  cloned should be see note */
496//    return boundsP == null? null: boundsP.copy();
497  }
498
499  /**
500   * Get range of axis (long direction) in physical coordinates.
501   * The bounds are used to determine the axis range.
502   * @return axis range (long direction)
503   */
504  public Range2D getRangeP() {
505    Rectangle2D.Double dbl = (Rectangle2D.Double)boundsP;
506    if(axisOrientation == DataGroup.X_DIR) {
507      return new Range2D(dbl.x, dbl.x + dbl.width);
508    } else {
509      return new Range2D(dbl.y, dbl.y + dbl.height);
510    }
511  }
512
513  /**
514   * Set large tic height in physical coordinates. Default = 0.1.
515   * @param largeTicHeightP large tic height
516   */
517  public void setLargeTicHeightP(double largeTicHeightP) {
518    double saved = this.largeTicHeightP;
519    this.largeTicHeightP = largeTicHeightP;
520    if(saved != this.largeTicHeightP) fireStateChanged();
521  }
522
523  /**
524   * Get large tic height.
525   * @return large tic height in physical coordinates.
526   */
527  public double getLargeTicHeightP() {
528    return largeTicHeightP;
529  }
530
531  /**
532   * Set small tic height in physical coordinates. Default = 0.05.
533   * @param smallTicHeightP small tic height
534   */
535  public void setSmallTicHeightP(double smallTicHeightP) {
536    double saved = this.smallTicHeightP;
537    this.smallTicHeightP = smallTicHeightP;
538    if(saved != this.smallTicHeightP) fireStateChanged();
539  }
540
541  /**
542   * Get small tic height.
543   * @return small tic height in physical coordinates
544   */
545  public double getSmallTicHeightP() {
546    return smallTicHeightP;
547  }
548
549  /**
550   * Set the number of small tics between the large tics.  This should be one less
551   * than the number of intervals you want. Default = 0.
552   * @param numSmallTics number of small tics
553   */
554  public void setNumSmallTics(int numSmallTics) {
555    int saved = this.numSmallTics;
556    this.numSmallTics = numSmallTics;
557    if(saved != this.numSmallTics) fireStateChanged();
558  }
559
560  /**
561   * Get the number of small tics.
562   * @return number of small tics between large tics
563   */
564  public int getNumSmallTics() {
565    return numSmallTics;
566  }
567
568  /**
569   * Set the thick  tic width (for Time axes). Default = 0.025.
570   * @param thickTicWidth thick tic width
571   */
572  public void setThickTicWidth(double thickTicWidth) {
573    double saved = this.thickTicWidth;
574    this.thickTicWidth = thickTicWidth;
575    if(saved != this.thickTicWidth) fireStateChanged();
576  }
577
578  /**
579   * Get the thick tic width.  Valid for Time axes
580   * @return thick tic width
581   */
582  public double getThickTicWidth() {
583    return thickTicWidth;
584  }
585
586  /**
587   * Set the tic position.  Tic position include:
588   * <pre>
589   * ticPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
590   *               Axis.NEGATIVE_SIDE, Axis.BOTH_SIDES
591   * </pre>
592   * Default = AUTO.
593   * @param ticPosition tic position
594   */
595  public void setTicPosition(int ticPosition) {
596    int saved = this.ticPosition;
597    this.ticPosition = ticPosition;
598    if(saved != this.ticPosition) fireStateChanged();
599  }
600
601/**
602 * Test if tic position in auto mode.
603 * @return true if in auto mode
604 */
605  public boolean isTicPositionAuto() {
606    return ticPosition == Axis.AUTO;
607  }
608
609  /**
610   * If ticPosition is AUTO then returns computed position, otherwise
611   * returns stored value.
612   * @return tic position
613   */
614  public int getTicPosition() {
615    int ticPos = Axis.NEGATIVE_SIDE;
616    if(isTicPositionAuto()) {
617      switch(axisPosition) {
618        case DataGroup.MANUAL:
619        case DataGroup.BOTTOM:
620        case DataGroup.LEFT:
621          ticPos = Axis.NEGATIVE_SIDE;
622          break;
623        case DataGroup.TOP:
624        case DataGroup.RIGHT:
625          ticPos = Axis.POSITIVE_SIDE;
626          break;
627      }
628    } else {
629      ticPos = ticPosition;
630    }
631    return ticPos;
632  }
633
634  /**
635   * Set the axis title.  Axis title is a <code>SGLabel</code> enabling the Color,
636   * Font, size to be set.
637   * @param title axis title
638   */
639  public void setTitle(SGLabel title) {
640    SGLabel saved = (SGLabel)this.title.copy();
641    this.title = title;
642    if(!saved.equals(this.title)) fireStateChanged();
643  }
644
645  /**
646   * Get the axis title.
647   * @return axis title
648   */
649  public SGLabel getTitle() {
650    return title;
651  }
652
653  /**
654   * Set the selecatability of the axis. If true, axis can be selected with
655   * the mouse. Default = true.
656   * @param selectable selectable
657   */
658  public void setSelectable(boolean selectable) {
659    boolean saved = this.selectable;
660    this.selectable = selectable;
661    if(saved != this.selectable) fireStateChanged();
662  }
663
664  /**
665   * Test if the axis selectable.
666   * @return true, if the axis can be selected
667   */
668  public boolean isSelectable() {
669    return selectable;
670  }
671
672  /**
673   * Set/unset the axis visibility.  If true, the axis will be displayed.
674   * Default = true.
675   * @param visible visible
676   */
677  public void setVisible(boolean visible) {
678    boolean saved = this.visible;
679    this.visible = visible;
680    if(saved != this.visible) fireStateChanged();
681  }
682
683  /**
684   * Test if the axis visible.
685   * @return true, if axis is set visible
686   */
687  public boolean isVisible() {
688    return visible;
689  }
690  // spaceaxis properties
691
692  /**
693   * Set the axis label format.  Not used with time axes. Default = ""
694   * @param labelFormat axis label format
695   */
696  public void setLabelFormat(String labelFormat) {
697    String saved = this.labelFormat;
698    this.labelFormat = labelFormat;
699    if(!saved.equals(this.labelFormat)) fireStateChanged();
700  }
701
702  /**
703   * Get the label format.
704   * @return label format.
705   */
706  public String getLabelFormat() {
707    return labelFormat;
708  }
709
710  /**
711   * Set the label interval.  Not used with time axes. Default = 2.
712   * @param labelInterval axis label interval
713   */
714  public void setLabelInterval(int labelInterval) {
715    int saved = this.labelInterval;
716    this.labelInterval = labelInterval;
717    if(saved != this.labelInterval) fireStateChanged();
718  }
719
720  /**
721   * Get the label interval.
722   * @return label interval
723   */
724  public int getLabelInterval() {
725    return labelInterval;
726  }
727
728  /**
729   * Set the axis label significant digits. Not used with time axes.
730   * Default = 2.
731   * @param labelSignificantDigits axis label significant digits
732   */
733  public void setLabelSignificantDigits(int labelSignificantDigits) {
734    int saved = this.labelSignificantDigits;
735    this.labelSignificantDigits = labelSignificantDigits;
736    if(saved != this.labelSignificantDigits) fireStateChanged();
737  }
738
739  /**
740   * Get axis label significant digits
741   * @return significant digits
742   */
743  public int getLabelSignificantDigits() {
744    return labelSignificantDigits;
745  }
746  // timeaxis properties
747
748  /**
749   * Set the time axis minor label format. Default = "MMM", appropriate for MONTH_YEAR.
750   * @param minorFormat time axis minor format
751   */
752  public void setMinorFormat(String minorFormat) {
753    String saved = this.minorFormat;
754    this.minorFormat = minorFormat;
755    if(!saved.equals(this.minorFormat)) fireStateChanged();
756  }
757
758  /**
759   * Get time axis minor label format.
760   * @return minor label format
761   */
762  public String getMinorFormat() {
763    return minorFormat;
764  }
765
766  /**
767   * Get the time axis major label format. Default = "yyyy", appropriate for MONTH_YEAR.
768   * @param majorFormat time axis major format
769   */
770  public void setMajorFormat(String majorFormat) {
771    String saved = this.majorFormat;
772    this.majorFormat = majorFormat;
773    if(!saved.equals(this.majorFormat)) fireStateChanged();
774  }
775
776  /**
777   * Get time axis major label format
778   * @return major label format
779   */
780  public String getMajorFormat() {
781    return majorFormat;
782  }
783
784  /**
785   * Set time axis minor label interval. Default = 2.
786   * @param minorInterval time axis minor interval
787   */
788  public void setMinorInterval(int minorInterval) {
789    int saved = this.minorInterval;
790    this.minorInterval = minorInterval;
791    if(saved != this.minorInterval) fireStateChanged();
792  }
793
794  /**
795   * Get time axis minor label interval
796   * @return minor label interval
797   */
798  public int getMinorInterval() {
799    return minorInterval;
800  }
801
802  /**
803   * Set time axis major label interval. Default = 1.
804   * @param majorInterval time axis major interval
805   */
806  public void setMajorInterval(int majorInterval) {
807    int saved = this.majorInterval;
808    this.majorInterval = majorInterval;
809    if(saved != this.majorInterval) fireStateChanged();
810  }
811
812  /**
813   * Get time axis major label interval
814   * @return major label interval
815   */
816  public int getMajorInterval() {
817    return majorInterval;
818  }
819
820  /**
821   * Set the time axis style.  Styles include:
822   * <pre>
823   * timeAxisStyle = TimeAxis.AUTO, TimeAxis.DAY_MONTH, TimeAxis.HOUR_DAY,
824   *                 TimeAxis.MINUTE_HOUR, TimeAxis.MONTH_YEAR,
825   *                 TimeAxis.YEAR_DECADE
826   * </pre>
827   * Default = AUTO.
828   * @param timeAxisStyle time axis style
829   */
830  public void setTimeAxisStyle(int timeAxisStyle) {
831    int saved = this.timeAxisStyle;
832    this.timeAxisStyle = timeAxisStyle;
833    if(saved != this.timeAxisStyle) fireStateChanged();
834  }
835
836  /**
837   * Get the time axis style.
838   * @return time axis style
839   */
840  public int getTimeAxisStyle() {
841    return timeAxisStyle;
842  }
843
844  /**
845   * Set the axis transform type.  Transform types include:
846   * <pre>
847   * transformType = DataGroup.LINEAR, DataGroup.LOG, DataGroup.REFERENCE
848   * </pre>
849   * Default = LINEAR.
850   * @param transformType axis transform type
851   */
852  public void setTransformType(int transformType) {
853    int saved = this.transformType;
854    this.transformType = transformType;
855    if(saved != this.transformType) fireStateChanged();
856  }
857
858  /**
859   * Get the axis transform type.
860   * @return transform type
861   */
862  public int getTransformType() {
863    return transformType;
864  }
865
866  /**
867   * Set the transform group.  The transform group is used when the
868   * transformType = DataGroup.REFERENCE.  The transformGroup is the
869   * <code>DataGroup</code> id containing the transform to be referenced.
870   * No default.
871   * @param transformGroup axis transform group name
872   */
873  public void setTransformGroup(String transformGroup) {
874    String saved = this.transformGroup;
875    this.transformGroup = transformGroup;
876    if(saved == null || !saved.equals(this.transformGroup)) fireStateChanged();
877  }
878
879  /**
880   * Get transform group name.
881   * @return transform group
882   */
883  public String getTransformGroup() {
884    return transformGroup;
885  }
886
887  /**
888   * Set the axis position.  Axis positions include:
889   * <pre>
890   * axisPosition = DataGroup.TOP, DataGroup.BOTTOM, (for x axes)
891   *                DataGroup.LEFT, DataGroup.RIGHT, (for y axes)
892   *                DataGroup.MANUAL
893   * </pre>
894   * No default.
895   * @param axisPosition axis position
896   */
897  public void setAxisPosition(int axisPosition) {
898    int saved = this.axisPosition;
899    this.axisPosition = axisPosition;
900    if(saved != this.axisPosition) fireStateChanged();
901  }
902
903  /**
904   * Get the axis position
905   * @return axis position
906   */
907  public int getAxisPosition() {
908    return axisPosition;
909  }
910
911  /**
912   * Set the axis origin in physical coordinates.  This is used when axisPosition = MANUAL.
913   * Default = (0, 0).
914   * @param axisOriginP axis origin
915   */
916  public void setAxisOriginP(Point2D.Double axisOriginP) {
917    Point2D saved = getAxisOriginP();
918//    if(this.axisOriginP != null) saved = this.axisOriginP.copy();
919    this.axisOriginP = axisOriginP;
920    boolean changed = true;
921    if(saved != null) changed = !saved.equals(this.axisOriginP);
922//    if(Page.DEBUG) System.out.println("AxisHolder.setAxisOriginP: " + changed +
923//                                      ", " + saved + ", " + this.axisOriginP);
924    if(changed) fireStateChanged();
925  }
926
927  /**
928   * Get axis origin.
929   * @return axis origin
930   */
931  public Point2D.Double getAxisOriginP() {
932    return axisOriginP == null? null: (Point2D.Double)axisOriginP.copy();
933  }
934
935  /**
936   * Set axis at origin  of perpendicular axis.  Not implemented.
937   * Default = false.
938   * @param locationAtOrigin set location at origin
939   */
940  public void setLocationAtOrigin(boolean locationAtOrigin) {
941    boolean saved = this.locationAtOrigin;
942    this.locationAtOrigin = locationAtOrigin;
943    if(saved != this.locationAtOrigin) fireStateChanged();
944  }
945
946  /**
947   * Test if the axis at the origin.  Not presently implemented.
948   * @return true, if axis will be at origin
949   */
950  public boolean isLocationAtOrigin() {
951    return locationAtOrigin;
952  }
953
954  /**
955   * Set the title auto property.  Set true to determine the title from the
956   * data. Default = true.
957   * @param titleAuto auto title property
958   */
959  public void setTitleAuto(boolean titleAuto) {
960    boolean saved = this.titleAuto;
961    this.titleAuto = titleAuto;
962    if(saved != this.titleAuto) fireStateChanged();
963  }
964
965  /**
966   * Test if the title in auto mode.
967   * @return true, if title is automatically generated
968   */
969  public boolean isTitleAuto() {
970    return titleAuto;
971  }
972}
Note: See TracBrowser for help on using the repository browser.