I found how to do it:
text.setLabelPlacement(sb.createPointPlacement(0.5, 0.0, 0.0));
It's still another deprecated method (setLabelPlacement), but there is
a way to avoid it :
StyleBuilder sb = new StyleBuilder();
org.geotools.styling.Font[] fontArray = {sb.createFont(new
Font("sansserif", Font.PLAIN, 12))};
TextSymbolizer text = sb.createTextSymbolizer(null,
fontArray,
null,
sb.attributeExpression("depth"),
sb.createPointPlacement(0.5, 0.0, 0.0),
"");
Le 24 févr. 09 à 14:36, Benoît Thiébault a écrit :
> Thanks Andrea,
>
> I did not try to set my AnchorX to 0.5.
> How do you do it ? I couldn't find any documentation to access the
> anchor point of a TextSymbolizer.
>
> Regarding the new function, I will give it a try and let you know.
>
> Benoît
>
> Le 24 févr. 09 à 14:03, Andrea Aime a écrit :
>
>> Jody Garnett wrote:
>>> Okay cool; so have you tried the text symbolizer offset yet?
>>> Setting an offset should allow you to draw above or below the line.
>>> There is also a rendering hint that can be used to make the text
>>> follow the line; I am not sure if that only changes orientation or
>>> if it also would calculate an offset?
>>
>> Follow line hint only helps if you need your text to follow the shape
>> of a curved line, no help here.
>>
>> Benoit, are you sure you set your AnchorX to 0.5? That's all you
>> should
>> need to get you centering. If not, please create a bug report on
>> jira.codehaus.org with a reproducable program that I can run to
>> replicate and fix the bug.
>>
>> For formatting text to 2 decimals we'd need a formatting filter
>> function, something that you could call like this:
>>
>> <Function name="numberFormat">
>> <PropertyName>myAtt</PropertyName>
>> <Literal>###.##</Literal>
>> </Function>
>>
>> to specify which attribute to use, and which pattern to use,
>> respectively. As far as I remember there is no such a function,
>> but it's not hard to make one, just have a look at the filter
>> functions contained in the main module (e.g,
>> FilterFunction_strLength),
>> and their SPI registration in META-INF/services (to have GeoTools
>> recognize them as plugins and thus don't throw and exception when
>> you try to create an instance of your function using the filter
>> factory).
>>
>> Oh, if you make that one, it's kind of general use, so consider
>> contributing it back.
>>
>> Cheers
>> Andrea
>>
>
> Benoît Thiébault
>
> Société Artenum
> 24 rue Louis Blanc, 75010 Paris
> tel: +33 (0)1 46 94 67 54
>
> Artenum - Science & Groupware - http://www.artenum.com
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San
> Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source
> code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
Benoît Thiébault
Société Artenum
24 rue Louis Blanc, 75010 Paris
tel: +33 (0)1 46 94 67 54
Artenum - Science & Groupware - http://www.artenum.com
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users