How To Produce Colored Map Based On Some Values
سؤال
I have a shape file, a simple a map of countries that I need to display on screen, but each country needs to be a specific color. Say I have an int
variable named HKDensity = 21
, then if a value of 21 is red, the color of the Hongkong polygon should be red.
This is for a school assignment in Java Swing, any help, hints examples is greatly appreciated. Thanks.
المحلول
Have a look at the GeoTools Style tutorial for details of how to display a shapefile and colour in the polygons. The tutorial only shows how to produce a single colour but you should be able to work out how to create a variable colour fill with out too much difficulty.
نصائح أخرى
Color colour = new Color(/*r*/ density / MAX_DENSITY, /*g*/ density / MAX_DENSITY, /*b*/ density / MAX_DENSITY);
or something.
لا تنتمي إلى StackOverflow