use of org.geotoolkit.display2d.style.j2d.TextStroke in project geotoolkit by Geomatys.
the class LinearLabelCandidateRenderer method render.
@Override
public void render(final Candidate candidate) {
if (!(candidate instanceof LinearCandidate))
return;
LinearCandidate linearCandidate = (LinearCandidate) candidate;
LinearLabelDescriptor label = linearCandidate.getDescriptor();
context.switchToDisplayCRS();
final TextStroke stroke = new TextStroke(label.getText(), label.getTextFont(), label.isRepeated(), label.getOffSet(), label.getInitialGap(), label.getGap(), context.getCanvasDisplayBounds());
Shape shp = linearCandidate.getShape();
if (shp == null) {
return;
}
final Shape shape = stroke.createStrokedShape(shp);
// paint halo
if (label.getHaloWidth() > 0) {
g2.setStroke(new BasicStroke(label.getHaloWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g2.setPaint(label.getHaloPaint());
g2.draw(shape);
}
// paint text
g2.setStroke(new BasicStroke(0));
g2.setPaint(label.getTextPaint());
g2.fill(shape);
}
use of org.geotoolkit.display2d.style.j2d.TextStroke in project geotoolkit by Geomatys.
the class DefaultLabelRenderer method portray.
private void portray(final Graphics2D g2, final LinearLabelDescriptor label) {
context.switchToDisplayCRS();
final TextStroke stroke = new TextStroke(label.getText(), label.getTextFont(), label.isRepeated(), label.getOffSet(), label.getInitialGap(), label.getGap(), context.getCanvasDisplayBounds());
final Shape[] geoms;
try {
geoms = label.getGeometry().getDisplayShape();
} catch (TransformException ex) {
Logger.getLogger("org.geotoolkit.display2d.style.labeling").log(Level.WARNING, null, ex);
return;
}
for (Shape geom : geoms) {
final Shape shape = stroke.createStrokedShape(geom);
// paint halo
if (label.getHaloWidth() > 0) {
g2.setStroke(new BasicStroke(label.getHaloWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g2.setPaint(label.getHaloPaint());
g2.draw(shape);
}
// paint text
g2.setStroke(new BasicStroke(0));
g2.setPaint(label.getTextPaint());
g2.fill(shape);
}
}
Aggregations