Re: dynamic selection of colors, country wise

From: Don Dietrick <dietrick@bbn.com>
Date: Mon May 07 2001 - 14:15:20 EDT

Hi Selva,

You'll need to get a shape file containing all the world's countries.
You'll need to convert the dbf file to a CSV file, and then use the
com.bbn.openmap.layer.shape.areas package to display the data. To color
the countries individally, you'll need to modify the properties for the
AreaShapeLayer so that the CSV file information is used to figure out
which graphics in the shape file belong to which country.

For instance, I have a time zone file that someone sent in (WrldTZA.shp,
with its CSV file I created WRLDTZA.csv). It lists the countries of the
world, but also the time zones they belong in. A sample of the CSV
file:

FIPS,NAME,COMMENTS,REGION,LAT,LON,TZ,GMTOFF,LOCALSUM,OFFSET,CLASSES
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Greenland,,,0.00000,0.00000,,,-2,-3,Countries
,Canada,,,0.00000,0.00000,,,,-6,Countries
,Canada,,,0.00000,0.00000,,,,-5,Countries
etc.....

To get the AreaShapeLayer to display different colors for each time
zone, I set up the following properties

tz.class=com.bbn.openmap.layer.shape.areas.AreaShapeLayer
tz.prettyName=Time Zones
tz.shapeFile=/usr/local/openmap/data/shape/timezone/WrldTZA.shp
tz.spatialIndex=/usr/local/openmap/data/shape/timezone/WrldTZA.ssx
tz.csvFile=/usr/local/openmap/data/shape/timezone/WRLDTZA.csv
tz.fillColor=ffCCCCCC
tz.keyIndex=9
tz.nameIndex=9
tz.areas=-11 -10 -9 -8 -7 -6 -5 -4 -3.5 -3 -2 -1 0 +1 +2 +3 +3.5 +4 +4.5
+5 +5.5 +6 +6.5 +7 +8 +9 + 9.5 +10 + 10.5 +11 +11.5
tz.areas.-11.fillColor=ffCCCC66
tz.areas.-10.fillColor=ff66CCCC
tz.areas.-9.fillColor=ffFFFFCC
tz.areas.-8.fillColor=ffCC6600
tz.areas.-7.fillColor=ff99CC66
tz.areas.-6.fillColor=ff3399CC
tz.areas.-5.fillColor=ffFF9999
tz.areas.-4.fillColor=ffCCCCFF
tz.areas.-3.5.fillColor=ffFF6699
tz.areas.-3.fillColor=ffCCCC66
tz.areas.-2.fillColor=ff66CCCC
tz.areas.-1.fillColor=ffFFFFCC
tz.areas.0.fillColor=ffCC6600
tz.areas.+1.fillColor=ff99CC66
tz.areas.+2.fillColor=ff3399CC
tz.areas.+3.fillColor=ffFF9999
tz.areas.+3.5.fillColor=ffCCCCFF
tz.areas.+4.fillColor=ffFF6699
tz.areas.+4.5.fillColor=ffCCCC66
tz.areas.+5.fillColor=ff66CCCC
tz.areas.+5.5.fillColor=ffFFFFCC
tz.areas.+6.fillColor=ffCC6600
tz.areas.+6.5.fillColor=ff99CC66
tz.areas.+7.fillColor=ff3399CC
tz.areas.+8.fillColor=ffFF999
tz.areas.+9.fillColor=ffCCCCFF
tz.areas.+9.5.fillColor=ffFF6699
tz.areas.+10.fillColor=ffCCCC66
tz.areas.+10.5.fillColor=ff66CCCC
tz.areas.+11.fillColor=ffFFFFCC
tz.areas.+11.5.fillColor=ffCC6600

You can do something similar with your country file, or if the actual
color selection for each color doesn't matter, you can extend the
AreaShapeLayer to just set a randomly generated color for each country
when the country gets displayed.

If you want to set the colors dynamically, you'll have to write the code
to do that. The DrawingAttributes object that is used to keep track of
the colors for each country has a GUI associated with it (getGUI()).
You just have to tie in your interface with the DrawingAttributes object
for the country you want to change (palette interface, mouse click on
the map, etc.)

Hope this helps,

Don

Selvaraj Balasubramaniam wrote:
>
> Hi all,
> Iam new to OpenMap tool, my requirement is to show the
> world map with different colors for different
> countries. Also i should be able to select the colors
> dyanamically.
>
> Can anyone help me.
> Thanks in advance
> Selva
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
>
> --
> [To unsubscribe to this list send an email to "majdart@bbn.com"
> with the following text in the BODY of the message "unsubscribe openmap-users"]

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Donald Dietrick  dietrick@bbn.com (617)873-3031 [FAX]4328
BBN Technologies, 10 Moulton Street, Cambridge, MA 02138
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon May 7 14:13:01 2001

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:31 EDT