001    /*
002     * This file is part of the Echo Point Project.  This project is a
003     * collection of Components that have extended the Echo Web Application
004     * Framework Version 3.
005     *
006     * Version: MPL 1.1
007     *
008     * The contents of this file are subject to the Mozilla Public License Version
009     * 1.1 (the "License"); you may not use this file except in compliance with
010     * the License. You may obtain a copy of the License at
011     * http://www.mozilla.org/MPL/
012     *
013     * Software distributed under the License is distributed on an "AS IS" basis,
014     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015     * for the specific language governing rights and limitations under the
016     * License.
017     */
018    
019    package echopoint.google.chart.internal;
020    
021    import echopoint.google.chart.model.FillArea;
022    import echopoint.google.chart.model.LineStyle;
023    import echopoint.google.chart.model.Range;
024    import echopoint.google.chart.model.RangeMarker;
025    
026    import java.util.Collection;
027    
028    /**
029     * An abstract base class for charts that support most of the configuration
030     * options supported by
031     * <a href='http://code.google.com/apis/chart/'>Google Chart API</a>.
032     *
033     * @author Rakesh Vidyadharan 2008-08-20
034     * @version $Id: AdvancedChart.java 83 2008-11-08 19:32:18Z sptrakesh $
035     */
036    public class AdvancedChart<N extends Number> extends SimpleChart<N>
037    {
038      private static final long serialVersionUID = 1l;
039    
040      /**
041       * The axis type specification for the chart.  This property can be
042       * styled.  See <a href='http://code.google.com/apis/chart/#axis_type'>Axis type</a>
043       * documentation.
044       */
045      public static final String PROPERTY_AXIS_TYPE = "axisType";
046    
047      /**
048       * The collection of collection of labels (string) for the axes.  This must
049       * have as many child collections as there are axis types defined in
050       * AXIS_TYPE.  See
051       * <a href='http://code.google.com/apis/chart/#axes_labels'>Axis labels</a>
052       * documentation.  This property cannot be styled.
053       */
054      public static final String PROPERTY_AXIS_LABELS = "axisLabels";
055    
056      /**
057       * The label positions for the axis labels.  This can be used to present
058       * labels that are non-unoformly distributed along the axis.  Similar to
059       * AXIS_LABELS, this is specified as a collection of collection of label
060       * positions (numbers).  This property cannot be styled.  See
061       * <a href='http://code.google.com/apis/chart/#axes_label_positions'>Axis
062       * positions</a> documentation.
063       */
064      public static final String PROPERTY_LABEL_POSITIONS = "labelPositions";
065    
066      /**
067       * The ranges for the axes defined for the chart.  The value is expressed
068       * as a collection of {@link echopoint.google.chart.model.Range} object instances
069       * with the collection size being equal to the number of axes defined for
070       * the chart. This property cannot be styled.
071       * See <a href='http://code.google.com/apis/chart/#axis_range'>Axis
072       * ranges</a> documentation.
073       */
074      public static final String PROPERTY_AXIS_RANGES = "axisRanges";
075    
076      /**
077       * The styles to apply for the axis labels.  The value is expressed as
078       * a string with the specified format without the <code>&amp;chxs=</code>
079       * prefix.  This property is best set as a style.
080       * See <a href='http://code.google.com/apis/chart/#axes_styles'>Axis
081       * styles</a> documentation for specification.
082       */
083      public static final String PROPERTY_AXIS_STYLES = "axisStyles";
084    
085      /**
086       * The line styles for the data sets plotted.  Value is expressed as a
087       * collection of {@link echopoint.google.chart.model.LineStyle} objects.  This
088       * property is not styleable.
089       */
090      public static final String PROPERTY_LINE_STYLES = "lineStyles";
091    
092      /**
093       * Style that controls display of grid lines.  See
094       * <a href='http://code.google.com/apis/chart/#grid'>Grid lines</a>
095       * documentation for specification.  Express the values without the
096       * <code>&amp;chls=</code> prefix in the style sheet.
097       */
098      public static final String PROPERTY_GRID_LINES = "gridLines";
099    
100      /**
101       * Range markers to display on the graph.  Value is specified as a collection
102       * of {@link echopoint.google.chart.model.RangeMarker} objects.  This property
103       * is not styleable.
104       */
105      public static final String PROPERTY_RANGE_MARKERS = "rangeMarkers";
106    
107      /**
108       * A collection of {@link echopoint.google.chart.model.FillArea} instances that
109       * represent the areas between lines that are to be filled.  This property
110       * is not styleable.
111       */
112      public static final String PROPERTY_FILL_AREA = "fillArea";
113    
114      /**
115       * Return the value of the {@link #PROPERTY_AXIS_TYPE} property.
116       *
117       * @return The property value.
118       */
119      public String getAxisType()
120      {
121        return (String) get( PROPERTY_AXIS_TYPE );
122      }
123    
124      /**
125       * Set the value of the {@link #PROPERTY_AXIS_TYPE} property.
126       *
127       * @param type The value of the property to set.
128       */
129      public void setAxisType( final String type )
130      {
131        set( PROPERTY_AXIS_TYPE, type );
132      }
133    
134      /**
135       * Return the value of the {@link #PROPERTY_AXIS_LABELS} property.
136       *
137       * @return The property value.
138       */
139      @SuppressWarnings( {"unchecked"} )
140      public Collection<Collection<String>> getAxisLabels()
141      {
142        return (Collection<Collection<String>>) get( PROPERTY_AXIS_LABELS );
143      }
144    
145      /**
146       * Set the value of the {@link #PROPERTY_AXIS_LABELS} property using the
147       * specified collection of collection of strings.
148       *
149       * @param labels The value to set.
150       */
151      public void setAxisLabels( final Collection<Collection<String>> labels )
152      {
153        set( PROPERTY_AXIS_LABELS, labels );
154      }
155    
156      /**
157       * Return the value of the {@link #PROPERTY_LABEL_POSITIONS} property.
158       *
159       * @return The property value.
160       */
161      @SuppressWarnings( {"unchecked"} )
162      public Collection<Collection<N>> getLabelPositions()
163      {
164        return (Collection<Collection<N>>) get( PROPERTY_LABEL_POSITIONS );
165      }
166    
167      /**
168       * Set the value of the {@link #PROPERTY_LABEL_POSITIONS} property using the
169       * collection of collection of numbers.
170       *
171       * @param positions The value to set after converting to JSON.
172       */
173      public void setLabelPositions( final Collection<Collection<N>> positions )
174      {
175        set( PROPERTY_LABEL_POSITIONS, positions );
176      }
177    
178      /**
179       * Return the value of the {@link #PROPERTY_AXIS_RANGES} property.
180       *
181       * @return The property value.
182       */
183      @SuppressWarnings( {"unchecked"} )
184      public Collection<Range> getAxisRanges()
185      {
186        return (Collection<Range>) get( PROPERTY_AXIS_RANGES );
187      }
188    
189      /**
190       * Set the value of the {@link #PROPERTY_AXIS_RANGES} property using the
191       * collection of range values.
192       *
193       * @param ranges The value to set.
194       */
195      public void setAxisRanges( final Collection<Range> ranges )
196      {
197        set( PROPERTY_AXIS_RANGES, ranges );
198      }
199    
200      /**
201       * Return the value of the {@link #PROPERTY_AXIS_STYLES} property.
202       *
203       * @return The property value.
204       */
205      public String getAxisStyles()
206      {
207        return (String) get( PROPERTY_AXIS_STYLES );
208      }
209    
210      /**
211       * Set the value of the {@link #PROPERTY_AXIS_STYLES} property.
212       *
213       * @param styles The value of the property to set.
214       */
215      public void setAxisStyles( final String styles )
216      {
217        set( PROPERTY_AXIS_STYLES, styles );
218      }
219    
220      /**
221       * Return the value of the {@link #PROPERTY_LINE_STYLES} property.
222       *
223       * @return The property value.
224       */
225      @SuppressWarnings( {"unchecked"} )
226      public Collection<LineStyle> getLineStyles()
227      {
228        return (Collection<LineStyle>) get( PROPERTY_LINE_STYLES );
229      }
230    
231      /**
232       * Set the value of the {@link #PROPERTY_LINE_STYLES} property.
233       *
234       * @param styles The value of the property to set.
235       */
236      public void setLineStyles( final Collection<LineStyle> styles )
237      {
238        set( PROPERTY_LINE_STYLES, styles );
239      }
240    
241      /**
242       * Return the value of the {@link #PROPERTY_GRID_LINES} property.
243       *
244       * @return The property value.
245       */
246      public String getGridLines()
247      {
248        return (String) get( PROPERTY_GRID_LINES );
249      }
250    
251      /**
252       * Set the value of the {@link #PROPERTY_GRID_LINES} property.
253       *
254       * @param gridLines The value of the property to set.
255       */
256      public void setGridLines( final String gridLines )
257      {
258        set( PROPERTY_GRID_LINES, gridLines );
259      }
260    
261      /**
262       * Return the value of the {@link #PROPERTY_RANGE_MARKERS} property.
263       *
264       * @return The property value.
265       */
266      @SuppressWarnings( {"unchecked"} )
267      public Collection<RangeMarker> getRangeMarkers()
268      {
269        return (Collection<RangeMarker>) get( PROPERTY_RANGE_MARKERS );
270      }
271    
272      /**
273       * Set the value of the {@link #PROPERTY_RANGE_MARKERS} property.
274       *
275       * @param markers The value of the property to set.
276       */
277      public void setRangeMarkers( final Collection<RangeMarker> markers )
278      {
279        set( PROPERTY_RANGE_MARKERS, markers );
280      }
281    
282      /**
283       * Return the value of the {@link #PROPERTY_FILL_AREA} property.
284       *
285       * @return The property value.
286       */
287      @SuppressWarnings( {"unchecked"} )
288      public Collection<FillArea> getFillArea()
289      {
290        return (Collection<FillArea>) get( PROPERTY_FILL_AREA );
291      }
292    
293      /**
294       * Set the value of the {@link #PROPERTY_FILL_AREA} property using the
295       * collection of area instances.
296       *
297       * @param area The value of the property to set.
298       */
299      public void setFillArea( final Collection<FillArea> area )
300      {
301        set( PROPERTY_FILL_AREA, area );
302      }
303    }