Style Lab: mark.setSize(filterFactory.literal(3)); not working?

4 messages Options
Embed this post
Permalink
Oliver Gottwald

Style Lab: mark.setSize(filterFactory.literal(3)); not working?

Reply Threaded More More options
Print post
Permalink

Hi,

I'm working on integrating the Style Lab(Creating styles programmatically) createPointStyle() method into one of my examples.

For some reason the mark.setSize(filterFactory.literal(3)); looks like it is not taking effect.

I change the filterFactory.literal(X) above and nothing happens.

I'm using the method in the lab exactly as is.  Am I missing something??

Any feedback would be greatly appreciated.

Oliver


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Style Lab: mark.setSize(filterFactory.literal(3)); not working?

Reply Threaded More More options
Print post
Permalink
Hi Oliver,

This looks like my fault :(

The createPointStyle method should set the size of the graphic rather
than the mark like this...

        Graphic gr = styleFactory.createDefaultGraphic();

        Mark mark = styleFactory.getCircleMark();

        mark.setStroke(styleFactory.createStroke(
                filterFactory.literal(Color.BLUE), filterFactory.literal(1)));

        mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN)));

        gr.graphicalSymbols().clear();
        gr.graphicalSymbols().add(mark);
        gr.setSize(filterFactory.literal(size));

I've just updated the StyleLab code but the web page won't refresh for
a bit. Meanwhile, please try the approach above and see if that gets
things working for you.

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Oliver Gottwald

Re: Style Lab: mark.setSize(filterFactory.literal(3)); not working?

Reply Threaded More More options
Print post
Permalink
Michael,

ah cool....
Yes that fixed the problem.  At first I set the value to

gr.setSize(filterFactory.literal(1));

and the point was just a dot
at 3 i could see the border and inner color.

I put a working LineString example out on the forum this morning as
well.  Any input on how to make it more flexible/efficient/better would
be greatly appreciated.  I also applied the same concept for a Point and
LineString to a Polygon with good results(Not posted on forum yet).

By the way if I wanted to add a Label to the point for the code snipped
below do you have an example for that possibly or could you point me in
the right direction?  Labels are on my hit list for tomorrow.

Oliver


Michael Bedward wrote:

> Hi Oliver,
>
> This looks like my fault :(
>
> The createPointStyle method should set the size of the graphic rather
> than the mark like this...
>
>         Graphic gr = styleFactory.createDefaultGraphic();
>
>         Mark mark = styleFactory.getCircleMark();
>
>         mark.setStroke(styleFactory.createStroke(
>                 filterFactory.literal(Color.BLUE), filterFactory.literal(1)));
>
>         mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN)));
>
>         gr.graphicalSymbols().clear();
>         gr.graphicalSymbols().add(mark);
>         gr.setSize(filterFactory.literal(size));
>
> I've just updated the StyleLab code but the web page won't refresh for
> a bit. Meanwhile, please try the approach above and see if that gets
> things working for you.
>
> Michael
>
>  

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Style Lab: mark.setSize(filterFactory.literal(3)); not working?

Reply Threaded More More options
Print post
Permalink
2009/10/23 Oliver Gottwald wrote:
> By the way if I wanted to add a Label to the point for the code snipped
> below do you have an example for that possibly or could you point me in
> the right direction?  Labels are on my hit list for tomorrow.
>

Labelling features involves including a TextSymbolizer in your Style
along with PointSymbolizer (or whatever).

Some options for doing it programmatically (there are others too)...

1. Really cheat and use JSimpleStyleDialog which gives the option of
adding labels...

SimpleFeatureType TYPE = ...
Style = JSimpleStyleDialog.showDialog(null, TYPE);

2. Cheat just a little bit and use the SLD utility class...

Color lineColor = ...
Color fillColor = ...
float opacity = 1.0f;
float size = 5.0f;
String labelAttribute = "name";
Font font = styleFactory.getDefaultFont();
Style = SLD.createPointStyle("Circle", lineColor, fillColor, opacity,
size, labelAttribute, font);

3. Spurn easy solutions and do it all by hand...

StyleFactory sf = ...
FilterFactory ff = ...

String symbolName = "Circle";  // or Cross, Square, X, Triangle, Star
Color lineColor = ...
float lineWidth = ...
Color fillColor = ...
float opacity = ..
float size = ..
String labelAttribute = "name";
Font font = sf.getDefaultFont();

Stroke stroke = sf.createStroke(ff.literal(lineColor), ff.literal(lineWidth));
Fill fill = sf.createFill(ff.literal(fillColor), ff.literal(opacity));

Mark mark = sf.createMark(ff.literal(symbolName), stroke, fill,
ff.literal(size), ff.literal(0));

Graphic graphic = sf.createDefaultGraphic();
graphic.graphicalSymbols().clear();
graphic.graphicalSymbols().add(mark);
graphic.setSize(ff.literal(size));

PointSymbolizer pointSym = sf.createPointSymbolizer(graphic, null);

Fill labelFill = sf.createFill(ff.literal(Color.BLACK));
AnchorPoint anchor = sf.createAnchorPoint(ff.literal(0.5), ff.literal(0.0));
Displacement disp = sf.createDisplacement(ff.literal(0), ff.literal(size));
LabelPlacement placement = sf.createPointPlacement(anchor, disp, ff.literal(0));

TextSymbolizer textSym = sf.createTextSymbolizer(
        labelFill, new Font[]{font}, null, ff.property(labelField),
placement, null);

Rule rule = sf.createRule();
rule.symbolizers().add( pointSym );
rule.symbolizers().add( textSym );

FeatureTypeStyle fts = sf.createFeatureTypeStyle(new Rule[] {rule});
Style style = sf.createStyle();
style.featureTypeStyles().add(fts);

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users