Hi,
I put together a method that displays the properties set for a Style.
The only way that I could see to do this was to:
Style as method parameter and base
iterate: ArrayList of FeatureTypeStyle
iterate: ArrayList of rules
iterate: ArrayList of symbolizers
check: for proper symbolizer implementation
display field settings
If there is a cleaner way to do this let me know. I have my reasons for needing to do this :-). I have not integrated Point or Line yet but will and post on forum after clean up. I figured this was a good place to start. The following is my code:
public void displayStyleProperties(Style style){
ArrayList ftsList = (ArrayList)style.featureTypeStyles();
ListIterator i = ftsList.listIterator();
while(i.hasNext()){
FeatureTypeStyle ftStyle = (FeatureTypeStyle)i.next();
ArrayList rList = (ArrayList)ftStyle.rules();
ListIterator j = rList.listIterator();
while(j.hasNext()){
Rule ruleo = (Rule)j.next();
ArrayList symList = (ArrayList)ruleo.symbolizers();
ListIterator s = symList.listIterator();
while(s.hasNext()){
Object ts=(Object)s.next();
System.out.println("++"+ts.getClass().getName()+"++\n");
if(ts.getClass().getName()=="org.geotools.styling.PolygonSymbolizerImpl"){
PolygonSymbolizer polySym = (PolygonSymbolizer)ts;
Fill fill = polySym.getFill();
System.out.println("fill color: "+fill.getColor());
Stroke stroke = polySym.getStroke();
System.out.println("stroke color: "+stroke.getColor());
} //end PolySymbolizerImpl if
if(ts.getClass().getName()=="org.geotools.styling.TextSymbolizerImpl"){
TextSymbolizer tsym = (TextSymbolizer)ts;
Font font = tsym.getFont();
System.out.println("family: "+font.getFamily());
System.out.println("size: "+font.getSize());
System.out.println("style: "+font.getStyle());
System.out.println("weight: "+font.getWeight());
Fill fill = tsym.getFill();
System.out.println("color: "+fill.getColor());
System.out.println("labelName: "+tsym.getLabel());
PointPlacement labelPlacement = (PointPlacement)tsym.getLabelPlacement();
AnchorPoint anchorPoint = labelPlacement.getAnchorPoint();
System.out.println("anchor.X: "+anchorPoint.getAnchorPointX()+
" anchor.Y: "+anchorPoint.getAnchorPointY());
Displacement displacement = (Displacement)labelPlacement.getDisplacement();
System.out.println("displacement.X: "+displacement.getDisplacementX()+
" displacement.Y: "+displacement.getDisplacementY());
} //end TextSymbolizerImpl if
} //end symbolizers symList loop
} //end rule rList loop
} //end featureTypeStyle ftsList loop
}
------------------------------------------------------------------------------
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