com.googlecode.charts4j
Class MapChart

java.lang.Object
  extended by com.googlecode.charts4j.MapChart
All Implemented Interfaces:
GChart

public class MapChart
extends Object

Map chart constructed with the GCharts static factory class. Build a map and paramaterize it with countries and US states that you want to color along a color gradient. You can also select and zoom in on a GeographicalArea.

Author:
Julien Chastang (julien.c.chastang at gmail dot com)
See Also:
PoliticalBoundary, USAState, Country, GeographicalArea, GCharts

Method Summary
 void addPoliticalBoundaries(List<? extends PoliticalBoundary> politicalBoundaries)
          Add a list of political boundaries (e.g.
 void addPoliticalBoundaries(PoliticalBoundary... politicalBoundaries)
          Add one or more political boundaries (e.g.
 void addPoliticalBoundary(PoliticalBoundary politicalBoundary)
          Add a political boundary (e.g.
 void setBackgroundFill(Fill fill)
          Specify background fill.
 void setColorGradient(Color defaultColor, Color... colorGradient)
          Define a default color and color gradient.
 void setDataEncoding(DataEncoding dataEncoding)
          Set the data encoding scheme.
 void setSize(int width, int height)
          The default is 440x220 which is also the maximum size allowable for a MapChart.
 void setTransparency(int opacity)
          Specify the chart transparency.
 String toURLForHTML()
          Create a URL with the ampersand character entity reference (&amp;) in place of an ampersand.
 String toURLString()
          Create a URL string given the information supplied to this chart.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setColorGradient

public final void setColorGradient(Color defaultColor,
                                   Color... colorGradient)
Define a default color and color gradient.

Parameters:
defaultColor - Default color for this map.
colorGradient - Colors defined in the PoliticalBoundary will be interpolated along this color gradient.
See Also:
PoliticalBoundary

addPoliticalBoundary

public final void addPoliticalBoundary(PoliticalBoundary politicalBoundary)
Add a political boundary (e.g. Country or USAState).

Parameters:
politicalBoundary - Pass in a political boundary.

addPoliticalBoundaries

public final void addPoliticalBoundaries(PoliticalBoundary... politicalBoundaries)
Add one or more political boundaries (e.g. Country or USAState).

Parameters:
politicalBoundaries - Pass in one or more political boundaries.

addPoliticalBoundaries

public final void addPoliticalBoundaries(List<? extends PoliticalBoundary> politicalBoundaries)
Add a list of political boundaries (e.g. Country or USAState).

Parameters:
politicalBoundaries - Pass in a list of political boundaries.

setSize

public final void setSize(int width,
                          int height)
The default is 440x220 which is also the maximum size allowable for a MapChart.

Specified by:
setSize in interface GChart
Parameters:
width - Map chart width
height - Map chart height
See Also:
Chart Size

toURLString

public final String toURLString()
Create a URL string given the information supplied to this chart. You can copy and paste this string into your web browser, and see if you get the results you anticipated. Better yet, incorporate this method call or GChart.toURLForHTML() into your Internet application to dynamically generate charts. URLs beyond 2000 characters are not recommended. You can sometimes get away with the simple encoding scheme if URL length is a problem. See GChart.setDataEncoding(DataEncoding dataEncoding)

Specified by:
toURLString in interface GChart
Returns:
URL String
See Also:
DataEncoding, WWW FAQs: What is the maximum length of a URL?

toURLForHTML

public final String toURLForHTML()
Create a URL with the ampersand character entity reference (&amp;) in place of an ampersand. Useful for embedding your link in a web page.

Specified by:
toURLForHTML in interface GChart
Returns:
URL string

setBackgroundFill

public void setBackgroundFill(Fill fill)
Specify background fill.

Specified by:
setBackgroundFill in interface GChart
Parameters:
fill - Background fill. Cannot be null.
See Also:
Fill

setTransparency

public void setTransparency(int opacity)
Specify the chart transparency. Use cautiously as this feature may obscure background fills. Also there appears to be a bug in the Google Chart API where setting a transparency makes the label color disappear.

Specified by:
setTransparency in interface GChart
Parameters:
opacity - Supply a number between 0 and 100. 0 is completely transparent, and 100 is completely opaque.

setDataEncoding

public final void setDataEncoding(DataEncoding dataEncoding)
Set the data encoding scheme. The only advantage to the simple encoding scheme is it will ultimately result in shorter URLs, but at the cost of lower resolution. charts4j defaults to the extended encoding, but if you have lots of data and if you are willing to sacrifice resolution, the simple encoding may be right for you.

Specified by:
setDataEncoding in interface GChart
Parameters:
dataEncoding - Supply the data encoding, either simple or extended. Cannot be null.