Hi Rakshit and thanks Michael for putting me in the loop.

Actually Jody wrote the font part for the uDig project, I just did the
job in pasting and adapting it here :)

Have a look at the org.geotools.swt.styling.simple.LabelViewer class.
Everything you need happens inside the method:
public TextSymbolizer get( StyleBuilder build )

Cheers,
Andrea


On Tue, Mar 6, 2012 at 7:21 AM, Rakshit Majithiya
<[email protected]> wrote:
> Hello Andrea  !
>
> As you've suggested, I have tried the way to implement the TextSymbolizer
> with fill of my choice.. Here is a way I followed..
>
>         Stroke stroke = sf.createStroke(
>                 ff.literal(Color.BLUE),
>                 ff.literal(1),
>                 ff.literal(0.5));
>
>         // create a partial opaque fill
>         Fill fill = sf.createFill(
>                 ff.literal(Color.YELLOW),
>                 ff.literal(0.5));
>
>         /*
>          * Setting the geometryPropertyName arg to null signals that we want
> to
>          * draw the default geomettry of features
>          */
>         PolygonSymbolizer sym = sf.createPolygonSymbolizer(stroke, fill,
> null);
>
>         TextSymbolizer text = sf.createTextSymbolizer();
>         Fill textFill = sf.createFill(
>         ff.literal(Color.YELLOW),
>              ff.literal(1.0));
>
>         text.setFill(textFill);
>
>         Rule rule = sf.createRule();
>         rule.symbolizers().add(sym);
>         rule.symbolizers().add(text);
>         FeatureTypeStyle fts = sf.createFeatureTypeStyle(new Rule[]{rule});
>         style.featureTypeStyles().add(fts);
>
> but unfortunately, it works with fill and stroke, but doesn't work with
> text.
> Am I missing anything ??
>
> thanks,
> ________________________________
> Best regards,
> Rakshit Majithiya
> Techno geek, Web Developer,Code Lover
> email : [email protected]
> blog : http://thetechtime.com
> skype : rakshit.majithiya
>
> ________________________________
> From: Andrea Aime <[email protected]>
> To: Rakshit Majithiya <[email protected]>
> Cc: Geotools Mailing List <[email protected]>
> Sent: Friday, 2 March 2012 9:19 PM
> Subject: Re: [Geotools-gt2-users] Change Font Color from Style dialogue
>
> On Fri, Mar 2, 2012 at 4:16 PM, Rakshit Majithiya
> <[email protected]> wrote:
>> Hello all !
>>
>> I am trying to implement a font color feature in "JFontChooser"
>>
>> ( http://svn.osgeo.org/geotools/tags/8.0-M4/modules/unsupported/swing/src/main/java/org/geotools/swing/styling/JFontChooser.java )
>>
>> My main purpose is to change the color of Labels of fields on the layer
>> using
>>
>> JSimpleStyleDialog(http://svn.osgeo.org/geotools/tags/8.0-M4/modules/unsupported/swing/src/main/java/org/geotools/swing/styling/JSimpleStyleDialog.java).
>>
>> In the source code of JFontChooser, the following lines are creating new
>> font
>>
>>     private void createSelectedFont() {
>>         selectedFont = sf.createFont(
>>                 ff.literal(families[familyIndex]),
>>                 ff.literal(styles[styleIndex]),
>>                 ff.literal(weights[weightIndex]),
>>                 ff.literal(String.valueOf(sizes[sizeIndex])));
>>
>>     }
>>
>> using which, I obviously cannot modify the font color.. because color is
>> not
>> property of org.geotools.styling.Font.
>>
>> Is there any way to achieve this goal ?
>
> The color of a TextSymbolizer is not specified in its Font, but as its
> "fill" property
> instead
>
> Cheers
> Andrea
>
>
> --
> -------------------------------------------------------
> Ing. Andrea Aime
> GeoSolutions S.A.S.
> Tech lead
>
> Via Poggio alle Viti 1187
> 55054  Massarosa (LU)
> Italy
>
> phone: +39 0584 962313
> fax:      +39 0584 962313
> mob:    +39 339 8844549
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://www.youtube.com/user/GeoSolutionsIT
> http://www.linkedin.com/in/andreaaime
> http://twitter.com/geowolf
>
> -------------------------------------------------------
>
>
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to