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;
020    
021    import echopoint.google.chart.internal.AbstractChart;
022    
023    /**
024     * Component wrapper for a
025     * <a href='http://code.google.com/apis/chart/#maps'>Map</a>
026     * provided by <a href='http://code.google.com/apis/chart/'>Google Chart
027     * API</a>.
028     *
029     * <p>The following code shows sample use of this component:</p>
030     * <pre>
031     *   import echopoint.google.chart.Map;
032     *   import echopoint.google.chart.model.ChartData;
033     *
034     *     ...
035     *     final ChartData&lt;Integer&gt; data = new ChartData&lt;Integer&gt;();
036     *     final Integer[] array = new Integer[] { 0, 5, 9 };
037     *     data.setXdata( Arrays.asList( array ) );
038     *
039     *     final Map chart = new Map();
040     *     final ArrayList&lt;ChartData&lt;Integer&gt;&gt; collection = new ArrayList&lt;ChartData&lt;Integer&gt;&gt;();
041     *     collection.add( data );
042     *     chart.setData( collection );
043     *     chart.setCodes( "MGKETN" );
044     * </pre>
045     *
046     * @author Rakesh Vidyadharan 2008-08-25
047     * @version $Id: Map.java 83 2008-11-08 19:32:18Z sptrakesh $
048     */
049    public class Map extends AbstractChart<Integer>
050    {
051      private static final long serialVersionUID = 1l;
052    
053      /** An enumeration used to represent the regions supported by the map. */
054      public enum Regions
055      { africa, asia, europe, middle_east, south_america, usa, world }
056    
057      /**
058       * The property used to configure the map area.  This property may be
059       * styled.
060       */
061      public static final String PROPERTY_GEOGRAPHICAL_AREA = "region";
062    
063      /**
064       * The property used to specify colour and colour gradients for countries or
065       * states displayed in the map.  Colour specifications are different for
066       * maps as compared to regular charts.  This property is best styled.
067       */
068      public static final String PROPERTY_COLORS = "colors";
069    
070      /**
071       * The property used to configure the countries or states in the map that
072       * are to be coloured.  This property may be styled.
073       */
074      public static final String PROPERTY_CODES = "codes";
075    
076      /**
077       * Return the {@link #PROPERTY_GEOGRAPHICAL_AREA} property value.
078       *
079       * @return The value that indicates the chart dimensions.
080       */
081      public Regions getGeographicalArea()
082      {
083        return (Regions) get( PROPERTY_GEOGRAPHICAL_AREA );
084      }
085    
086      /**
087       * Set the value of the {@link #PROPERTY_GEOGRAPHICAL_AREA} property.
088       *
089       * @param region The value to set.
090       */
091      public void setGeographicalArea( final Regions region )
092      {
093        set( PROPERTY_GEOGRAPHICAL_AREA, region );
094      }
095    
096      /**
097       * Return the {@link #PROPERTY_COLORS} property value.
098       *
099       * @return The colors value encoded as required by the chart api.
100       */
101      public String getColors()
102      {
103        return (String) get( PROPERTY_COLORS );
104      }
105    
106      /**
107       * Set the value of the {@link #PROPERTY_COLORS} property.
108       *
109       * @param colors The value to set.
110       */
111      public void setColors( final String colors )
112      {
113        set( PROPERTY_COLORS, colors );
114      }
115    
116      /**
117       * Return the {@link #PROPERTY_CODES} property value.
118       *
119       * @return The codes value encoded as required by the chart api.
120       */
121      public String getCodes()
122      {
123        return (String) get( PROPERTY_CODES );
124      }
125    
126      /**
127       * Set the value of the {@link #PROPERTY_CODES} property.
128       *
129       * @param codes The value to set.
130       */
131      public void setCodes( final String codes )
132      {
133        set( PROPERTY_CODES, codes );
134      }
135    }