[Geoserver-devel] Puzzled trying to add GetLegendGraphic sample text for TextSymbolizer

Hey Andrea,

lets see if you have some clue.

as per <http://jira.codehaus.org/browse/GEOS-1622&gt;, I'm trying to render a
sample text (say, a single letter) on top of the legend graphic when there's
a text symbolizer in a rule.

Problem is, DefaultRasterLegendProducer uses a StyledShapePainter directly to
render the sample geometry, but has no idea about how to render text.
What I'm trying to do is, if a rule has a TextSymbolizer, use a clone whose
label is a Literal expression. In the following code I've added the
first "if", but the call to shapePainter.paint(...) does nothing. It doesn't
have any treatment of TextStyles. So I wonder if you know of another way to
easily draw the sample text?

--------
if(symbolizer instanceof TextSymbolizer){
    TextSymbolizer textSym = (TextSymbolizer)symbolizer;
    StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null);
    TextSymbolizer textSymbolizer = styleFactory.createTextSymbolizer();
    textSymbolizer.setFill(textSym.getFill());
    textSymbolizer.setFonts(textSym.getFonts());
    textSymbolizer.setHalo(textSym.getHalo());
    
textSymbolizer.setLabel(CommonFactoryFinder.getFilterFactory(null).literal("T"));
    textSymbolizer.setPlacement(textSym.getPlacement());
    textSymbolizer.setPriority(textSym.getPriority());
    symbolizer = textSymbolizer;
}
Style2D style2d = styleFactory.createStyle(sampleFeature, symbolizer,
scaleRange);
LiteShape2 shape = getSampleShape(symbolizer, w, h);

if (style2d != null) {
    shapePainter.paint(graphics, shape, style2d, scaleDenominator);
}
--------

Gabriel