@Override public XSLFPictureShape createPicture(PictureData pictureData){ if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId()); new DrawPictureShape(sh).resize(); getShapes().add(sh); sh.setParent(this); return sh; }
public void draw(Graphics2D context) { PictureShape<?,?> ps = ((GraphicalFrame<?,?>)getShape()).getFallbackPicture(); if (ps == null) { return; } DrawPictureShape dps = DrawFactory.getInstance(context).getDrawable(ps); dps.draw(context); } }
@Override public void drawContent(Graphics2D graphics) { PictureData data = getShape().getPictureData(); if(data == null) return; Rectangle2D anchor = getAnchor(graphics, getShape()); Insets insets = getShape().getClipping(); try { ImageRenderer renderer = getImageRenderer(graphics, data.getContentType()); renderer.loadImage(data.getData(), data.getContentType()); renderer.drawImage(graphics, anchor, insets); } catch (IOException e) { LOG.log(POILogger.ERROR, "image can't be loaded/rendered.", e); } }
/** * Fit picture shape into the target rectangle, maintaining the aspect ratio * and repositioning within the target rectangle with a centered alignment. * * @param target The target rectangle */ public void resize(Rectangle2D target) { resize(target, RectAlign.CENTER); }
public DrawPictureShape getDrawable(PictureShape<?,?> shape) { return new DrawPictureShape(shape); }
/** * Resize this picture to the default size. * * For PNG and JPEG resizes the image to 100%, * for other types, if the size can't be determined it will be 200x200 pixels. */ public void resize() { PictureShape<?,?> ps = getShape(); Dimension dim = ps.getPictureData().getImageDimension(); Rectangle2D origRect = ps.getAnchor(); double x = origRect.getX(); double y = origRect.getY(); double w = dim.getWidth(); double h = dim.getHeight(); ps.setAnchor(new Rectangle2D.Double(x, y, w, h)); }
ImageRenderer renderer = DrawPictureShape.getImageRenderer(graphics, fill.getContentType());
/** * Fit picture shape into the target rectangle, maintaining the aspect ratio * and repositioning within the target rectangle with a centered alignment. * * @param target The target rectangle */ public void resize(Rectangle2D target) { resize(target, RectAlign.CENTER); }
public DrawPictureShape getDrawable(PictureShape<?,?> shape) { return new DrawPictureShape(shape); }
PictureShape<?,?> ps = getShape(); Dimension dim = ps.getPictureData().getImageDimension(); if (dim.width <= 0 || dim.height <= 0) {
ImageRenderer renderer = DrawPictureShape.getImageRenderer(graphics, fill.getContentType());
@Override public XSLFPictureShape createPicture(PictureData pictureData){ if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId()); new DrawPictureShape(sh).resize(); _shapes.add(sh); sh.setParent(this); return sh; }
@Override public void drawContent(Graphics2D graphics) { PictureData data = getShape().getPictureData(); if(data == null) return; Rectangle2D anchor = getAnchor(graphics, getShape()); Insets insets = getShape().getClipping(); try { ImageRenderer renderer = getImageRenderer(graphics, data.getContentType()); renderer.loadImage(data.getData(), data.getContentType()); renderer.drawImage(graphics, anchor, insets); } catch (IOException e) { LOG.log(POILogger.ERROR, "image can't be loaded/rendered.", e); } }
/** * Resize this picture to the default size. * * For PNG and JPEG resizes the image to 100%, * for other types, if the size can't be determined it will be 200x200 pixels. */ public void resize() { PictureShape<?,?> ps = getShape(); Dimension dim = ps.getPictureData().getImageDimension(); Rectangle2D origRect = ps.getAnchor(); double x = origRect.getX(); double y = origRect.getY(); double w = dim.getWidth(); double h = dim.getHeight(); ps.setAnchor(new Rectangle2D.Double(x, y, w, h)); }
public void draw(Graphics2D context) { PictureShape<?,?> ps = ((GraphicalFrame<?,?>)getShape()).getFallbackPicture(); if (ps == null) { return; } DrawPictureShape dps = DrawFactory.getInstance(context).getDrawable(ps); dps.draw(context); } }
@Override public XSLFPictureShape createPicture(PictureData pictureData){ if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId()); new DrawPictureShape(sh).resize(); _shapes.add(sh); sh.setParent(this); return sh; }
PictureShape<?,?> ps = getShape(); Dimension dim = ps.getPictureData().getImageDimension(); if (dim.width <= 0 || dim.height <= 0) {
@Override public XSLFPictureShape createPicture(PictureData pictureData){ if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId()); new DrawPictureShape(sh).resize(); getShapes().add(sh); sh.setParent(this); return sh; }
/** * By default set the orininal image size */ @Override protected void afterInsert(HSLFSheet sh){ super.afterInsert(sh); EscherBSERecord bse = getEscherBSERecord(); bse.setRef(bse.getRef() + 1); Rectangle2D anchor = getAnchor(); if (anchor.isEmpty()){ new DrawPictureShape(this).resize(); } }