문제

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