private void createMultipleStyleLegend(StyledLayerDescriptor sld,Map<String,Style> styleMap,StyledLayer selectedStyledLayer){
  List<StyledLayer> styledLayerList=null;
  if (selectedStyledLayer == null) {
    styledLayerList=sld.layers();
  }
 else {
    styledLayerList=new ArrayList<StyledLayer>();
    styledLayerList.add(selectedStyledLayer);
  }
  for (  StyledLayer styledLayer : styledLayerList) {
    List<Style> styleList=null;
    if (styledLayer instanceof NamedLayerImpl) {
      NamedLayerImpl namedLayer=(NamedLayerImpl)styledLayer;
      styleList=namedLayer.styles();
    }
 else     if (styledLayer instanceof UserLayerImpl) {
      UserLayerImpl userLayer=(UserLayerImpl)styledLayer;
      styleList=userLayer.userStyles();
    }
    if (styleList != null) {
      int count=1;
      for (      Style style : styleList) {
        String styleName;
        if (style.getName() != null) {
          styleName=style.getName();
        }
 else {
          styleName=String.format("Style %d",count);
        }
        styleMap.put(styleName,style);
        count++;
      }
    }
  }
}

private void createMultipleStyleLegend ( StyledLayerDescriptor sld , Map < String , Style > styleMap , StyledLayer selectedStyledLayer ) { List < StyledLayer > styledLayerList = null ; if ( selectedStyledLayer == null ) { styledLayerList = sld . layers ( ) ; } else { styledLayerList = new ArrayList < StyledLayer > ( ) ; styledLayerList . add ( selectedStyledLayer ) ; } for ( StyledLayer styledLayer : styledLayerList ) { List < Style > styleList = null ; if ( styledLayer instanceof NamedLayerImpl ) { NamedLayerImpl namedLayer = ( NamedLayerImpl ) styledLayer ; styleList = namedLayer . styles ( ) ; } else if ( styledLayer instanceof UserLayerImpl ) { UserLayerImpl userLayer = ( UserLayerImpl ) styledLayer ; styleList = userLayer . userStyles ( ) ; } if ( styleList != null ) { int count = 1 ; for ( Style style : styleList ) { String styleName ; if ( style . getName ( ) != null ) { styleName = style . getName ( ) ; } else { styleName = String . format ( "Style %d" , count ) ; } styleMap . put ( styleName , style ) ; count ++ ; } } } }
creates the legend for multiple sld styles .
