Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Positioning text with LabelPlacement

Cory Horner wrote:
>tony.roth@xxxxxx wrote:
>> Hi list,
>> two questions about putting text to a feature in the map:
>>
>> i) I'm using a Textsymbolizer object, which is positioned by a
>> LabelPlacement. The problem is, that the position is fixed and
>> independet from the position of the object in the map. Sometimes it
>is
>> near the left or right edge of the map and the text is
>> truncated especially if you have long attribute values. I can
>calculate
>> the position of the Textsymbolizer depending on text length and
>relative
>> position to the viewpane but ... no.
>> Is it somehow possible in UDIG to generate a "floating"
>Textsymbolizer
>> object which is positioned by the Rendermanager?
>
>Tony, this doesn't sound right. What geometry type are your
>features,
>and what SLD snippet are you using? Usually text is positioned as a
>proportion of the text length, with 0 being right-aligned, 1 being
>left-aligned, and 0.5 being the midpoint (for points at least).
>Offsets
>can also be applied.
geometry type is point
 
double horiz = 0;
double vert = 2;
double rotation = =;
LabelPlacement placement = myStyleBuilder.createPointPlacement(horiz,vert,rotation);
Fill fill = myStyleBuilder.createFill(new Color(0,0,0));
_expression_ attributeExpression = myStyleBuilder.createAttributeExpression(attributeName);
Font font = myStyleBuilder.createFont("Arial",false,true,16);
TextSymbolizer text = myStyleBuilder.createTextSymbolizer(fill,new Font[]{font},null,attributeExpression,placement,null));
 
the text is positioned below the point, starting exactly on the same longitude. I would call it left-aligned. Points near the right edge of the map don't show their label. I guess the renderer (?) avoids showing truncated text.
 

>> ii) In the project I'm involved in, we use the Textsymbolizer to
>inform
>> the user about certain feature attributes. More convenient for the
>user
>> would be something like an onmouseover effect which opens a tool
>tipp if
>> the mouse position is next to a feature (of a certain layer). Is
>> something like this existing in Udig itself or in related
>projects?
>
>This doesn't exist -- a good idea though! When should the tool tip
>appear? Only when a certain tool is selected (like the info tool), or
>anything? (the latter being more difficult)
 
In my special case it would be fine if one (the user or hard-coded) can switch on this feature and then it works generally even if you pan or zoom. But of course it would be enough that you have a tool like the info tool. In google maps it's not really an onmouseover effect, you have to click in the map on a link (but the curser shows that there is a link).
 
tony roth
 
INVALID HTML

Back to the top