Style Layer Descriptor

The gt-main module provides interfaces for the Style Layer Descriptor data structure and offers GeoTools specific extensions to the Symbology Encoding data structure.


SLD Utility Class

The SLD utility class is used to perform common operations on Style objects. This is the class you can used when you “just” want to hack away at an existing Style object for a test case.

  • Changing the Colors

    Utility methods exits to change the “first” symbolizer found in the Style:

    SLD.setLineColour(style, Color.BLUE );
    SLD.setPolyColour(style, Color.RED );
  • You can also perform these kinds of changes on individual symbolizers:

    SLD.setLineColour( lineSymbolizer, Color.BLUE );
    SLD.setPolyColour( polygonSymbolizer, Color.RED );
  • You can combine this approach with a StyleVisitor to edit the colors for specific rules:

    DuplicatingStyleVisitor repaint = new DuplicatingStyleVisitor(){
       boolean flag=false;
       public void visit(Rule rule){
            super.visit( rule ); // makes a copy
       public void visit(PolygonSymbolizer polygonSymbolizer){
            super.visit( rule ); // makes a copy
            if( flag ){
                PolygonSymbolizer copy = getObject(); // the copy just made
                SLD.setPolyColour( copy, Color.RED );
    style.accepts( repaint ):
    Style modified = (Style) repaint.getObject();


This utility class originated as part of the uDig application.