example point with text:

StyleBuilder sb = new StyleBuilder();
                    TextSymbolizer textSymbolizer =
sb.createTextSymbolizer(sb.createFill(Color.BLACK),
                        new Font[] { sb.createFont("Lucida Sans", 10),
sb.createFont("Arial", 10) },
                        sb.createHalo(), sb.attributeExpression("name"), null,
null);
                    
                    
                    Mark circle = sb.createMark(StyleBuilder.MARK_SQUARE, 
Color.GREEN);
                    Graphic graph2 = sb.createGraphic(null, circle, null, 1, 4, 
0);
                    
                    PointSymbolizer pointSymbolizer = 
sb.createPointSymbolizer(graph2);
                    
                    FeatureTypeStyle fts = 
sb.createFeatureTypeStyle("labelPointFeature",
                        new Symbolizer[] { textSymbolizer, pointSymbolizer });

                    
                    style.addFeatureTypeStyle(fts);

                   Coordinate coordinate =  new
Coordinate(Double.valueOf("12").doubleValue(),  
Double.valueOf("14").doubleValue());
                    Point point = geomFac.createPoint(coordinate);

AttributeType[] typesNew = new AttributeType[2];
                     typesNew[0] = 
AttributeTypeFactory.newAttributeType("coolection",
point.getClass()
                                                , false, 0, null, 
DefaultGeographicCRS.WGS84);

                     typesNew[1] = AttributeTypeFactory.newAttributeType("name",
String.class);
                    FeatureType pointType = 
FeatureTypes.newFeatureType(typesNew,
"labelPointFeature");
                    
                    Feature pointFeature = pointType
                                .create(new Object[] { point,"2.1"});









gederer wrote:
> 
> Hi,
> 
> I am new to GeoTools.  I need to render point features in a JMapPane 
> with each point represented by a dot with some adjacent text (the value 
> of a feature attribute).  I can render the dots using:
> 
>   private static Style createPointStyle()
>   {
>     Style style;
>     PointSymbolizer symbolizer = styleFactory.createPointSymbolizer();
>     symbolizer.getGraphic().setSize(filterFactory.literal(1));
>     Rule rule = styleFactory.createRule();
>     rule.setSymbolizers(new Symbolizer[]
>                         {
>                           symbolizer
>                         });
>     FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
>     fts.setRules(new Rule[]
>                  {
>                    rule
>                  });
>     style = styleFactory.createStyle();
>     style.addFeatureTypeStyle(fts);
>     return style;
>   }
> 
> or
> 
>   public Style createStyleFromScratch()
>   {
> 
>     /* Point style from scratch */
>     StyleBuilder builder = new StyleBuilder();
>     Mark mark = builder.createMark("circle", Color.RED);
>     Graphic g = builder.createGraphic(null, mark, null);
>     Symbolizer s = builder.createPointSymbolizer(g);
> 
>     Style memStyle = builder.createStyle(s);
>    
>     return memStyle;
> 
>   }
> 
> I've been experimenting with both TextMark and TextSymbolizer without 
> success.  Does anyone know how to do it?
> 
> Thanks!
> 
> Greg
> 
> -- 
> | E R G O N O S I S
> | Greg Ederer
> | Lead Developer
> | [EMAIL PROTECTED]
> | 360.774.6848
> |
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft 
> Defy all challenges. Microsoft(R) Visual Studio 2008. 
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-render-point-feature-with-text-label-tp17220390p17231207.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to