/** * Calculate the preferred size for this picture. * * @param scaleX the amount by which image width is multiplied relative to the original width. * @param scaleY the amount by which image height is multiplied relative to the original height. * @return XSSFClientAnchor with the preferred size for this image */ public XSSFClientAnchor getPreferredSize(double scaleX, double scaleY){ Dimension dim = ImageUtils.setPreferredSize(this, scaleX, scaleY); CTPositiveSize2D size2d = ctPicture.getSpPr().getXfrm().getExt(); size2d.setCx((int)dim.getWidth()); size2d.setCy((int)dim.getHeight()); return getClientAnchor(); }
/** * set chart height * * @param height height of chart * @since POI 4.0.0 */ public void setChartHeight(long height) { ctInline.getExtent().setCy(height); }
/** * set chart width * * @param width width of chart * @since POI 4.0.0 */ public void setChartWidth(long width) { ctInline.getExtent().setCx(width); }
public long getY() { if (size == null) { return y; } else { return size.getCy(); } } }
public long getX() { if (size == null) { return x; } else { return size.getCx(); } }
public void setDy2(int dy2) { t2d.getExt().setCy(dy2 - getDy1()); }
public void setDx2(int dx2) { t2d.getExt().setCx(dx2 - getDx1()); } }
/** * get chart height * * @since POI 4.0.0 */ public long getChartHeight() { return ctInline.getExtent().getCy(); }
/** * get chart width * * @since POI 4.0.0 */ public long getChartWidth() { return ctInline.getExtent().getCx(); }
public XSSFChildAnchor(int x, int y, int cx, int cy) { t2d = CTTransform2D.Factory.newInstance(); CTPoint2D off = t2d.addNewOff(); CTPositiveSize2D ext = t2d.addNewExt(); off.setX(x); off.setY(y); ext.setCx(Math.abs(cx - x)); ext.setCy(Math.abs(cy - y)); if(x > cx) t2d.setFlipH(true); if(y > cy) t2d.setFlipV(true); }
@Override public Rectangle2D getAnchor(){ CTGroupTransform2D xfrm = getXfrm(); CTPoint2D off = xfrm.getOff(); double x = Units.toPoints(off.getX()); double y = Units.toPoints(off.getY()); CTPositiveSize2D ext = xfrm.getExt(); double cx = Units.toPoints(ext.getCx()); double cy = Units.toPoints(ext.getCy()); return new Rectangle2D.Double(x,y,cx,cy); }
/** * set chart height * * @param height height of chart * @since POI 4.0.0 */ public void setChartHeight(long height) { ctInline.getExtent().setCy(height); }
/** * set chart width * * @param width width of chart * @since POI 4.0.0 */ public void setChartWidth(long width) { ctInline.getExtent().setCx(width); }
public int getDy2() { return (int)(getDy1() + t2d.getExt().getCy()); }
public int getDx2() { return (int)(getDx1() + t2d.getExt().getCx()); }
/** * Return a fake-xfrm which is used for calculating the text height */ protected CTTransform2D getXfrm() { Rectangle2D anc = getAnchor(); CTTransform2D xfrm = CTTransform2D.Factory.newInstance(); CTPoint2D off = xfrm.addNewOff(); off.setX(Units.toEMU(anc.getX())); off.setY(Units.toEMU(anc.getY())); CTPositiveSize2D size = xfrm.addNewExt(); size.setCx(Units.toEMU(anc.getWidth())); size.setCy(Units.toEMU(anc.getHeight())); return xfrm; }
@Override public Rectangle2D getAnchor() { CTTransform2D xfrm = getXfrm(false); if (xfrm == null) { return null; } CTPoint2D off = xfrm.getOff(); double x = Units.toPoints(off.getX()); double y = Units.toPoints(off.getY()); CTPositiveSize2D ext = xfrm.getExt(); double cx = Units.toPoints(ext.getCx()); double cy = Units.toPoints(ext.getCy()); return new Rectangle2D.Double(x, y, cx, cy); }
public void setDy2(int dy2) { t2d.getExt().setCy(dy2 - getDy1()); }
public void setDx2(int dx2) { t2d.getExt().setCx(dx2 - getDx1()); } }