Java JMapViewer: How can I change the color of a MapPolygon? -
i'm creating application drawing pollution information on jmapviewer. want mappolygons, didn't find documentation it. succeeded create new mappolygons this:
private mappolygon getpolygon(double lat, double lon, color col){ list<coordinate> coords = new arraylist<>(); //add points list... mappolygon poly = new mappolygonimpl(coords); return poly; }
i'm wondering how change color , remove border of mappolygon. there no function setcolor or such...
i tried directly constructor, doesn't work:
mappolygon poly = new mappolygonimpl(coords, color.red, new basicstroke(0));
does know how can change color of mappolygon? thanks!
because mappolygonimpl
extends mapobjectimpl
, mappolygonimpl
inherits setcolor()
, setbackcolor()
mapobjectimpl
. mappolygonimpl
uses these colors in implementation of paint()
. colors stored in parent class's style
attribute, initialized calling getdefaultstyle()
during construction.
you can vary alpha component of chosen color
achieve variety of effects; example below uses 12.5% light gray.
mappolygonimpl poly = new mappolygonimpl(coords); color color = new color(0x20202020, true); poly.setcolor(color); poly.setbackcolor(color); poly.setstroke(new basicstroke(0)); map.addmappolygon(poly);
if existing color satisfactory, similar effect may achieved setting color background color.
mappolygonimpl poly = new mappolygonimpl(route); poly.setcolor(poly.getbackcolor());
Comments
Post a Comment