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: * @(#)BarProperties.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.bar;
030:
031: import org.openesb.tools.extchart.property.JFChartConstants;
032: import org.openesb.tools.extpropertysheet.impl.ExtPropertyGroup;
033: import org.openesb.tools.extpropertysheet.impl.ExtPropertyOptions;
034: import java.awt.Color;
035:
036: /**
037: * BarProperties.java
038: *
039: * @author Chris Johnston
040: * @version :$Revision: 1.1 $
041: */
042: public class BarProperties extends ExtPropertyGroup {
043:
044: /** the RCS id */
045: static final String RCS_ID = "$Id: BarProperties.java,v 1.1 2007/07/03 19:25:03 rahul_dwivedi Exp $";
046:
047: /** IS_STACKED_KEY is a default key for stacked flag default for bar charts. */
048: public static final String IS_STACKED_KEY = "bd_stacked";
049:
050: /** BAR_CATEGORY_LABEL_TYPE_KEY is a default key. */
051: public static final String BAR_CATEGORY_LABEL_TYPE_KEY = "bd_barcategorytype";
052:
053: /** BAR_SERIES_LABEL_TYPE_KEY is a default key. */
054: public static final String BAR_SERIES_LABEL_TYPE_KEY = "bd_barseriestype";
055:
056: /** BAR_DISPLAY_EMPTY_CATEGORIES_KEY is a default key. */
057: public static final String BAR_DISPLAY_EMPTY_CATEGORIES_KEY = "bd_bardisplayemptycategories";
058:
059: /** BAR_DISPLAY_EMPTY_SERIES_KEY is a default key. */
060: public static final String BAR_DISPLAY_EMPTY_SERIES_KEY = "bd_bardisplayemptyseries";
061:
062: /** BAR_CATEGORY_GAP_PERCENT_KEY is a default key. */
063: public static final String BAR_CATEGORY_GAP_PERCENT_KEY = "bd_barcategorygappercent";
064:
065: /** BAR_SERIES_GAP_PERCENT_KEY is a default key. */
066: public static final String BAR_SERIES_GAP_PERCENT_KEY = "bd_barseriesgappercent";
067:
068: /** BAR_DISPLAY_EMPTY_LEGEND_ITEMS_KEY is a default key. */
069: public static final String BAR_DISPLAY_EMPTY_LEGEND_ITEMS_KEY = "bd_bardisplayemptylegenditems";
070:
071: /** DEFAULT_BAR_CHART_TITLE is used as a hard default. */
072: public static final String DEFAULT_BAR_CHART_TITLE = "Bar Chart";
073:
074: /** DEFAULT_STACKED is used as a hard default. */
075: public static final boolean DEFAULT_STACKED = false;
076:
077: /** BAR_CATEGORY_NO_LABELS_STRING is used for XML persistency. */
078: public static final String BAR_CATEGORY_NO_LABELS_STRING = "None";
079:
080: /** BAR_CATEGORY_NAME_LABELS_STRING is used for XML persistency. */
081: public static final String BAR_CATEGORY_NAME_LABELS_STRING = "Name";
082:
083: /** BAR_CATEGORY_VALUE_LABELS_STRING is used for XML persistency. */
084: public static final String BAR_CATEGORY_VALUE_LABELS_STRING = "Value";
085:
086: /** BAR_SERIES_NO_LABELS_STRING is used for XML persistency. */
087: public static final String BAR_SERIES_NO_LABELS_STRING = "None";
088:
089: /** BAR_SERIES_NAME_LABELS_STRING is used for XML persistency. */
090: public static final String BAR_SERIES_NAME_LABELS_STRING = "Name";
091:
092: /** BAR_SERIES_VALUE_LABELS_STRING is used for XML persistency. */
093: public static final String BAR_SERIES_VALUE_LABELS_STRING = "Value";
094:
095: /** DEFAULT_BAR_CATEGORY_LABEL_TYPE is set to zero for no labels */
096: public static final int DEFAULT_BAR_CATEGORY_LABEL_TYPE = 0;
097:
098: /** DEFAULT_BAR_SERIES_LABEL_TYPE is set to zero for no labels */
099: public static final int DEFAULT_BAR_SERIES_LABEL_TYPE = 0;
100:
101: /** DEFAULT_BAR_DISPLAY_EMPTY_CATEGORIES is used to display empty categories */
102: public static final boolean DEFAULT_BAR_DISPLAY_EMPTY_CATEGORIES = true;
103: /** DEFAULT_BAR_DISPLAY_EMPTY_SERIES is used to display empty series */
104: public static final boolean DEFAULT_BAR_DISPLAY_EMPTY_SERIES = true;
105:
106: /** DEFAULT_BAR_CATEGORY_GAP_PERCENT is a default */
107: public static final int DEFAULT_BAR_CATEGORY_GAP_PERCENT = 10;
108: /** DEFAULT_BAR_SERIES_GAP_PERCENT is a default */
109: public static final int DEFAULT_BAR_SERIES_GAP_PERCENT = 10;
110: /** DEFAULT_BAR_CATEGORY_OUTLINE_COLOR is a default */
111: public static final Color DEFAULT_BAR_CATEGORY_OUTLINE_COLOR = Color.white;
112: /** DEFAULT_DISPLAY_EMPTY_LEGEND_ITEMS is a default */
113: public static final boolean DEFAULT_BAR_DISPLAY_EMPTY_LEGEND_ITEMS = true;
114:
115: /** BAR_CATEGORY_SHADOWBOX_OUTLINE_STYLES is the list of outline styles */
116: /*
117: public static final int[] BAR_CATEGORY_SHADOWBOX_OUTLINE_STYLES = {
118: CategoryAxis.NO_OUTLINE_STYLE,
119: CategoryAxis.TOP_STYLE,
120: CategoryAxis.BOTTOM_STYLE,
121: CategoryAxis.LEFT_STYLE,
122: CategoryAxis.RIGHT_STYLE,
123: CategoryAxis.BOX_STYLE
124: };
125: */
126: /** DEFAULT_BAR_CATEGORY_SHADOWBOX_OUTLINE_STYLE is a default */
127:
128: // public static final int DEFAULT_BAR_CATEGORY_SHADOWBOX_OUTLINE_STYLE = CategoryAxis.NO_OUTLINE_STYLE;
129: Object[] defaultObjects = { Boolean.valueOf(DEFAULT_STACKED),
130: new Integer(DEFAULT_BAR_CATEGORY_LABEL_TYPE),
131: new Integer(DEFAULT_BAR_SERIES_LABEL_TYPE),
132: Boolean.valueOf(DEFAULT_BAR_DISPLAY_EMPTY_CATEGORIES),
133: Boolean.valueOf(DEFAULT_BAR_DISPLAY_EMPTY_SERIES),
134: Boolean.valueOf(DEFAULT_BAR_DISPLAY_EMPTY_LEGEND_ITEMS),
135: new Integer(DEFAULT_BAR_CATEGORY_GAP_PERCENT),
136: new Integer(DEFAULT_BAR_SERIES_GAP_PERCENT), };
137:
138: /** MY_DEFAULT_KEYS is the list of keys for this object. */
139: protected static final String[] MY_DEFAULT_KEYS = { IS_STACKED_KEY,
140: BAR_CATEGORY_LABEL_TYPE_KEY, BAR_SERIES_LABEL_TYPE_KEY,
141: BAR_DISPLAY_EMPTY_CATEGORIES_KEY,
142: BAR_DISPLAY_EMPTY_SERIES_KEY,
143: BAR_DISPLAY_EMPTY_LEGEND_ITEMS_KEY,
144: BAR_CATEGORY_GAP_PERCENT_KEY, BAR_SERIES_GAP_PERCENT_KEY };
145:
146: /** BAR_CATEGORY_LABEL_TYPES is used automate the bar category label processing. */
147: public static final String[] BAR_CATEGORY_LABEL_TYPES = {
148: BAR_CATEGORY_NO_LABELS_STRING,
149: BAR_CATEGORY_NAME_LABELS_STRING,
150: BAR_CATEGORY_VALUE_LABELS_STRING, };
151:
152: private static final ExtPropertyOptions BAR_CATEGORY_LABEL_TYPES_OPTIONS = new ExtPropertyOptions(
153: BAR_CATEGORY_LABEL_TYPES, true);
154:
155: /** BAR_SERIES_LABEL_TYPES is used automate the bar category label processing. */
156: public static final String[] BAR_SERIES_LABEL_TYPES = {
157: BAR_SERIES_NO_LABELS_STRING, BAR_SERIES_NAME_LABELS_STRING,
158: BAR_SERIES_VALUE_LABELS_STRING, };
159:
160: private static final ExtPropertyOptions BAR_SERIES_LABEL_TYPES_OPTIONS = new ExtPropertyOptions(
161: BAR_SERIES_LABEL_TYPES, true);
162:
163: static final String[] BAR_CHART_KEYS;
164: static {
165: String[] super Keys = XYProperties.MY_DEFAULT_KEYS;
166: String[] myKeys = new String[super Keys.length
167: + MY_DEFAULT_KEYS.length];
168: for (int n = 0; n < myKeys.length; n++) {
169: if (n < super Keys.length) {
170: myKeys[n] = super Keys[n];
171: } else {
172: myKeys[n] = MY_DEFAULT_KEYS[n - super Keys.length];
173: }
174: }
175: BAR_CHART_KEYS = myKeys;
176: }
177:
178: /**
179: * @see com.stc.ebam.server.chart.engine.view.ViewDefaults.getKeys()
180: */
181: public String[] getKeys() {
182: return BAR_CHART_KEYS;
183: }
184:
185: /**
186: * The BarChartDefaultsImpl constructor creates a new class instance.
187: */
188: public BarProperties() {
189: super ();
190:
191: initDefaults();
192: this .setGroupName(JFChartConstants.CHART_BAR_PROPERTIES);
193:
194: }
195:
196: /**
197: * Method isDisplayEmptyCategories is used to determine if empty categories are to be
198: * drawn (as jfree does by default).
199: * @return boolean true if empty categories are to be rendered
200: */
201: public boolean isDisplayEmptyCategories() {
202: Boolean val = (Boolean) this
203: .getPropertyValue(BAR_DISPLAY_EMPTY_CATEGORIES_KEY);
204: boolean returnValue = DEFAULT_BAR_DISPLAY_EMPTY_CATEGORIES;
205: if (val != null) {
206: returnValue = val.booleanValue();
207: }
208: return returnValue;
209: }
210:
211: /**
212: * Method setDisplayEmptyCategories is used to set empty categories displayability
213: * @param bDisplayEmptyBars is true if empty bars are to be rendered
214: */
215: public void setDisplayEmptyCategories(boolean bDisplayEmptyCatgories) {
216: setProperty(BAR_DISPLAY_EMPTY_CATEGORIES_KEY, Boolean
217: .valueOf(bDisplayEmptyCatgories));
218: }
219:
220: /**
221: * Method isDisplayEmptySeries is used to determine if empty series are to be
222: * drawn (as jfree does by default).
223: * @return boolean true if empty series are to be rendered
224: */
225: public boolean isDisplayEmptySeries() {
226: Boolean val = (Boolean) this
227: .getPropertyValue(BAR_DISPLAY_EMPTY_SERIES_KEY);
228: boolean returnValue = DEFAULT_BAR_DISPLAY_EMPTY_SERIES;
229: if (val != null) {
230: returnValue = val.booleanValue();
231: }
232: return returnValue;
233: }
234:
235: /**
236: * Method setDisplayEmptyBars is used to set empty bars displayability
237: * @param bDisplayEmptyBars is true if empty bars are to be rendered
238: */
239: public void setDisplayEmptySeries(boolean bDisplayEmptySeries) {
240: setProperty(BAR_DISPLAY_EMPTY_SERIES_KEY, Boolean
241: .valueOf(bDisplayEmptySeries));
242: }
243:
244: /**
245: * Method getCategoryGapPercent gets the percentage of gap between categories
246: * as a factor of the category drawing area
247: * @return int Percent as a percentage from 0 to 100
248: */
249: public int getCategoryGapPercent() {
250: Integer val = (Integer) this
251: .getPropertyValue(BAR_CATEGORY_GAP_PERCENT_KEY);
252: if (val != null) {
253: return val.intValue();
254: }
255: return DEFAULT_BAR_CATEGORY_GAP_PERCENT;
256: }
257:
258: /**
259: * Method setCategoryGapPercent sets the percentage of gap between categories
260: * as a factor of the category drawing area
261: * @param nPercent is a percentage from 0 to 100
262: */
263: public void setCategoryGapPercent(int nPercent) {
264:
265: setProperty(BAR_CATEGORY_GAP_PERCENT_KEY, new Integer(nPercent));
266:
267: }
268:
269: /**
270: * Method getSeriesGapPercent gets the percentage of gap between series
271: * as a factor of the series drawing area
272: * @return int Percent as a percentage from 0 to 100
273: */
274: public int getSeriesGapPercent() {
275: Integer val = (Integer) this
276: .getPropertyValue(BAR_SERIES_GAP_PERCENT_KEY);
277: if (val != null) {
278: return val.intValue();
279: }
280: return DEFAULT_BAR_SERIES_GAP_PERCENT;
281: }
282:
283: /**
284: * Method setSeriesGapPercent sets the percentage of gap between series
285: * as a factor of the series drawing area
286: * @param nPercent is a percentage from 0 to 100
287: */
288: public void setSeriesGapPercent(int nPercent) {
289:
290: setProperty(BAR_SERIES_GAP_PERCENT_KEY, new Integer(nPercent));
291:
292: }
293:
294: /**
295: * Method setBarCategoryLabelType is sets the category label type
296: * @param nBarCategoryLabelType is the new type
297: */
298: public void setBarCategoryLabelType(int nBarCategoryLabelType) {
299: if ((nBarCategoryLabelType >= 0)
300: && (nBarCategoryLabelType < BAR_CATEGORY_LABEL_TYPES.length)) {
301: setProperty(BAR_CATEGORY_LABEL_TYPE_KEY, new Integer(
302: nBarCategoryLabelType),
303: BAR_CATEGORY_LABEL_TYPES_OPTIONS);
304: }
305: }
306:
307: /**
308: * Method getBarCategoryLabelType retrieves the bar category label type
309: * @return int of identifier for the label type
310: */
311: public int getBarCategoryLabelType() {
312: Integer val = (Integer) this
313: .getPropertyValue(BAR_CATEGORY_LABEL_TYPE_KEY);
314: if (val != null) {
315: return val.intValue();
316: }
317: return DEFAULT_BAR_CATEGORY_LABEL_TYPE;
318: }
319:
320: /**
321: * Method setBarSeriesLabelType is used to set the bar series label type
322: * @param nBarSeriesLabelType is the new type
323: */
324: public void setBarSeriesLabelType(int nBarSeriesLabelType) {
325: if ((nBarSeriesLabelType >= 0)
326: && (nBarSeriesLabelType < BAR_SERIES_LABEL_TYPES.length)) {
327: setProperty(BAR_SERIES_LABEL_TYPE_KEY, new Integer(
328: nBarSeriesLabelType),
329: BAR_SERIES_LABEL_TYPES_OPTIONS);
330: }
331: }
332:
333: /**
334: * Method getBarSeriesLabelType is used to retrieve the series label type
335: * @return int identifier for the label type.
336: */
337: public int getBarSeriesLabelType() {
338: Integer val = (Integer) this
339: .getPropertyValue(BAR_SERIES_LABEL_TYPE_KEY);
340: if (val != null) {
341: return val.intValue();
342: }
343: return DEFAULT_BAR_SERIES_LABEL_TYPE;
344: }
345:
346: private void initDefaults() {
347: setStacked(DEFAULT_STACKED);
348: setBarCategoryLabelType(DEFAULT_BAR_CATEGORY_LABEL_TYPE);
349: setBarSeriesLabelType(DEFAULT_BAR_SERIES_LABEL_TYPE);
350: setDisplayEmptyCategories(DEFAULT_BAR_DISPLAY_EMPTY_CATEGORIES);
351: setDisplayEmptySeries(DEFAULT_BAR_DISPLAY_EMPTY_SERIES);
352: setDisplayEmptyLegendItems(DEFAULT_BAR_DISPLAY_EMPTY_LEGEND_ITEMS);
353: setCategoryGapPercent(DEFAULT_BAR_CATEGORY_GAP_PERCENT);
354: setSeriesGapPercent(DEFAULT_BAR_SERIES_GAP_PERCENT);
355: }
356:
357: /**
358: * @see com.stc.ebam.server.chart.engine.view.chart.xy.simple.BarChartDefaults.isStacked()
359: */
360: public boolean isStacked() {
361: Boolean val = (Boolean) this .getPropertyValue(IS_STACKED_KEY);
362: if (val != null) {
363: return val.booleanValue();
364: }
365: return DEFAULT_STACKED;
366: }
367:
368: /**
369: * Sets stacked
370: * @param bStacked - if stacked
371: */
372: public void setStacked(boolean bStacked) {
373: setProperty(IS_STACKED_KEY, Boolean.valueOf(bStacked));
374: }
375:
376: /**
377: * @see com.stc.ebam.server.chart.engine.view.chart.xy.simple.BarChartDefaults.isStacked()
378: */
379: public boolean isDisplayEmptyLegendItems() {
380: Boolean val = (Boolean) this
381: .getPropertyValue(BAR_DISPLAY_EMPTY_LEGEND_ITEMS_KEY);
382: if (val != null) {
383: return val.booleanValue();
384: }
385: return DEFAULT_BAR_DISPLAY_EMPTY_LEGEND_ITEMS;
386: }
387:
388: /**
389: * Sets stacked
390: * @param bStacked - if stacked
391: */
392: public void setDisplayEmptyLegendItems(boolean bDisplay) {
393: setProperty(BAR_DISPLAY_EMPTY_LEGEND_ITEMS_KEY, Boolean
394: .valueOf(bDisplay));
395: }
396:
397: /**
398: * toString
399: * @return - string
400: */
401: public String toString() {
402: return "Bar Chart";
403: }
404:
405: /**
406: * Returns property template name
407: * @return - template name
408: */
409: public String getPropertyTemplateName() {
410: return "BarChart";
411: }
412:
413: }
|