private void setStylingElements( TextSymbolizer symbolizer ) {
Color fontFill = SLDs.textFontFill(symbolizer);
FontData[] tempFD = SLDs.textFont(symbolizer);
Expression label = SLDs.textLabel(symbolizer);
if (fontFill == null) {
fontFill = SymbolizerContent.DEFAULT_FONT_COLOR;
}
labelFont.setColorValue(
new RGB(fontFill.getRed(), fontFill.getGreen(), fontFill.getBlue()));
if (tempFD == null) {
tempFD = new FontData[1];
tempFD[0] = new FontData(SymbolizerContent.DEFAULT_FONT_FACE,
SymbolizerContent.DEFAULT_FONT_SIZE,
SymbolizerContent.DEFAULT_FONT_STYLE);
}
labelFont.setFontList(tempFD);
// Need to get all available labels
//check if this layer has a feature
Layer currLayer = getLayer();
List<AttributeDescriptor> attributeList = null;
AttributeDescriptor defaultGeom = null;
if (currLayer.hasResource(FeatureSource.class)) {
SimpleFeatureType ft = currLayer.getSchema();
attributeList = ft.getAttributeDescriptors();
defaultGeom=ft.getGeometryDescriptor();
}
labelCombo.removeAll();
if (attributeList != null) {
for( int i = 0; i < attributeList.size(); i++ ) {
AttributeDescriptor attributeDescriptor = attributeList.get(i);
if( attributeDescriptor != defaultGeom )
labelCombo.add(attributeDescriptor.getName().getLocalPart());
if( label != null && attributeDescriptor != null &&
attributeDescriptor.getName().equals(label.toString()) ) {
//Set the correct initial label
labelCombo.select(i);
} else if( i == 0 ) {
labelCombo.select(i);
}