@SuppressWarnings("deprecation")
@Override
public void visit(TextSymbolizer text) {
super.visit(text);
TextSymbolizer copy = (TextSymbolizer) pages.peek();
Unit<Length> uom = copy.getUnitOfMeasure();
// rescales fonts
Font[] fonts = copy.getFonts();
for (Font font : fonts)
font.setSize(rescale(font.getSize(), uom));
copy.setFonts(fonts);
// rescales label placement
LabelPlacement placement = copy.getLabelPlacement();
if (placement instanceof PointPlacement) {
// rescales point label placement
PointPlacement pointPlacement = (PointPlacement) placement;
Displacement disp = pointPlacement.getDisplacement();
if (disp != null) {
disp.setDisplacementX(rescale(disp.getDisplacementX(), uom));
disp.setDisplacementY(rescale(disp.getDisplacementY(), uom));
pointPlacement.setDisplacement(disp);
}
} else if (placement instanceof LinePlacement) {
// rescales line label placement
LinePlacement linePlacement = (LinePlacement) placement;
linePlacement.setGap(rescale(linePlacement.getGap(), uom));
linePlacement.setInitialGap(rescale(linePlacement.getInitialGap(), uom));
linePlacement.setPerpendicularOffset(rescale(linePlacement.getPerpendicularOffset(),
uom));
}
copy.setLabelPlacement(placement);
// rescale the halo
if (copy.getHalo() != null) {
copy.getHalo().setRadius(rescale(copy.getHalo().getRadius(), uom));
}
if (copy instanceof TextSymbolizer2) {
TextSymbolizer2 copy2 = (TextSymbolizer2) copy;
rescale(copy2.getGraphic(), uom);
}
// scale various options as well
Map<String, String> options = copy.getOptions();
scaleIntOption(options, TextSymbolizer.MAX_DISPLACEMENT_KEY, uom);
scaleIntOption(options, TextSymbolizer.SPACE_AROUND_KEY, uom);
scaleIntOption(options, TextSymbolizer.MIN_GROUP_DISTANCE_KEY, uom);
scaleIntOption(options, TextSymbolizer.LABEL_REPEAT_KEY, uom);
scaleIntOption(options, TextSymbolizer.AUTO_WRAP_KEY, uom);
scaleIntArrayOption(options, TextSymbolizer.GRAPHIC_MARGIN_KEY, uom);
copy.setUnitOfMeasure(NonSI.PIXEL);
}