if (legendRasterizingInfo.getWidth() > 0) {
builder.setSize(legendRasterizingInfo.getWidth(), legendRasterizingInfo.getHeight());
}
for (Layer layer : mapContext.layers()) {
if (layer instanceof RasterDirectLayer) {
RasterDirectLayer rasterLayer = (RasterDirectLayer) layer;
builder.addRasterLayer(rasterLayer.getTitle(), font);
} else if (layer instanceof FeatureLayer) {
FeatureLayer featureLayer = (FeatureLayer) layer;
List<Rule> rules = (List<Rule>) featureLayer.getUserData().get(LayerFactory.USERDATA_KEY_STYLE_RULES);
for (Rule rule : rules) {
if (!isTextOnly(rule)) {