use of org.apache.poi.sl.usermodel.StrokeStyle in project poi by apache.
the class DrawTableShape method draw.
public void draw(Graphics2D graphics) {
Drawable d = getGroupShape(graphics);
if (d != null) {
d.draw(graphics);
return;
}
TableShape<?, ?> ts = getShape();
DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(ts);
final int rows = ts.getNumberOfRows();
final int cols = ts.getNumberOfColumns();
// draw background boxes
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
TableCell<?, ?> tc = ts.getCell(row, col);
if (tc == null || tc.isMerged()) {
continue;
}
Paint fillPaint = drawPaint.getPaint(graphics, tc.getFillStyle().getPaint());
graphics.setPaint(fillPaint);
Rectangle2D cellAnc = tc.getAnchor();
graphics.fill(cellAnc);
for (BorderEdge edge : BorderEdge.values()) {
StrokeStyle stroke = tc.getBorderStyle(edge);
if (stroke == null) {
continue;
}
graphics.setStroke(getStroke(stroke));
Paint linePaint = drawPaint.getPaint(graphics, stroke.getPaint());
graphics.setPaint(linePaint);
double x = cellAnc.getX(), y = cellAnc.getY(), w = cellAnc.getWidth(), h = cellAnc.getHeight();
Line2D line;
switch(edge) {
default:
case bottom:
line = new Line2D.Double(x - borderSize, y + h, x + w + borderSize, y + h);
break;
case left:
line = new Line2D.Double(x, y, x, y + h + borderSize);
break;
case right:
line = new Line2D.Double(x + w, y, x + w, y + h + borderSize);
break;
case top:
line = new Line2D.Double(x - borderSize, y, x + w + borderSize, y);
break;
}
graphics.draw(line);
}
}
}
// draw text
drawContent(graphics);
}
use of org.apache.poi.sl.usermodel.StrokeStyle 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