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: * @(#)PieProperties.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.pie;
030:
031: import org.openesb.tools.extpropertysheet.impl.ExtPropertyGroup;
032: import java.awt.Color;
033: import java.awt.Font;
034:
035: /**
036: * PieChartDefaultsImpl.java
037: *
038: * PieChartDefaultsImpl is used to encapsulate all defaults specific only to
039: * pie charts.
040: *
041: * @author Chris Johnston
042: * @version :$Revision: 1.1 $
043: */
044:
045: public class PieProperties extends ExtPropertyGroup implements
046: PieConstants {
047:
048: /** the RCS id */
049: public static final String RCS_ID = "$Id: PieProperties.java,v 1.1 2007/07/03 19:25:04 rahul_dwivedi Exp $";
050: /** DEFAULT_SECTION_LABEL is used as a hard default. */
051: public static final int DEFAULT_SECTION_LABEL = 1;//PiePlot.NAME_AND_VALUE_LABELS; //PiePlot.NO_LABELS;
052:
053: /** DEFAULT_TOOLTIP_LABEL_FORMAT is used as a hard default. */
054: public static final int DEFAULT_TOOLTIP_LABEL_FORMAT = 1;
055:
056: /** TOOLTIP_LABEL_FORMATS is used automate the section label processing. */
057: //public static final String[] TOOLTIP_LABEL_FORMATS;
058: public static final String[] TOOLTIP_LABEL_FORMATS = {
059: TOOLTIP_NO_LABELS_STRING, TOOLTIP_NAME_LABELS_STRING,
060: TOOLTIP_VALUE_LABELS_STRING, TOOLTIP_PERCENT_LABELS_STRING,
061: TOOLTIP_NAME_AND_VALUE_LABELS_STRING,
062: TOOLTIP_NAME_AND_PERCENT_LABELS_STRING,
063: TOOLTIP_VALUE_AND_PERCENT_LABELS_STRING,
064: TOOLTIP_NAME_VALUE_AND_PERCENT_LABELS_STRING };
065:
066: /** SECTION_LABELS is used automate the section label processing. */
067: //public static final String[] SECTION_LABELS;
068: public static final String[] SECTION_LABELS = {
069: SECTION_NO_LABELS_STRING, SECTION_NAME_LABELS_STRING,
070: SECTION_VALUE_LABELS_STRING, SECTION_PERCENT_LABELS_STRING,
071: SECTION_NAME_AND_VALUE_LABELS_STRING,
072: SECTION_NAME_AND_PERCENT_LABELS_STRING,
073: SECTION_VALUE_AND_PERCENT_LABELS_STRING,
074: SECTION_NAME_VALUE_AND_PERCENT_LABELS_STRING };
075:
076: Object[] defaultObjects = { new Double(DEFAULT_RADIUS),
077: new Integer(DEFAULT_SECTION_LABEL),
078: new Integer(DEFAULT_TOOLTIP_LABEL_FORMAT) };
079:
080: /** MY_DEFAULT_KEYS contains the default keys for this class */
081: protected static final String[] MY_DEFAULT_KEYS = { RADIUS_KEY,
082: SECTION_LABEL_TYPE_KEY, TOOLTIP_LABEL_FORMAT_KEY,
083: INDIVIDUAL_SLICE_LABEL_KEY,
084: INDIVIDUAL_SLICE_IS_EXPLODED_KEY,
085: INDIVIDUAL_SLICE_EXPLODE_PERCENT_KEY };
086:
087: public static final Font DEFAULT_SECTION_FONT = new Font(
088: "SansSerif", DEFAULT_ALL_FIELDS_FONT_STYLE,
089: DEFAULT_ALL_FIELDS_FONT_SIZE);
090: public static final Font DEFAULT_SERIES_FONT = new Font(
091: "SansSerif", DEFAULT_ALL_FIELDS_FONT_STYLE,
092: DEFAULT_ALL_FIELDS_FONT_SIZE);
093:
094: static final String[] PIE_CHART_KEYS;
095: static {
096: //String[] superKeys = ChartDefaults.MY_DEFAULT_KEYS;
097: String[] myKeys = new String[MY_DEFAULT_KEYS.length];
098: for (int n = 0; n < myKeys.length; n++) {
099: //if (n < superKeys.length) {
100: // myKeys[n] = superKeys[n];
101: //} else {
102: myKeys[n] = MY_DEFAULT_KEYS[n];
103: //}
104: }
105: PIE_CHART_KEYS = myKeys;
106: }
107:
108: /**
109: * @see com.stc.ebam.server.chart.engine.view.ViewDefaults.getKeys()
110: */
111: public String[] getKeys() {
112: return PIE_CHART_KEYS;
113: }
114:
115: /**
116: * New instance
117: */
118: public PieProperties() {
119: super ();
120:
121: initDefaults();
122:
123: }
124:
125: /**
126: * Init
127: */
128: public void initDefaults() {
129: setSectionLabel(DEFAULT_SECTION_LABEL);
130: setTooltipLabelFormat(DEFAULT_TOOLTIP_LABEL_FORMAT);
131: setRadius(DEFAULT_RADIUS);
132: setSectionLabelFont(DEFAULT_SECTION_FONT);
133: setSeriesLabelFont(DEFAULT_SERIES_FONT);
134: // setPieChartDefaults
135: }
136:
137: /**
138: * @see com.stc.ebam.server.chart.engine.view.tabular.TabularProperties.getFieldWidth()
139: */
140: /*
141: public String getSliceLabel(String fieldName) {
142: FieldProperties fieldProp = this.getFieldPropertyForColumn(fieldName);
143: if (fieldProp != null) {
144: String label = (String) fieldProp.getFieldPropertyMap().getPropertyValue(INDIVIDUAL_SLICE_LABEL_KEY);
145: return label;
146: }
147:
148: return fieldName;
149: }
150: */
151: /**
152: * @see com.stc.ebam.server.chart.engine.view.tabular.TabularProperties.getFieldWidth()
153: */
154: /*
155: public boolean isSliceExploded(String fieldName) {
156: FieldProperties fieldProp = this.getFieldPropertyForColumn(fieldName);
157: if (fieldProp != null) {
158: Boolean exploded = (Boolean) fieldProp.getFieldPropertyMap().getPropertyValue(
159: INDIVIDUAL_SLICE_IS_EXPLODED_KEY);
160: return exploded.booleanValue();
161: }
162:
163: return false;
164: }
165: */
166: /**
167: * @see com.stc.ebam.server.chart.engine.view.tabular.TabularProperties.getFieldWidth()
168: */
169: /*
170: public int getSliceExplodedPercent(String fieldName) {
171: FieldProperties fieldProp = this.getFieldPropertyForColumn(fieldName);
172: if (fieldProp != null) {
173: Integer explodedPercent = (Integer) fieldProp.getFieldPropertyMap().getPropertyValue(
174: INDIVIDUAL_SLICE_EXPLODE_PERCENT_KEY);
175: return explodedPercent.intValue();
176: }
177:
178: return DEFAULT_ALL_EXPLODED_PERCENT;
179: }
180: */
181: /**
182: * @see com.stc.ebam.server.chart.engine.view.chart.pie.PieChartDefaults.getRadius()
183: */
184: public double getRadius() {
185: Double val = (Double) this .getPropertyValue(RADIUS_KEY);
186: if (val != null) {
187: return val.doubleValue();
188: }
189:
190: //return default
191: return DEFAULT_RADIUS;
192:
193: }
194:
195: /**
196: * @see com.stc.ebam.server.chart.engine.view.chart.pie.PieChartDefaults.setRadius()
197: */
198: public void setRadius(double newRadius) {
199:
200: setProperty(RADIUS_KEY, new Double(newRadius));
201: }
202:
203: /**
204: * @see com.stc.ebam.server.chart.engine.view.chart.pie.PieChartDefaults.setSectionLabel()
205: */
206: public void setTooltipLabelFormat(int nTooltipLabelFormat) {
207: if ((nTooltipLabelFormat >= 0)
208: && (nTooltipLabelFormat < TOOLTIP_LABEL_FORMATS.length)) {
209: setProperty(TOOLTIP_LABEL_FORMAT_KEY, new Integer(
210: nTooltipLabelFormat));
211: }
212: }
213:
214: /**
215: * @see com.stc.ebam.server.chart.engine.view.chart.pie.PieChartDefaults.getSectionLabel()
216: */
217: public int getTooltipLabelFormat() {
218: Integer val = (Integer) this
219: .getPropertyValue(TOOLTIP_LABEL_FORMAT_KEY);
220: if (val != null) {
221: return val.intValue();
222: }
223: return DEFAULT_TOOLTIP_LABEL_FORMAT;
224: }
225:
226: /**
227: * @see com.stc.ebam.server.chart.engine.view.chart.pie.PieChartDefaults.setSectionLabel()
228: */
229: public void setSectionLabel(int nSectionLabelType) {
230: if ((nSectionLabelType >= 0)
231: && (nSectionLabelType < SECTION_LABELS.length)) {
232: setProperty(SECTION_LABEL_TYPE_KEY, new Integer(
233: nSectionLabelType));
234: }
235: }
236:
237: /**
238: * @see com.stc.ebam.server.chart.engine.view.chart.pie.PieChartDefaults.getSectionLabel()
239: */
240: public int getSectionLabel() {
241: Integer val = (Integer) this
242: .getPropertyValue(SECTION_LABEL_TYPE_KEY);
243: if (val.intValue() == 0) {
244: setSectionLabel(DEFAULT_SECTION_LABEL);
245: return DEFAULT_SECTION_LABEL;
246: }
247: if (val != null) {
248: return val.intValue();
249: }
250: return DEFAULT_SECTION_LABEL;
251: }
252:
253: /**
254: * Returns section label font
255: * @return section label font
256: */
257: public Font getSectionLabelFont() {
258: Font f = (Font) getPropertyValue(SECTION_LABEL_FONT_KEY);
259: if (f == null) {
260: f = DEFAULT_SECTION_FONT;
261: }
262: return f;
263: }
264:
265: /**
266: * Sets section label font
267: * @param font - section label font
268: */
269: public void setSectionLabelFont(Font font) {
270: setProperty(SECTION_LABEL_FONT_KEY, font);
271: }
272:
273: /**
274: * Returns section label gap
275: * @return gap
276: */
277: public double getSectionLabelGap() {
278: Double val = (Double) this
279: .getPropertyValue(SECTION_LABEL_GAP_KEY);
280: if (val != null) {
281: return val.doubleValue();
282: }
283: return 0.3;
284: }
285:
286: /**
287: * Returns if show series labels
288: * @return true/false
289: */
290: public boolean isShowSectionLabels() {
291: Boolean val = (Boolean) this
292: .getPropertyValue(SHOW_SECTION_LABELS_KEY);
293: if (val != null) {
294: return val.booleanValue();
295: }
296: return false;
297: }
298:
299: /**
300: * Sets show series labels
301: * @param show - true/false
302: */
303: public void setShowSectionLabels(boolean show) {
304: this .setProperty(SHOW_SECTION_LABELS_KEY, new Boolean(show));
305: }
306:
307: /**
308: * Returns series label font
309: * @return font
310: */
311: public Font getSeriesLabelFont() {
312: Font val = (Font) this .getPropertyValue(SERIES_LABEL_FONT_KEY);
313: if (val == null) {
314: val = DEFAULT_SERIES_FONT;
315: }
316: return val;
317:
318: }
319:
320: /**
321: * Sets series label font
322: * @param font - font
323: */
324: public void setSeriesLabelFont(Font font) {
325: setProperty(SERIES_LABEL_FONT_KEY, font);
326: }
327:
328: /**
329: * Returns series label paint
330: * @return series label paint
331: */
332: public Color getSeriesLabelPaint() {
333: Color val = (Color) this
334: .getPropertyValue(SERIES_LABEL_PAINT_KEY);
335: return val;
336: }
337:
338: /**
339: * Sets series label paint
340: * @param paint - paint
341: */
342: public void setSeriesLabelPaint(Color paint) {
343: if (paint != null) {
344: setProperty(SERIES_LABEL_PAINT_KEY, paint);
345: }
346: }
347:
348: /**
349: * Sets section label gap
350: * @param gap - gap
351: */
352: public void setSectionLabelGap(double gap) {
353:
354: this .setProperty(SECTION_LABEL_GAP_KEY, new Double(gap));
355: }
356:
357: /**
358: * Returns section label paint
359: * @return section label paint
360: */
361: public Color getSectionLabelPaint() {
362: Color val = (Color) this
363: .getPropertyValue(SECTION_LABEL_PAINT_KEY);
364: return val;
365: }
366:
367: /**
368: * Sets section label paint
369: * @param paint - section label paint
370: */
371: public void setSectionLabelPaint(Color paint) {
372: if (paint != null) {
373: setProperty(SECTION_LABEL_PAINT_KEY, paint);
374: }
375: }
376:
377: /**
378: * toString
379: * @return - string
380: */
381: public String toString() {
382: return "Pie Chart";
383: }
384:
385: /**
386: * Return property template name
387: * @return - template name
388: */
389: public String getPropertyTemplateName() {
390: return "PieChart";
391: }
392:
393: }
|