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: * @(#)ChartDefaults.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;
030:
031: /**
032: * ChartDefaults.java
033: *
034: * @author Chris Johnston
035: * @version :$Revision: 1.1 $
036: */
037: public class ChartDefaults extends ViewDefaults implements
038: ChartConstants {
039:
040: /** the RCS id */
041: static final String RCS_ID = "$Id: ChartDefaults.java,v 1.1 2007/07/03 19:24:54 rahul_dwivedi Exp $";
042:
043: public static final String IS_CHART_IMAGE_KEY = "cd_isChartImage";
044: public static final boolean DEFAULT_IS_CHART_IMAGE = false;
045:
046: public static final String CHART_IMAGE_LOCATION_KEY = "cd_chartImageLocation";
047: public static final String DEFAULT_CHART_IMAGE_LOCATION = "";
048:
049: public static final String CHART_IMAGE_DRAW_ORIGIN_KEY = "cd_chartImageDrawOrigin";
050: public static final int CHART_IMAGE_DRAW_ORIGIN_UPPERLEFT = 0;
051: public static final int CHART_IMAGE_DRAW_ORIGIN_CENTERED = 1;
052: public static final int[] CHART_IMAGE_DRAW_ORIGIN_TYPES = {
053: CHART_IMAGE_DRAW_ORIGIN_UPPERLEFT,
054: CHART_IMAGE_DRAW_ORIGIN_CENTERED };
055: public static final int DEFAULT_CHART_IMAGE_DRAW_ORIGIN = CHART_IMAGE_DRAW_ORIGIN_UPPERLEFT;
056:
057: public static final String CHART_IMAGE_FIT_KEY = "cd_chartImageFit";
058: public static final int CHART_IMAGE_UNCHANGED = 0;
059: public static final int CHART_IMAGE_STRETCH_TO_FIT = 1;
060: public static final int[] CHART_IMAGE_FIT_TYPES = {
061: CHART_IMAGE_UNCHANGED, CHART_IMAGE_STRETCH_TO_FIT };
062:
063: private static final String CHART_ID = "cdChartID";
064:
065: public static final int DEFAULT_CHART_IMAGE_FIT = CHART_IMAGE_UNCHANGED;
066:
067: /** defaultObjects is a list of default objects for this class */
068: Object[] defaultObjects = {
069: //Boolean.valueOf(DEFAULT_IS_CHART_IMAGE),
070: //DEFAULT_CHART_IMAGE_LOCATION,
071: new Integer(DEFAULT_CHART_IMAGE_DRAW_ORIGIN),
072: new Integer(DEFAULT_CHART_IMAGE_FIT),
073: Boolean.valueOf(DEFAULT_3D),
074: Boolean.valueOf(DEFAULT_INCLUDE_LEGEND),
075: new Integer(DEFAULT_IMAGE_WIDTH),
076: new Integer(DEFAULT_IMAGE_HEIGHT),
077: //new Integer(DEFAULT_REPORT_WIDTH),
078: //new Integer(DEFAULT_REPORT_HEIGHT),
079: //new Integer(DEFAULT_CHART_FILE_CREATION_FORMAT_TYPE),
080: //Boolean.valueOf(DEFAULT_DRILLDOWN_IS_ENABLED),
081: //DEFAULT_DRILLDOWN_CHART_NAME,
082: //Boolean.valueOf(DEFAULT_DISPLAY_NAVIGATION_BUTTONS),
083: //DEFAULT_NAVIGATION_CHART_NAME
084: };
085:
086: /** MY_DEFAULT_KEYS is a list of keys for this class. */
087: protected static final String[] MY_DEFAULT_KEYS = {
088: ///IS_CHART_IMAGE_KEY,
089: CHART_IMAGE_LOCATION_KEY, CHART_IMAGE_DRAW_ORIGIN_KEY,
090: CHART_IMAGE_FIT_KEY, IS_3D_KEY, IS_INCLUDE_LEGEND_KEY,
091: IMAGE_WIDTH_KEY, IMAGE_HEIGHT_KEY,
092: //REPORT_WIDTH_KEY,
093: //REPORT_HEIGHT_KEY,
094: //CHART_FILE_CREATION_FORMAT_TYPE_KEY,
095: //DRILLDOWN_IS_ENABLED_KEY,
096: //DRILLDOWN_CHART_NAME_KEY,
097: //DISPLAY_NAVIGATION_BUTTONS_KEY,
098: //NAVIGATION_CHART_NAME_KEY
099: };
100:
101: static final String[] CHART_KEYS;
102: static {
103: String[] super Keys = ViewDefaults.MY_DEFAULT_KEYS;
104: String[] myKeys = new String[super Keys.length
105: + MY_DEFAULT_KEYS.length];
106: for (int n = 0; n < myKeys.length; n++) {
107: if (n < super Keys.length) {
108: myKeys[n] = super Keys[n];
109: } else {
110: myKeys[n] = MY_DEFAULT_KEYS[n - super Keys.length];
111: }
112: }
113: CHART_KEYS = myKeys;
114: }
115:
116: /**
117: * @see com.stc.ebam.server.chart.engine.view.ViewDefaults.getKeys()
118: */
119: public String[] getKeys() {
120: return CHART_KEYS;
121: }
122:
123: /**
124: * The ChartDefaults constructor constructs a new chart defaults
125: * instance.
126: */
127: public ChartDefaults() {
128: super ();
129: initDefaults();
130: this .setGroupName(JFChartConstants.CHART_COMMON_PROPERTIES);
131: }
132:
133: private void initDefaults() {
134: //setChartImage(DEFAULT_IS_CHART_IMAGE);
135: //setChartImageLocation(DEFAULT_CHART_IMAGE_LOCATION);
136: //setChartImageDrawOrigin(DEFAULT_CHART_IMAGE_DRAW_ORIGIN);
137: //setChartImageFit(DEFAULT_CHART_IMAGE_FIT);
138: set3D(DEFAULT_3D);
139: setIncludeLegend(DEFAULT_INCLUDE_LEGEND);
140: setImageWidth(DEFAULT_IMAGE_WIDTH);
141: setImageHeight(DEFAULT_IMAGE_HEIGHT);
142: //setReportWidth(DEFAULT_REPORT_WIDTH);
143: // setReportHeight(DEFAULT_REPORT_HEIGHT);
144: //setChartFileCreationFormatType(DEFAULT_CHART_FILE_CREATION_FORMAT_TYPE);
145: //setDrilldownEnabled(DEFAULT_DRILLDOWN_IS_ENABLED);
146: //setDrilldownChartName(DEFAULT_DRILLDOWN_CHART_NAME);
147: //setDisplayNavigationButtons(DEFAULT_DISPLAY_NAVIGATION_BUTTONS);
148: //setNavigationChartName(DEFAULT_NAVIGATION_CHART_NAME);
149: }
150:
151: /**
152: * Method setChartImage is used to set the chart image on or off
153: * @param val val
154: */
155: /**public void setChartImage(boolean val) {
156: this.setProperty(IS_CHART_IMAGE_KEY, new Boolean(val));
157: }
158:
159: /**
160: * Method isChartImage is used to determine if a chart image is to be used
161: * @return boolean true if chart image is to be rendered
162: */
163: /**public boolean isChartImage() {
164: Boolean val = (Boolean) this.getPropertyValue(IS_CHART_IMAGE_KEY);
165: if (val != null) {
166: return val.booleanValue();
167: }
168: return DEFAULT_IS_CHART_IMAGE;
169: }
170:
171: /**
172: * Method getChartImageLocation returns the location of the chart image
173: * @return String of the chart image
174: */
175: /*
176: public String getChartImageLocation() {
177: String val = (String) this.getPropertyValue(CHART_IMAGE_LOCATION_KEY);
178: if (val != null) {
179: return val;
180: }
181: return DEFAULT_CHART_IMAGE_LOCATION;
182: }
183: */
184: /**
185: * Method setChartImageLocation sets the chart image location
186: * @param sChartImageLocation is the location for the image
187: */
188: /*
189: public void setChartImageLocation(String sChartImageLocation) {
190: this.setProperty(CHART_IMAGE_LOCATION_KEY, sChartImageLocation);
191: }
192: */
193: /**
194: * Method getChartImageDrawOrigin
195: * @return int of the draw origin
196: */
197: /*
198: public int getChartImageDrawOrigin() {
199: int nChartImageDrawOrigin = DEFAULT_CHART_IMAGE_DRAW_ORIGIN;
200: Integer val = (Integer) this.getPropertyValue(CHART_IMAGE_DRAW_ORIGIN_KEY);
201: if (val != null) {
202: nChartImageDrawOrigin= val.intValue();
203: }
204: return nChartImageDrawOrigin;
205: }
206: */
207: /**
208: * Method setChartImageDrawOrigin sets the draw origin for the chart image
209: * @param nChartImageDrawOrigin
210: */
211: /* public void setChartImageDrawOrigin(int nChartImageDrawOrigin) {
212: if ((nChartImageDrawOrigin >= 0) && (nChartImageDrawOrigin < CHART_IMAGE_DRAW_ORIGIN_TYPES.length)) {
213: this.setProperty(CHART_IMAGE_DRAW_ORIGIN_KEY, new Integer(nChartImageDrawOrigin));
214: }
215: }
216: */
217: /**
218: * Method getChartImageFit returns the fit for the chart image
219: * @return int of the draw origin
220: */
221: /* public int getChartImageFit() {
222: int nChartImageFit = DEFAULT_CHART_IMAGE_FIT;
223: Integer val = (Integer) this.getPropertyValue(CHART_IMAGE_FIT_KEY);
224: if (val != null) {
225: nChartImageFit= val.intValue();
226: }
227: return nChartImageFit;
228: }
229: */
230: /**
231: * Method setChartImageFit sets the fit for the chart image
232: * @param nChartImageFit
233: */
234: /* public void setChartImageFit(int nChartImageFit) {
235: if ((nChartImageFit >= 0) && (nChartImageFit < CHART_IMAGE_FIT_TYPES.length)) {
236: this.setProperty(CHART_IMAGE_FIT_KEY, new Integer(nChartImageFit));
237: }
238: }
239: */
240: /**
241: * set 3d
242: * @param val val
243: */
244: public void set3D(boolean val) {
245: this .setProperty(ChartDefaults.IS_3D_KEY, new Boolean(val));
246: }
247:
248: /**
249: * is 3d
250: * @return 3d
251: */
252: public boolean is3D() {
253: Boolean val = (Boolean) this
254: .getPropertyValue(ChartDefaults.IS_3D_KEY);
255: if (val != null) {
256: return val.booleanValue();
257: }
258: return DEFAULT_3D;
259: }
260:
261: /**
262: * Returns depth factor
263: * @return depth factor
264: */
265: public double getDepthFactor() {
266: Double val = (Double) this .getPropertyValue(DEPTH_FACTOR_KEY);
267: if (val != null) {
268: return val.doubleValue();
269: }
270: return DEFAULT_DEPTH_FACTOR;
271: }
272:
273: /**
274: * Sets depth factor
275: * @param factor - depth factor
276: */
277: public void setDepthFactor(double factor) {
278:
279: this .setProperty(DEPTH_FACTOR_KEY, new Double(factor));
280: }
281:
282: /**
283: * Returns if circular
284: * @return circular
285: */
286: public boolean isCircular() {
287: Boolean val = (Boolean) this .getPropertyValue(CIRCULAR_KEY);
288: if (val != null) {
289: return val.booleanValue();
290: }
291: return false;
292: }
293:
294: /**
295: * Sets circular
296: * @param circular - circular
297: */
298: public void setCircular(boolean circular) {
299: this .setProperty(CIRCULAR_KEY, new Boolean(circular));
300: }
301:
302: /**
303: * Returns direction
304: * @return direction
305: */
306: public int getDirection() {
307: Integer val = (Integer) this .getPropertyValue(DIRECTION_KEY);
308: if (val != null) {
309: return val.intValue();
310: }
311: return CLOCKWISE;
312: }
313:
314: /**
315: * Sets direction
316: * @param direction - direction
317: */
318: public void setDirection(int direction) {
319: this .setProperty(DIRECTION_KEY, new Integer(direction));
320: }
321:
322: /**
323: * Returns interior gap
324: * @return gap
325: */
326: public double getInteriorGap() {
327: Double val = (Double) this .getPropertyValue(INTERIOR_GAP_KEY);
328: if (val != null) {
329: return val.doubleValue();
330: }
331: return 0.3;
332: }
333:
334: /**
335: * Sets interior gap
336: * @param gap - gap
337: */
338: public void setInteriorGap(double gap) {
339:
340: this .setProperty(INTERIOR_GAP_KEY, new Double(gap));
341: }
342:
343: /**
344: * set include legend
345: * @param include include
346: */
347: public void setIncludeLegend(boolean include) {
348: this .setProperty(IS_INCLUDE_LEGEND_KEY, new Boolean(include));
349: }
350:
351: /**
352: * is include legend
353: * @return include legend
354: */
355: public boolean isIncludeLegend() {
356: Boolean val = (Boolean) this
357: .getPropertyValue(IS_INCLUDE_LEGEND_KEY);
358: if (val != null) {
359: return val.booleanValue();
360: }
361: return DEFAULT_INCLUDE_LEGEND;
362: }
363:
364: /**
365: * Returns legend anchor
366: * @return legend anchor
367: */
368: public int getLegendAnchor() {
369: Integer val = (Integer) this
370: .getPropertyValue(LEGEND_ANCHOR_KEY);
371: if (val != null) {
372: return val.intValue();
373: }
374: return DEFAULT_LEGEND_ANCHOR;
375: }
376:
377: /**
378: * Sets legend anchor
379: * @param anchor - legend anchor
380: */
381: public void setLegendAnchor(int anchor) {
382: this .setProperty(LEGEND_ANCHOR_KEY, new Integer(anchor));
383: }
384:
385: /**
386: * set image width
387: * @param width width
388: */
389: public void setImageWidth(int width) {
390:
391: this .setProperty(ChartDefaults.IMAGE_WIDTH_KEY, new Integer(
392: width));
393: }
394:
395: /**
396: * get image width
397: * @return width
398: */
399: public int getImageWidth() {
400: Integer val = (Integer) this
401: .getPropertyValue(ChartDefaults.IMAGE_WIDTH_KEY);
402: if (val != null) {
403: return val.intValue();
404: }
405: return DEFAULT_IMAGE_WIDTH;
406: }
407:
408: /**
409: * set image height
410: * @param height height
411: */
412: public void setImageHeight(int height) {
413:
414: this .setProperty(ChartDefaults.IMAGE_HEIGHT_KEY, new Integer(
415: height));
416: }
417:
418: /**
419: * get image height
420: * @return image height
421: */
422: public int getImageHeight() {
423: Integer val = (Integer) this
424: .getPropertyValue(ChartDefaults.IMAGE_HEIGHT_KEY);
425: if (val != null) {
426: return val.intValue();
427: }
428:
429: //return default??
430: return DEFAULT_IMAGE_HEIGHT;
431: }
432:
433: public String getChartID() {
434:
435: String val = (String) this .getPropertyValue(CHART_ID);
436: if (val != null) {
437: return val;
438: } else {
439: return null;
440: }
441: }
442:
443: public void setChartID(String i) {
444: this .setProperty(CHART_ID, i);
445: }
446:
447: public String getPropertyTemplateName() {
448: return "CommonChart";
449: }
450:
451: }
|