Hello,

I think I found an idea from where is coming my problem of opacity.
Maybe from a bad creation of Style, when reading the SLD...

First, I wrote this SLD :

<StyledLayerDescriptor version="0.7.2">
<!-- a named layer is the basic building block of an sld document -->
<NamedLayer>
<Name>A Random Layer</Name>
<title>The title of the layer</title>
<abstract>
A longer and some would say less random peice of text
that allows you to describe the layer in more detail
</abstract>
<!-- with in a layer you have Named Styles -->
<UserStyle xmlns:ogc="http://www.opengis.net";>
    <!-- again they have names, titles and abstracts -->
    <Name>TestStyle</Name>
    <Title>Transparency style</Title>
    <Abstract>A style to test transparency provider</Abstract>


    <FeatureTypeStyle>
        <Name>Des points</Name>
        <Title>Un style pour des points en forme d'étoile</Title>
        <Abstract>Ce style comporte une transparence pour le
remplissage</Abstract>
        <FeatureTypeName>SIMPLE_PLACE</FeatureTypeName>

        <rule>
            <Name>Le point</Name>
            <Title>Point design</Title>

            <PointSymbolizer>
                <graphic>

<geometry><propertyname>the_geom</propertyname></geometry>
                    <mark>
                        <wellknownname>star</wellknownname>
                        <Fill>
                            <CssParameter name="fill">#FF0000</CssParameter>
                            <CssParameter
name="fill-opacity">0.3</CssParameter>
                        </Fill>
                        <Stroke>
                            <CssParameter
name="stroke">#FFC800</CssParameter>
                            <CssParameter
name="stroke-linecap">butt</CssParameter>
                            <CssParameter
name="stroke-linejoin">round</CssParameter>
                            <CssParameter
name="stroke-opacity">1.0</CssParameter>
                            <CssParameter
name="stroke-width">1.0</CssParameter>
                            <CssParameter
name="stroke-dashoffset">0.0</CssParameter>
                        </Stroke>
                    </mark>
                    <Size>80</Size>
                    <Rotation>20.0</Rotation>
                </graphic>
            </PointSymbolizer>
        </rule>
    </FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

And this code :

URL sld = _2_SimplePlace.class.getResource("/resources/test1.xml");
SLDParser parser = new SLDParser(new StyleFactoryImpl());
parser.setInput(sld);
Style ptStyle = parser.readXML()[0];

Symbolizer s =
ptStyle.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];
PointSymbolizer ps = (PointSymbolizer)s;
System.out.println("mark size = "+ ps.getGraphic().getMarks()[0].getSize());
System.out.println("fill opacity = "+
ps.getGraphic().getMarks()[0].getFill().getOpacity());
System.out.println("fill color = "+
ps.getGraphic().getMarks()[0].getFill().getColor());

But when I see my stars, there is no filling in it. Even though, I got this
result on the console :

mark size = 80
fill opacity = 0.3
fill color = #FF0000

So next I tried to add this little piece of code after loading the SLD :

StyleBuilder sb = new StyleBuilder();
Fill fill = sb.createFill(Color.red, 0.3);
ps.getGraphic().getMarks()[0].setFill(fill);

System.out.println("fill opacity = "+
ps.getGraphic().getMarks()[0].getFill().getOpacity());

And with it, this is working fine !!!
And the result on the console is :

mark size = 80
fill opacity = 0.3
fill color = #FF0000
fill opacity = 0.3

So do you think it is really a problem in SLD loader ? If it is, is it
possible to fix it quickly ?
If it is not...what did I do wrong ? ;-)

Thanks,
Thomas
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to