final double rotation = ((shape.getRotation() % 360.) + 360.) % 360.; final int quadrant = (((int)rotation+45)/90)%4; final Rectangle2D shapeAnchor = shape.getAnchor(); final Rectangle2D anchorO = tx.createTransformedShape(shapeAnchor).getBounds2D(); normalizedShape = shape.getAnchor();
case 'h': if (ps.getFlipHorizontal()) { graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY()); graphics.scale(-1, 1); case 'v': if (ps.getFlipVertical()) { graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight()); graphics.scale(1, -1); case 'r': double rotation = ps.getRotation(); if (rotation != 0.) {
while (sc instanceof PlaceableShape) { PlaceableShape<?,?> ps = (PlaceableShape<?,?>)sc; vertFlip ^= ps.getFlipVertical(); horzFlip ^= ps.getFlipHorizontal(); sc = ps.getParent();
/** * Set the contents of this shape to be a copy of the source shape. * This method is called recursively for each shape when merging slides * * @param sh the source shape * @see org.apache.poi.xslf.usermodel.XSLFSlide#importContent(XSLFSheet) */ @Internal void copy(XSLFShape sh) { if (!getClass().isInstance(sh)) { throw new IllegalArgumentException( "Can't copy " + sh.getClass().getSimpleName() + " into " + getClass().getSimpleName()); } if (this instanceof PlaceableShape) { PlaceableShape<?,?> ps = (PlaceableShape<?,?>)this; ps.setAnchor(sh.getAnchor()); } }
@SuppressWarnings("WeakerAccess") protected Paint createLinearGradientPaint(GradientPaint fill, Graphics2D graphics) { // TODO: we need to find the two points for gradient - the problem is, which point at the outline // do you take? My solution would be to apply the gradient rotation to the shape in reverse // and then scan the shape for the largest possible horizontal distance double angle = fill.getGradientAngle(); if (!fill.isRotatedWithShape()) { angle -= shape.getRotation(); } Rectangle2D anchor = DrawShape.getAnchor(graphics, shape); AffineTransform at = AffineTransform.getRotateInstance(Math.toRadians(angle), anchor.getCenterX(), anchor.getCenterY()); double diagonal = Math.sqrt(Math.pow(anchor.getWidth(),2) + Math.pow(anchor.getHeight(),2)); final Point2D p1 = at.transform(new Point2D.Double(anchor.getCenterX() - diagonal / 2, anchor.getCenterY()), null); final Point2D p2 = at.transform(new Point2D.Double(anchor.getMaxX(), anchor.getCenterY()), null); // snapToAnchor(p1, anchor); // snapToAnchor(p2, anchor); // gradient paint on the same point throws an exception ... and doesn't make sense return (p1.equals(p2)) ? null : safeFractions((f,c)->new LinearGradientPaint(p1,p2,f,c), fill); }
Rectangle2D textAnchor = shape.getAnchor(); BufferedImage image; if ("image/x-wmf".equals(fill.getContentType())) {
/** * Set the contents of this shape to be a copy of the source shape. * This method is called recursively for each shape when merging slides * * @param sh the source shape * @see org.apache.poi.xslf.usermodel.XSLFSlide#importContent(XSLFSheet) */ @Internal void copy(XSLFShape sh) { if (!getClass().isInstance(sh)) { throw new IllegalArgumentException( "Can't copy " + sh.getClass().getSimpleName() + " into " + getClass().getSimpleName()); } if (this instanceof PlaceableShape) { PlaceableShape<?,?> ps = (PlaceableShape<?,?>)this; ps.setAnchor(sh.getAnchor()); } }
@SuppressWarnings("WeakerAccess") protected Paint createLinearGradientPaint(GradientPaint fill, Graphics2D graphics) { // TODO: we need to find the two points for gradient - the problem is, which point at the outline // do you take? My solution would be to apply the gradient rotation to the shape in reverse // and then scan the shape for the largest possible horizontal distance double angle = fill.getGradientAngle(); if (!fill.isRotatedWithShape()) { angle -= shape.getRotation(); } Rectangle2D anchor = DrawShape.getAnchor(graphics, shape); AffineTransform at = AffineTransform.getRotateInstance(Math.toRadians(angle), anchor.getCenterX(), anchor.getCenterY()); double diagonal = Math.sqrt(Math.pow(anchor.getWidth(),2) + Math.pow(anchor.getHeight(),2)); final Point2D p1 = at.transform(new Point2D.Double(anchor.getCenterX() - diagonal / 2, anchor.getCenterY()), null); final Point2D p2 = at.transform(new Point2D.Double(anchor.getMaxX(), anchor.getCenterY()), null); // snapToAnchor(p1, anchor); // snapToAnchor(p2, anchor); // gradient paint on the same point throws an exception ... and doesn't make sense return (p1.equals(p2)) ? null : safeFractions((f,c)->new LinearGradientPaint(p1,p2,f,c), fill); }
Rectangle2D textAnchor = shape.getAnchor(); BufferedImage image; if ("image/x-wmf".equals(fill.getContentType())) {
case 'h': if (ps.getFlipHorizontal()) { graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY()); graphics.scale(-1, 1); case 'v': if (ps.getFlipVertical()) { graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight()); graphics.scale(1, -1); case 'r': double rotation = ps.getRotation(); if (rotation != 0.) {
while (sc instanceof PlaceableShape) { PlaceableShape<?,?> ps = (PlaceableShape<?,?>)sc; vertFlip ^= ps.getFlipVertical(); horzFlip ^= ps.getFlipHorizontal(); sc = ps.getParent();
final double rotation = ((shape.getRotation() % 360.) + 360.) % 360.; final int quadrant = (((int)rotation+45)/90)%4; final Rectangle2D shapeAnchor = shape.getAnchor(); final Rectangle2D anchorO = tx.createTransformedShape(shapeAnchor).getBounds2D(); normalizedShape = shape.getAnchor();