}
for (FeatureTypeStyle featureTypeStyle : style.featureTypeStyles()) {
for (int i = 0; i < featureTypeStyle.rules().size(); i++) {
Rule rule = featureTypeStyle.rules().get(i);
DuplicatingStyleVisitor update = new DuplicatingStyleVisitor() {
@Override
public void visit(RasterSymbolizer raster) {
ChannelSelection channelSelection = createChannelSelection();
ColorMap colorMap = copy(raster.getColorMap());
ContrastEnhancement ce = copy(raster.getContrastEnhancement());
String geometryProperty = raster.getGeometryPropertyName();
Symbolizer outline = copy(raster.getImageOutline());
Expression overlap = copy(raster.getOverlap());
ShadedRelief shadedRelief = copy(raster.getShadedRelief());
Expression opacity = copy(raster.getOpacity());
RasterSymbolizer copy = sf.createRasterSymbolizer(geometryProperty, opacity,
channelSelection, overlap, colorMap, ce,
shadedRelief, outline);
if (STRICT && !copy.equals(raster)) {
throw new IllegalStateException("Was unable to duplicate provided raster:" + raster);
}
pages.push(copy);
}
private ChannelSelection createChannelSelection() {
if (rgb == null) {
return sf.createChannelSelection(new SelectedChannelType[]{gray});
} else {
return sf.createChannelSelection(rgb);
}
}
};
rule.accept(update);
Rule updatedRule = (Rule) update.getCopy();
featureTypeStyle.rules().set(i, updatedRule);
}
}
}