public static String[] colors(final Rule rule){
  final Set<String> colorSet=new HashSet<String>();
  Color color=null;
  for (  final Symbolizer sym : rule.symbolizers()) {
    if (sym instanceof PolygonSymbolizer) {
      final PolygonSymbolizer symb=(PolygonSymbolizer)sym;
      color=polyFill(symb);
    }
 else     if (sym instanceof LineSymbolizer) {
      final LineSymbolizer symb=(LineSymbolizer)sym;
      color=color(symb);
    }
 else     if (sym instanceof PointSymbolizer) {
      final PointSymbolizer symb=(PointSymbolizer)sym;
      color=pointFillWithAlpha(symb);
    }
    if (color != null) {
      colorSet.add(SLD.colorToHex(color));
    }
  }
  if (colorSet.size() > 0) {
    return colorSet.toArray(new String[0]);
  }
 else {
    return new String[0];
  }
}

public static String [ ] colors ( final Rule rule ) { final Set < String > colorSet = new HashSet < String > ( ) ; Color color = null ; for ( final Symbolizer sym : rule . symbolizers ( ) ) { if ( sym instanceof PolygonSymbolizer ) { final PolygonSymbolizer symb = ( PolygonSymbolizer ) sym ; color = polyFill ( symb ) ; } else if ( sym instanceof LineSymbolizer ) { final LineSymbolizer symb = ( LineSymbolizer ) sym ; color = color ( symb ) ; } else if ( sym instanceof PointSymbolizer ) { final PointSymbolizer symb = ( PointSymbolizer ) sym ; color = pointFillWithAlpha ( symb ) ; } if ( color != null ) { colorSet . add ( SLD . colorToHex ( color ) ) ; } } if ( colorSet . size ( ) > 0 ) { return colorSet . toArray ( new String [ 0 ] ) ; } else { return new String [ 0 ] ; } }
retrieves all colour names defined in a rule
