Class XSSFPicture

  • All Implemented Interfaces:
    Picture, Shape

    public final class XSSFPicture
    extends XSSFShape
    implements Picture
    Represents a picture shape in a SpreadsheetML drawing.
    • Method Detail

      • getCTPicture

        @Internal
        public CTPicture getCTPicture()
        Return the underlying CTPicture bean that holds all properties for this picture
        Returns:
        the underlying CTPicture bean
      • resize

        public void resize​(double scaleX,
                           double scaleY)
        Resize the image relatively to its current size.

        Please note, that this method works correctly only for workbooks with the default font size (Calibri 11pt for .xlsx). If the default font is changed the resized image can be streched vertically or horizontally.

        resize(1.0,1.0) keeps the original size,
        resize(0.5,0.5) resize to 50% of the original,
        resize(2.0,2.0) resizes to 200% of the original.
        resize(Double.MAX_VALUE,Double.MAX_VALUE) resizes to the dimension of the embedded image.

        Specified by:
        resize in interface Picture
        Parameters:
        scaleX - the amount by which the image width is multiplied relative to the original width, when set to Double.MAX_VALUE the width of the embedded image is used
        scaleY - the amount by which the image height is multiplied relative to the original height, when set to Double.MAX_VALUE the height of the embedded image is used
      • getPreferredSize

        public XSSFClientAnchor getPreferredSize()
        Calculate the preferred size for this picture.
        Specified by:
        getPreferredSize in interface Picture
        Returns:
        XSSFClientAnchor with the preferred size for this image
      • getPreferredSize

        public XSSFClientAnchor getPreferredSize​(double scale)
        Calculate the preferred size for this picture.
        Parameters:
        scale - the amount by which image dimensions are multiplied relative to the original size.
        Returns:
        XSSFClientAnchor with the preferred size for this image
      • getPreferredSize

        public XSSFClientAnchor getPreferredSize​(double scaleX,
                                                 double scaleY)
        Calculate the preferred size for this picture.
        Specified by:
        getPreferredSize in interface Picture
        Parameters:
        scaleX - the amount by which image width is multiplied relative to the original width.
        scaleY - the amount by which image height is multiplied relative to the original height.
        Returns:
        XSSFClientAnchor with the preferred size for this image
      • getImageDimension

        public java.awt.Dimension getImageDimension()
        Return the dimension of the embedded image in pixel
        Specified by:
        getImageDimension in interface Picture
        Returns:
        image dimension in pixels
      • getPictureData

        public XSSFPictureData getPictureData()
        Return picture data for this shape
        Specified by:
        getPictureData in interface Picture
        Returns:
        picture data for this shape
      • getSheet

        public XSSFSheet getSheet()
        Specified by:
        getSheet in interface Picture
        Returns:
        the sheet which contains the picture shape
      • getShapeName

        public java.lang.String getShapeName()
        Specified by:
        getShapeName in interface Shape
        Returns:
        the name of this shape