001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)MeterProperties.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package org.openesb.tools.extchart.property.meter;
030:
031: import org.openesb.tools.extpropertysheet.impl.ExtPropertyGroup;
032: import java.awt.Color;
033: import java.awt.Font;
034:
035: /**
036: *
037: * @author Wei Han
038: * @version :$Revision: 1.1 $
039: */
040: public class MeterProperties extends ExtPropertyGroup {
041: /** Key for maximum value */
042: public static final String MAXINUM_VALUE_KEY = "max-value";
043:
044: /** Key for minimum value */
045: public static final String MINIMUM_VALUE_KEY = "min-value";
046:
047: /** Key for maximum critical value */
048: public static final String MAXINUM_CRITICAL_VALUE_KEY = "max-critical-value";
049:
050: /** Key for minimum critical value */
051: public static final String MINIMUM_CRITICAL_VALUE_KEY = "min-critical-value";
052:
053: /** Key for maximum normal value */
054: public static final String MAXINUM_NORMAL_VALUE_KEY = "max-normal-value";
055:
056: /** Key for minimum normal value */
057: public static final String MINIMUM_NORMAL_VALUE_KEY = "min-normal-value";
058:
059: /** Key for maximum warning value */
060: public static final String MAXINUM_WARNING_VALUE_KEY = "max-warning-value";
061:
062: /** Key for minimum warning value */
063: public static final String MINIMUM_WARNING_VALUE_KEY = "min-warning-value";
064:
065: /** Key for units */
066: public static final String UNITS_KEY = "units";
067:
068: /** Key for border type */
069: public static final String BORDER_TYPE_KEY = "border-type";
070: /** Key for dial type */
071: public static final String DIAL_TYPE_KEY = "dial-type";
072: /** Key for draw border flag */
073: public static final String DRAW_BORDER_KEY = "draw-border";
074: /** Key for draw border flag */
075: public static final String TICK_LABEL_TYPE_KEY = "tick-label-type";
076: /** Key for critical paint */
077: public static final String CRITICAL_PAINT_KEY = "critical-paint";
078: /** Key for normal paint */
079: public static final String NORMAL_PAINT_KEY = "normal-paint";
080: /** Key for warning paint */
081: public static final String WARNING_PAINT_KEY = "warning-paint";
082: /** Key for dial border color */
083: public static final String DIAL_BORDER_COLOR_KEY = "dial-border-color";
084: /** Key for dial background paint */
085: public static final String DIAL_BACKGROUND_PAINT_KEY = "dial-background-paint";
086: /** Key for needle paint */
087: public static final String NEEDLE_PAINT_KEY = "needle-paint";
088: /** Key for value paint */
089: public static final String VALUE_PAINT_KEY = "value-paint";
090: /** Key for ValueFont property */
091: public static final String VALUE_FONT_KEY = "value-font";
092: /** Key for legend text */
093: public static final String LEGEND_TEXT_KEY = "legend-text";
094: /** Key for tick label font name */
095: public static final String TICK_LABEL_FONT_KEY = "tick-label-font";
096: /** Key for meter angle property */
097: public static final String METER_ANGLE_KEY = "meter-angle";
098:
099: /** Circle dial type */
100: public static final int DIALTYPE_CIRCLE = 0;
101: /** Pie dial type */
102: public static final int DIALTYPE_PIE = 1;
103: /** Chord dial type */
104: public static final int DIALTYPE_CHORD = 2;
105: /** No tick label */
106: public static final int TICK_NO_LABELS = 0;
107: /** Value tick label */
108: public static final int TICK_VALUE_LABELS = 1;
109: /** Border type - normal */
110: public static final int BORDER_TYPE_NORMAL = 0;
111: /** Border type - warning */
112: public static final int BORDER_TYPE_WARNING = 1;
113: /** Border type - critical */
114: public static final int BORDER_TYPE_CRITICAL = 2;
115: /** Border type - full */
116: public static final int BORDER_TYPE_FULL = 3;
117:
118: /** XML tag */
119: public static final String METER_TAG = "meter-defaults";
120:
121: /** Default max value */
122: public static final double DEFAULT_MAX_VALUE = 3;
123:
124: /** Default min value */
125: public static final double DEFAULT_MIN_VALUE = 0;
126:
127: /** Default max critical value */
128: public static final double DEFAULT_MAX_CRITICAL_VALUE = 3;
129:
130: /** Default min critical value */
131: public static final double DEFAULT_MIN_CRITICAL_VALUE = 2;
132:
133: /** Default max normal value */
134: public static final double DEFAULT_MAX_NORMAL_VALUE = 1;
135:
136: /** Default min normal value */
137: public static final double DEFAULT_MIN_NORMAL_VALUE = 0;
138:
139: /** Default max warning value */
140: public static final double DEFAULT_MAX_WARNING_VALUE = 2;
141:
142: /** Default min warning value */
143: public static final double DEFAULT_MIN_WARNING_VALUE = 1;
144:
145: /** Default units value */
146: public static final String DEFAULT_UNITS = "units";
147:
148: /** Default border type */
149: public static final int DEFAULT_BORDER_TYPE = BORDER_TYPE_NORMAL;
150:
151: /** Default meter angle */
152: // public static final int DEFAULT_METER_ANGLE = MeterPlot.DEFAULT_METER_ANGLE;
153: /** Default dial type */
154: public static final int DEFAULT_DIAL_TYPE = DIALTYPE_CIRCLE;
155:
156: /** Default tick label type */
157: public static final int DEFAULT_TICK_LABEL_TYPE = TICK_VALUE_LABELS;
158:
159: /** Default draw border flag */
160: public static final boolean DEFAULT_DRAW_BORDER = false;
161:
162: /** Default critical paint color */
163: public static final Color DEFAULT_CRITICAL_PAINT = Color.RED;
164:
165: public static final Color DEFAULT_NORMAL_PAINT = Color.GREEN;
166:
167: public static final Color DEFAULT_WARNING_PAINT = Color.YELLOW;
168:
169: public static final Color DEFAULT_DIAL_BORDER_COLOR = Color.BLACK;
170: public static final Color DEFAULT_DIAL_BACKGROUND_COLOR = Color.WHITE;
171: public static final Color DEFAULT_NEEDLE_COLOR = Color.BLACK;
172: public static final Color DEFAULT_VALUE_COLOR = Color.BLACK;
173: private static final int DEFAULT_ALL_FIELDS_FONT_STYLE = Font.PLAIN;
174: private static final int DEFAULT_ALL_FIELDS_FONT_SIZE = 9;
175:
176: /** Default legend text */
177: public static final String DEFAULT_LEGEND_TEXT = "Meter";
178:
179: public static final Font DEFAULT_VALUE_FONT = new Font("SansSerif",
180: DEFAULT_ALL_FIELDS_FONT_STYLE, DEFAULT_ALL_FIELDS_FONT_SIZE);
181:
182: /**
183: * New instance
184: */
185: public MeterProperties() {
186: super ();
187:
188: initDefaults();
189:
190: }
191:
192: /**
193: * Init
194: */
195: public void initDefaults() {
196: setValueFont(DEFAULT_VALUE_FONT);
197: setTickLabelFont(DEFAULT_VALUE_FONT);
198: setCriticalPaint(DEFAULT_CRITICAL_PAINT);
199: setMaximumCriticalValue(DEFAULT_MAX_CRITICAL_VALUE);
200: setMinimumCriticalValue(DEFAULT_MIN_CRITICAL_VALUE);
201: setMaximumNormalValue(DEFAULT_MAX_NORMAL_VALUE);
202: setMinimumNormalValue(DEFAULT_MIN_NORMAL_VALUE);
203: setMaximumWarningValue(DEFAULT_MAX_WARNING_VALUE);
204: setMinimumWarningValue(DEFAULT_MIN_WARNING_VALUE);
205: setUnits(DEFAULT_UNITS);
206: setValueFont(DEFAULT_VALUE_FONT);
207: setMaximumValue(DEFAULT_MAX_VALUE);
208: setMinimumValue(DEFAULT_MIN_VALUE);
209: // setPieChartDefaults
210: }
211:
212: /**
213: * Returns the maximum value.
214: * @return - the maximum value
215: */
216: public double getMaximumValue() {
217: Double val = (Double) this .getPropertyValue(MAXINUM_VALUE_KEY);
218: if (val != null) {
219: return val.doubleValue();
220: }
221: return DEFAULT_MAX_VALUE;
222: }
223:
224: /**
225: * Sets the maximum value.
226: * @param value - the maximum value.
227: */
228: public void setMaximumValue(double value) {
229:
230: setProperty(MAXINUM_VALUE_KEY, new Double(value));
231:
232: }
233:
234: /**
235: * Returns the minimum value.
236: * @return - the minimum value
237: */
238: public double getMinimumValue() {
239: Double val = (Double) this .getPropertyValue(MINIMUM_VALUE_KEY);
240: if (val != null) {
241: return val.doubleValue();
242: }
243: return DEFAULT_MIN_VALUE;
244: }
245:
246: /**
247: * Sets the minimum value.
248: * @param value - the minimum value.
249: */
250: public void setMinimumValue(double value) {
251:
252: setProperty(MINIMUM_VALUE_KEY, new Double(value));
253:
254: }
255:
256: /**
257: * Returns the maximum critical value.
258: * @return - the maximum critical value
259: */
260: public double getMaximumCriticalValue() {
261: Double val = (Double) this
262: .getPropertyValue(MAXINUM_CRITICAL_VALUE_KEY);
263: if (val != null) {
264: return val.doubleValue();
265: }
266: return DEFAULT_MAX_CRITICAL_VALUE;
267: }
268:
269: /**
270: * Sets the maximum critical value.
271: * @param value - the maximum critical value.
272: */
273: public void setMaximumCriticalValue(double value) {
274:
275: setProperty(MAXINUM_CRITICAL_VALUE_KEY, new Double(value));
276:
277: }
278:
279: /**
280: * Returns the minimum critical value.
281: * @return - the minimum critical value
282: */
283: public double getMinimumCriticalValue() {
284: Double val = (Double) this
285: .getPropertyValue(MINIMUM_CRITICAL_VALUE_KEY);
286: if (val != null) {
287: return val.doubleValue();
288: }
289: return DEFAULT_MIN_CRITICAL_VALUE;
290: }
291:
292: /**
293: * Sets the minimum critical value.
294: * @param value - the minimum critical value.
295: */
296: public void setMinimumCriticalValue(double value) {
297:
298: setProperty(MINIMUM_CRITICAL_VALUE_KEY, new Double(value));
299: }
300:
301: /**
302: * Returns the maximum normal value.
303: * @return - the maximum normal value
304: */
305: public double getMaximumNormalValue() {
306: Double val = (Double) this
307: .getPropertyValue(MAXINUM_NORMAL_VALUE_KEY);
308: if (val != null) {
309: return val.doubleValue();
310: }
311: return DEFAULT_MAX_NORMAL_VALUE;
312: }
313:
314: /**
315: * Sets the maximum normal value.
316: * @param value - the maximum normal value.
317: */
318: public void setMaximumNormalValue(double value) {
319:
320: setProperty(MAXINUM_NORMAL_VALUE_KEY, new Double(value));
321: }
322:
323: /**
324: * Returns the minimum normal value.
325: * @return - the minimum normal value
326: */
327: public double getMinimumNormalValue() {
328: Double val = (Double) this
329: .getPropertyValue(MINIMUM_NORMAL_VALUE_KEY);
330: if (val != null) {
331: return val.doubleValue();
332: }
333: return DEFAULT_MIN_NORMAL_VALUE;
334: }
335:
336: /**
337: * Sets the minimum normal value.
338: * @param value - the minimum normal value.
339: */
340: public void setMinimumNormalValue(double value) {
341:
342: setProperty(MINIMUM_NORMAL_VALUE_KEY, new Double(value));
343:
344: }
345:
346: /**
347: * Returns the maximum warning value.
348: * @return - the maximum warning value
349: */
350: public double getMaximumWarningValue() {
351: Double val = (Double) this
352: .getPropertyValue(MAXINUM_WARNING_VALUE_KEY);
353: if (val != null) {
354: return val.doubleValue();
355: }
356: return DEFAULT_MAX_WARNING_VALUE;
357: }
358:
359: /**
360: * Sets the maximum warning value.
361: * @param value - the maximum warning value.
362: */
363: public void setMaximumWarningValue(double value) {
364:
365: setProperty(MAXINUM_WARNING_VALUE_KEY, new Double(value));
366: }
367:
368: /**
369: * Returns the minimum warning value.
370: * @return - the minimum warning value
371: */
372: public double getMinimumWarningValue() {
373: Double val = (Double) this
374: .getPropertyValue(MINIMUM_WARNING_VALUE_KEY);
375: if (val != null) {
376: return val.doubleValue();
377: }
378: return DEFAULT_MIN_WARNING_VALUE;
379: }
380:
381: /**
382: * Sets the minimum warning value.
383: * @param value - the minimum warning value.
384: */
385: public void setMinimumWarningValue(double value) {
386:
387: setProperty(MINIMUM_WARNING_VALUE_KEY, new Double(value));
388: }
389:
390: /**
391: * Returns the units
392: * @return - the units
393: */
394: public String getUnits() {
395: String val = (String) this .getPropertyValue(UNITS_KEY);
396: if (val != null) {
397: return val;
398: }
399: return DEFAULT_UNITS;
400: }
401:
402: /**
403: * Sets the units
404: * @param units - the units
405: */
406: public void setUnits(String units) {
407: setProperty(UNITS_KEY, units);
408: }
409:
410: /**
411: * Returns the paint used to display the 'critical' range
412: * @return - The paint
413: */
414: public Color getCriticalPaint() {
415: Color val = (Color) this .getPropertyValue(CRITICAL_PAINT_KEY);
416: if (val == null) {
417: val = DEFAULT_CRITICAL_PAINT;
418: }
419: return val;
420: }
421:
422: /**
423: * Sets the paint used to display the 'critical' range.
424: * @param paint - the paint
425: */
426: public void setCriticalPaint(Color paint) {
427: if (paint != null) {
428: setProperty(CRITICAL_PAINT_KEY, paint);
429: }
430: }
431:
432: /**
433: * Returns the paint used to display the 'normal' range
434: * @return - The paint
435: */
436: public Color getNormalPaint() {
437: Color val = (Color) this .getPropertyValue(NORMAL_PAINT_KEY);
438: if (val == null) {
439: val = DEFAULT_NORMAL_PAINT;
440: }
441: return val;
442: }
443:
444: /**
445: * Sets the paint used to display the 'normal' range.
446: * @param paint - the paint
447: */
448: public void setNormalPaint(Color paint) {
449: if (paint != null) {
450: setProperty(NORMAL_PAINT_KEY, paint);
451: }
452: }
453:
454: /**
455: * Returns the paint used to display the 'warning' range
456: * @return - The paint
457: */
458: public Color getWarningPaint() {
459: Color val = (Color) this .getPropertyValue(WARNING_PAINT_KEY);
460: if (val == null) {
461: val = DEFAULT_WARNING_PAINT;
462: }
463: return val;
464: }
465:
466: /**
467: * Sets the paint used to display the 'warning' range.
468: * @param paint - the paint
469: */
470: public void setWarningPaint(Color paint) {
471: if (paint != null) {
472: setProperty(WARNING_PAINT_KEY, paint);
473: }
474: }
475:
476: /**
477: * Returns the paint for the dial background.
478: * @return the paint
479: */
480: public Color getDialBackgroundPaint() {
481: Color val = (Color) this
482: .getPropertyValue(DIAL_BACKGROUND_PAINT_KEY);
483: if (val == null) {
484: val = DEFAULT_DIAL_BACKGROUND_COLOR;
485: }
486:
487: return val;
488: }
489:
490: /**
491: * Sets the paint used to fill the dial background
492: * @param paint - the paint
493: */
494: public void setDialBackgroundPaint(Color paint) {
495: if (paint != null) {
496: setProperty(DIAL_BACKGROUND_PAINT_KEY, paint);
497: }
498: }
499:
500: /**
501: * Returns the color of the border for the dial.
502: * @return the color of the border for the dial.
503: */
504: public Color getDialBorderColor() {
505: Color val = (Color) this
506: .getPropertyValue(DIAL_BORDER_COLOR_KEY);
507: if (val == null) {
508: val = DEFAULT_DIAL_BORDER_COLOR;
509: }
510: return val;
511: }
512:
513: /**
514: * Sets the color for the border of the dial.
515: * @param color - the color
516: */
517: public void setDialBorderColor(Color color) {
518: if (color != null) {
519: setProperty(DIAL_BORDER_COLOR_KEY, color);
520: }
521: }
522:
523: /**
524: * Returns meter angle
525: * @return meter angle
526: */
527: /** public int getMeterAngle() {
528: Integer val = (Integer) this.getPropertyValue(METER_ANGLE_KEY);
529: if (val != null) {
530: return val.intValue();
531: }
532: return DEFAULT_METER_ANGLE;
533: }
534: */
535: /**
536: * Sets meter angle
537: * @param angle - meter angle
538: */
539: public void setMeterAngle(int angle) {
540:
541: setProperty(METER_ANGLE_KEY, new Integer(angle));
542: }
543:
544: /**
545: * Returns the paint for the needle.
546: * @return the paint
547: */
548: public Color getNeedlePaint() {
549: Color val = (Color) this .getPropertyValue(NEEDLE_PAINT_KEY);
550: if (val == null) {
551: val = DEFAULT_NEEDLE_COLOR;
552: }
553: return val;
554: }
555:
556: /**
557: * Sets the paint used by the needle
558: * @param paint - the paint
559: */
560: public void setNeedlePaint(Color paint) {
561: if (paint != null) {
562: setProperty(NEEDLE_PAINT_KEY, paint);
563: }
564: }
565:
566: /**
567: * Returns value font
568: * @return value font
569: */
570: public Font getValueFont() {
571: Font f = (Font) this .getPropertyValue(VALUE_FONT_KEY);
572: if (f == null) {
573: f = DEFAULT_VALUE_FONT;
574: }
575: return f;
576:
577: }
578:
579: /**
580: * Sets value font
581: * @param font - value font
582: */
583: public void setValueFont(Font font) {
584: setProperty(VALUE_FONT_KEY, font);
585: }
586:
587: /**
588: * Returns the paint for the value.
589: * @return the paint
590: */
591: public Color getValuePaint() {
592: Color val = (Color) this .getPropertyValue(VALUE_PAINT_KEY);
593: if (val == null) {
594: val = DEFAULT_VALUE_COLOR;
595: }
596: return val;
597: }
598:
599: /**
600: * Sets the paint used by the value
601: * @param paint - the paint
602: */
603: public void setValuePaint(Color paint) {
604: if (paint != null) {
605: setProperty(VALUE_PAINT_KEY, paint);
606: }
607: }
608:
609: /**
610: * Returns the border type
611: * @return - the border type
612: */
613: public int getBorderType() {
614: Integer val = (Integer) this .getPropertyValue(BORDER_TYPE_KEY);
615: if (val != null) {
616: return val.intValue();
617: }
618: return DEFAULT_BORDER_TYPE;
619: }
620:
621: /**
622: * Sets the border type
623: * @param borderType - the border type
624: */
625: public void setBorderType(int borderType) {
626: setProperty(BORDER_TYPE_KEY, new Integer(borderType));
627: }
628:
629: /**
630: * Returns the type of dial (DIALTYPE_PIE, DIALTYPE_CIRCLE, DIALTYPE_CHORD).
631: * @return - the dial type
632: */
633: public int getDialType() {
634: Integer val = (Integer) this .getPropertyValue(DIAL_TYPE_KEY);
635: if (val != null) {
636: return val.intValue();
637: }
638: return DEFAULT_DIAL_TYPE;
639: }
640:
641: /**
642: * Sets the dial type (background shape)
643: * This controls the shape of the dial background. Use one of the constants:
644: * DIALTYPE_PIE, DIALTYPE_CIRCLE, or DIALTYPE_CHORD.
645: * @param type - dial type
646: */
647: public void setDialType(int type) {
648: setProperty(DIAL_TYPE_KEY, new Integer(type));
649: }
650:
651: /**
652: * Returns the tick label type. Defined by the constants: NO_LABELS, VALUE_LABELS
653: * @return - The tick label type.
654: */
655: public int getTickLabelType() {
656: Integer val = (Integer) this
657: .getPropertyValue(TICK_LABEL_TYPE_KEY);
658: if (val != null) {
659: return val.intValue();
660: }
661: return DEFAULT_TICK_LABEL_TYPE;
662: }
663:
664: /**
665: * Sets the tick label type
666: * @param type - the type of tick labels - either NO_LABELS or VALUE_LABELS
667: */
668: public void setTickLabelType(int type) {
669: setProperty(TICK_LABEL_TYPE_KEY, new Integer(type));
670: }
671:
672: /**
673: * Returns tick label font
674: * @return tick label font
675: */
676: public Font getTickLabelFont() {
677: Font f = (Font) this .getPropertyValue(TICK_LABEL_FONT_KEY);
678: if (f == null) {
679: f = DEFAULT_VALUE_FONT;
680: }
681: return f;
682: }
683:
684: /**
685: * Sets tick label font
686: * @param font - tick label font
687: */
688: public void setTickLabelFont(Font font) {
689: setProperty(TICK_LABEL_FONT_KEY, font);
690: }
691:
692: /**
693: * Returns a flag that controls whether or not a rectangular border is
694: * drawn around the plot area.
695: * @return - a flag
696: */
697: public boolean isDrawBorder() {
698: Boolean val = (Boolean) this .getPropertyValue(DRAW_BORDER_KEY);
699: if (val != null) {
700: return val.booleanValue();
701: }
702: return DEFAULT_DRAW_BORDER;
703: }
704:
705: /**
706: * Sets the flag that controls whether or not a rectangular border is drawn around the plot area.
707: * Note: it looks like the true setting needs some work to provide some insets
708: * @param draw - The flag
709: */
710: public void setDrawBorder(boolean draw) {
711: setProperty(DRAW_BORDER_KEY, new Boolean(draw));
712: }
713:
714: /**
715: * Returns legend text
716: * @return legend text
717: */
718: public String getLegendText() {
719: String val = (String) this .getPropertyValue(LEGEND_TEXT_KEY);
720: if (val != null) {
721: return val;
722: }
723: return DEFAULT_LEGEND_TEXT;
724: }
725:
726: /**
727: * Sets legend text
728: * @param text - legend text
729: */
730: public void setLegendText(String text) {
731: setProperty(LEGEND_TEXT_KEY, text);
732: }
733:
734: /**
735: * toString
736: * @return - string
737: */
738: public String toString() {
739: return "Meter Chart";
740: }
741:
742: /**
743: * Returns property template name
744: * @return - property template name
745: */
746: public String getPropertyTemplateName() {
747: return "MeterChart";
748: }
749:
750: }
|