Re: [OpenMap Users] Labelling

From: Don Dietrick <dietrick_at_bbn.com>
Date: Fri, 3 Mar 2006 08:35:39 -0500

Hi Dave,

On Mar 2, 2006, at 9:57 AM, Dave Brown wrote:

> Hi thanks for the info Don,
>
> Can you tell me where that code should go ? I'm confused by the
> concept of
> OMGraphics, I thought there was an OMGraphic object per line or
> point etc..

There can be an OMGraphicList for an entry, representing a multi-part
geometry.

> But my code doesnít even detect a single OMGraphic..
> Right after loading the shapefile I am using this
>
> if (shapeLayer.getList()!= null && !shapeLayer.getList().isEmpty()) {
> System.out.println("getting list elements
> "+shapeLayer.getList().size());
> OMGraphic elem = (OMGraphic)
> shapeLayer.getList().getOMGraphicAt(0);
> elem.putAttribute(OMGraphicConstants.LABEL, new
> OMTextLabeler
> ("street name "));
> System.out.println(elem.toString());
> }
>
> However the shapeLayer.getList() returns null everytime so itís a bit
> baffling to me.

Does the ShapeLayer have a projection to work with? The ShapeLayer's
SpatialIndex uses a projection to determine what shapes to retrieve
from the shape file. How are you loading the Shape file? Just
telling the ShapeLayer the name doesn't do it. Look at the prepare()
method, which is where you probably want to do this stuff.

> Also can you tell me if its possible to override the line painting
> code,
> what I want to do is first check the type of road that is being
> painted,
> according to a field in my dbf. And then give it a specific
> thickness/color
> etc...

You don't want to do this work in the paint thread. Do the work in
the prepare() method, and then set the Stroke and fill/line paint on
the OMGraphic based on the attribute values. The painting will take
care of itself after that.

- Don


>
> -----Original Message-----
> From: Don Dietrick [mailto:dietrick_at_bbn.com]
> Sent: Wednesday, March 01, 2006 10:55 PM
> To: Dave Brown
> Cc: 'openmap questions'
> Subject: Re: [OpenMap Users] Labelling
>
> Hi Dave,
>
> On Feb 28, 2006, at 4:54 AM, Dave Brown wrote:
>
>> Can anyone explain to me the method I would use to render Labels on a
>> street shapefile I have.
>
> The easiest thing to do now is to set an OMTextLabeler as an
> attribute on
> each OMGraphic:
>
> OMGraphic.putAttribute(OMGraphicConstants.LABEL, new OMTextLabeler
> ("street
> name"));
>
> The labels will be rendered automatically. If you want special
> behavior,
> like scale filtering, you could substitute an extended
> OMTextLabeler that
> will only paint if the scale is a certain value, or something like
> that.
>
> The order of the rows in the DBF match the order of the shapes out
> of the
> shape file. If you use the ShapeLayer, you can ask the OMGraphics
> for their
> index (row number) in the app object. There's an off by one thing
> going on
> here, though, so be careful. I keep forgetting which one starts at
> 1 and
> which starts at 0. I think the index numbers in the OMGraphics
> start at 1.
>
>>
>> There is a specific column in the DBF which I wish to use as the
>> label.
>>
>> Also, 'while I'm here.. ' Re' Routing.. How can openmap take
>> into
>> consideration the direction of a particular road, whether its oneway
>> or not
>> when route calculating ? The direction indicator in my case also
>> comes
>> from the accompanying DBF for the shapefile.
>
> I'll have to check on this, but I can't see anything in the code that
> handles one way streets.
>
> - Don
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 268.1.1/271 - Release Date:
> 28/02/2006
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 268.1.1/271 - Release Date:
> 28/02/2006
>
>
>
> --
> [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 Fri Mar 03 2006 - 08:36:58 EST

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