I'm creating an application for drawing pollution information on a JMapViewer. I want to do this with MapPolygons, but I didn't find a good documentation about it. I succeeded to create new MapPolygons like this:
private MapPolygon getPolygon(double lat, double lon, Color col){
List<Coordinate> coords = new ArrayList<>();
//add all points to the list...
MapPolygon poly = new MapPolygonImpl(coords);
return poly;
}
I'm wondering how I could change the color and remove the border of the MapPolygon. There is no function setColor or such...
I tried directly with the constructor, but this doesn't work:
MapPolygon poly = new MapPolygonImpl(coords, Color.RED, new BasicStroke(0));
Does anybody know how I can change the color of the MapPolygon? Thanks!
Found it out. You have to create a layer and a style:
Because
MapPolygonImpl
extendsMapObjectImpl
,MapPolygonImpl
inheritssetColor()
andsetBackColor()
fromMapObjectImpl
.MapPolygonImpl
uses these colors in its implementation ofpaint()
. The colors are stored in the parent class'sStyle
attribute, initialized by callinggetDefaultStyle()
during construction.You can vary the alpha component of the chosen
Color
to achieve a variety of effects; the example below uses a 12.5% light gray.If the existing color is satisfactory, a similar effect may be achieved by setting the color to the background color.