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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top