use of org.apache.poi.sl.draw.geom.Outline in project poi by apache.
the class DrawSimpleShape method draw.
@Override
public void draw(Graphics2D graphics) {
DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(getShape());
Paint fill = drawPaint.getPaint(graphics, getShape().getFillStyle().getPaint());
Paint line = drawPaint.getPaint(graphics, getShape().getStrokeStyle().getPaint());
// the stroke applies both to the shadow and the shape
BasicStroke stroke = getStroke();
graphics.setStroke(stroke);
Collection<Outline> elems = computeOutlines(graphics);
// first paint the shadow
drawShadow(graphics, elems, fill, line);
// then fill the shape interior
if (fill != null) {
for (Outline o : elems) {
if (o.getPath().isFilled()) {
Paint fillMod = drawPaint.getPaint(graphics, getShape().getFillStyle().getPaint(), o.getPath().getFill());
if (fillMod != null) {
graphics.setPaint(fillMod);
java.awt.Shape s = o.getOutline();
graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
graphics.fill(s);
}
}
}
}
// then draw any content within this shape (text, image, etc.)
drawContent(graphics);
// then stroke the shape outline
if (line != null) {
graphics.setPaint(line);
graphics.setStroke(stroke);
for (Outline o : elems) {
if (o.getPath().isStroked()) {
java.awt.Shape s = o.getOutline();
graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
graphics.draw(s);
}
}
}
// draw line decorations
drawDecoration(graphics, line, stroke);
}
use of org.apache.poi.sl.draw.geom.Outline in project poi by apache.
the class DrawFreeformShape method computeOutlines.
protected Collection<Outline> computeOutlines(Graphics2D graphics) {
List<Outline> lst = new ArrayList<Outline>();
FreeformShape<?, ?> fsh = getShape();
Path2D sh = fsh.getPath();
AffineTransform tx = (AffineTransform) graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if (tx == null) {
tx = new AffineTransform();
}
java.awt.Shape canvasShape = tx.createTransformedShape(sh);
FillStyle fs = fsh.getFillStyle();
StrokeStyle ss = fsh.getStrokeStyle();
Path path = new Path(fs != null, ss != null);
lst.add(new Outline(canvasShape, path));
return lst;
}
Aggregations