Package org.apache.poi.xssf.usermodel
Class XSSFPicture
java.lang.Object
org.apache.poi.xssf.usermodel.XSSFShape
org.apache.poi.xssf.usermodel.XSSFPicture
Represents a picture shape in a SpreadsheetML drawing.
- Author:
- Yegor Kozlov
-
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedXSSFPicture(XSSFDrawing drawing, org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture ctPicture) Construct a new XSSFPicture object. -
Method Summary
Modifier and TypeMethodDescriptionorg.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPictureReturn the underlying CTPicture bean that holds all properties for this pictureReturn the dimension of the embedded image in pixelprotected static DimensiongetImageDimension(PackagePart part, int type) Return the dimension of this imageReturn picture data for this shapeCalculate the preferred size for this picture.getPreferredSize(double scale) Calculate the preferred size for this picture.getPreferredSize(double scaleX, double scaleY) Calculate the preferred size for this picture.protected org.openxmlformats.schemas.drawingml.x2006.main.CTShapePropertiesReturns xml bean with shape properties.getSheet()protected static org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPictureReturns a prototype that is used to construct new shapesvoidresize()Reset the image to the dimension of the embedded imagevoidresize(double scale) Resize the image proportionally.voidresize(double scaleX, double scaleY) Resize the image relatively to its current size.protected voidLink this shape with the picture dataMethods inherited from class org.apache.poi.xssf.usermodel.XSSFShape
getAnchor, getDrawing, getParent, isNoFill, setFillColor, setLineStyle, setLineStyleColor, setLineWidth, setNoFillMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.poi.ss.usermodel.Shape
getAnchor, getParent, isNoFill, setFillColor, setLineStyleColor, setNoFill
-
Constructor Details
-
XSSFPicture
protected XSSFPicture(XSSFDrawing drawing, org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture ctPicture) Construct a new XSSFPicture object. This constructor is called fromXSSFDrawing.createPicture(XSSFClientAnchor, int)- Parameters:
drawing- the XSSFDrawing that owns this picture
-
-
Method Details
-
prototype
protected static org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture prototype()Returns a prototype that is used to construct new shapes- Returns:
- a prototype that is used to construct new shapes
-
setPictureReference
Link this shape with the picture data- Parameters:
rel- relationship referring the picture data
-
getCTPicture
@Internal public org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPicture getCTPicture()Return the underlying CTPicture bean that holds all properties for this picture- Returns:
- the underlying CTPicture bean
-
resize
public void resize()Reset the image to the dimension of the embedded image -
resize
public void resize(double scale) Resize the image proportionally. -
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(resizes to the dimension of the embedded image.Double.MAX_VALUE,Double.MAX_VALUE)- Specified by:
resizein interfacePicture- Parameters:
scaleX- the amount by which the image width is multiplied relative to the original width, when set toDouble.MAX_VALUEthe width of the embedded image is usedscaleY- the amount by which the image height is multiplied relative to the original height, when set toDouble.MAX_VALUEthe height of the embedded image is used
-
getPreferredSize
Calculate the preferred size for this picture.- Specified by:
getPreferredSizein interfacePicture- Returns:
- XSSFClientAnchor with the preferred size for this image
-
getPreferredSize
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
Calculate the preferred size for this picture.- Specified by:
getPreferredSizein interfacePicture- 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
Return the dimension of this image- Parameters:
part- the package part holding raw picture datatype- type of the picture:Workbook.PICTURE_TYPE_JPEG,Workbook.PICTURE_TYPE_PNGorWorkbook.PICTURE_TYPE_DIB- Returns:
- image dimension in pixels
-
getImageDimension
Return the dimension of the embedded image in pixel- Specified by:
getImageDimensionin interfacePicture- Returns:
- image dimension in pixels
-
getPictureData
Return picture data for this shape- Specified by:
getPictureDatain interfacePicture- Returns:
- picture data for this shape
-
getShapeProperties
protected org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties getShapeProperties()Description copied from class:XSSFShapeReturns xml bean with shape properties.- Specified by:
getShapePropertiesin classXSSFShape- Returns:
- xml bean with shape properties.
-
getClientAnchor
- Specified by:
getClientAnchorin interfacePicture- Returns:
- the anchor that is used by this shape.
-
getSheet
-
getShapeName
- Specified by:
getShapeNamein interfaceShape- Returns:
- the name of this shape
-