- All Implemented Interfaces:
- java.lang.Iterable, org.apache.myfaces.trinidad.model.LocalRowKeyIndex, org.apache.myfaces.trinidad.model.RowKeyIndex
- Direct Known Subclasses:
- ActiveGeoMapDataModelDecorator
public class GeoMapDataModel
extends org.apache.myfaces.trinidad.model.CollectionModel
Data for each map theme is abstracted in an instance of a GeoMapDataModel. Users can create their own custom GeoMapDataModel theme data. The examples below show how to create custom color, bar/pie chart, point, and geocoded point themes. For each type of theme, the various data values and labels are defined within GeoRowObjects, and then these GeoRowObjects are used to populate a GeoMapDataModel. The example data assumes use of the MAP_STATES_NAME theme name. // Color Theme String rowid="Row1"; String location = "New Jersey"; String locationLabel = "The Garden State"; String itemIds[] = new String[]{"Item1"}; String itemLabels[] = new String[]{"Sales"}; Double value[] = new Double[]{10000.0}; String formattedValue[] = new String[]{"$10000.0"}; GeoObject key = new GeoObject(rowId, location, locationLabel); GeoRowObject rowObj = new GeoRowObject(key, itemIds, itemLabels, value, formattedValue); // Bar/Pie Theme String rowid="Row1"; String location = "New Jersey"; String locationLabel = "The Garden State"; String itemIds[] = new String[]{"Item1", "Item2", "Item3", "Item4"}; String itemLabels[] = new String[]{"IPod Sales", "DVD Sales", "TV Sales", "Video Game Sales"}; Double value[] = new Double[]{10000.0, 20000.0, 30000.0, 40000.0}; String formattedValue[] = new String[]{"$10000.0", "$20000.0", "$30000.0", "$40000.0"}; GeoObject key = new GeoObject(rowId, location, locationLabel); GeoRowObject rowObj = new GeoRowObject(key, itemIds, itemLabels, value, formattedValue); // Point Theme String rowid="Row1"; String itemIds[] = new String[]{"Item1"}; String itemLabels[] = new String[]{"Sales"}; String locationLabel = "Example Point"; Double value[] = new Double[]{10000.0}; String formattedValue[] = new String[]{"$10000.0"}; double longitude = -122.0; double latitude = 45.0; GeoObject key = new GeoObject(rowId, locationLabel, longitude, latitude); GeoRowObject rowObj = new GeoRowObject(key, itemIds, itemLabels, value, formattedValue); // Geocoded Point Theme String rowid="Row1"; String itemIds[] = new String[]{"Item1"}; String itemLabels[] = new String[]{"Sales"}; String locationLabel = "Oracle"; String countryCode = "USA"; String address = "500 Oracle Parkway\nRedwood City, CA"; Double value[] = new Double[]{10000.0}; String formattedValue[] = new String[]{"$10000.0"}; GeocodedObject geoAddress = new GeocodedObject(locationLabel, rowId, countryCode, address); GeoRowObject rowObj = new GeoRowObject(geoAddress, itemIds, itemLabels, value, formattedValue); // Add the rows to an ArrayList ArrayList data = new ArrayList(); data.add(rowObj); data.add(...row2...); // Populating the GeoMapDataModel // Note that each theme must have its own GeoMapDataModel // Do not mix GeoRowObjects configured for different themes together GeoMapDataModel model = new GeoMapDataModel(); model.setWrappedData(data);