Re: [OpenMap Users] Location color on locationlayer not working

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Mon, 5 Dec 2011 17:08:17 -0500

Hi Eric,

There's a bit of a disconnect here, it might be a flaw in the design
of the BasicLocation object. Location objects extend from
OMGraphicAdapter, which means they can be managed by a LocationHandler
or OMGraphicHandlerLayer like any OMGraphic. They really are a
container for two other OMGraphics, a marker and a label. You can ask
the Location for the marker or the label and set the colors on those
parts individually. You could argue that calling setColor/setPaint on
the Location should call that method on the marker and the label, and
I'd probably agree, but it doesn't right now. So that explains why
the Color.RED setting isn't taking hold.

For when you set the line color to Green, the setLineColor() method
there is setting the value on a DrawingAttributes object being held
for you for when you respond to the get method call. You can set all
the different rendering attributes on that DrawingAttributes object,
and then in get() make this call:

locationDrawingAttributes.setTo(location.getLocationMarker());

and it will set those values on that location marker OMGraphic.
Another benefit of doing things this way is that the
locationDrawingAttributes settings can be modified in the properties
file settings for the layer. The javadocs for the handler have more
details and I think an example.

Hope this helps,

Don


On Sun, Dec 4, 2011 at 5:06 PM, Eric Chatellier
<chatellier_at_codelutin.com> wrote:
> Hi,
>
> I'm using an locationLayer with a custom LocationHandler to
> put dynamic objects on a map.
>
> Here is my code :
>
> HaulLocationHandler locationHandler = new HaulLocationHandler(hauls);
> haulLocationLayer = new LocationLayer();
> haulLocationLayer.setLocationHandlers(new LocationHandler[]{locationHandler});
> addMapComponent(haulLocationLayer);
>
> with HaulLocationHandler:
>
> public class HaulLocationHandler extends AbstractLocationHandler {
>
>    public HaulLocationHandler(List<Coordinate> coordinates) {
>        this.coordinates = coordinates;
>        setLocationColor(Color.GREEN);
>        setShowLocations(true);
>    }
>
>    _at_Override
>    public OMGraphicList get(float nwLat, float nwLon, float seLat, float seLon,
> OMGraphicList graphicList) {
>            Location location = new BasicLocation(0.0, 0.0, "test", null);
>            location.setLocationHandler(this);
>            location.setLinePaint(Color.RED);
>            location.setShowName(true);
>            location.setShowLocation(true);
>
>            graphicList.add(location);
>
>        return graphicList;
>    }
> }
>
> I can see location diplayed on map, but a can display it
> in a different color than default black.
>
> In previous code, "setLocationColor(Color.GREEN);" and
> "location.setLinePaint(Color.RED);"
> both don't work.
>
> I've different serie of location to display and i would like to have a different
> color for each series.
>
> Any clue why color won't work ?
>
> Regards.
>
> --
> Éric Chatellier <chatellier_at_codelutin.com>
> Tel: 02.40.50.29.28
> http://www.codelutin.com
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe openmap-users"]

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Dec 05 2011 - 17:10:29 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:10 EDT