Package org.apache.poi.hslf.usermodel
Class HSLFShape
- java.lang.Object
-
- org.apache.poi.hslf.usermodel.HSLFShape
-
- All Implemented Interfaces:
Shape<HSLFShape,HSLFTextParagraph>
- Direct Known Subclasses:
HSLFBackground,HSLFGroupShape,HSLFSimpleShape
public abstract class HSLFShape extends Object implements Shape<HSLFShape,HSLFTextParagraph>
Represents a Shape which is the elemental object that composes a drawing. This class is a wrapper around EscherSpContainer which holds all information about a shape in PowerPoint document.When you add a shape, you usually specify the dimensions of the shape and the position of the upper'left corner of the bounding box for the shape relative to the upper'left corner of the page, worksheet, or slide. Distances in the drawing layer are measured in points (72 points = 1 inch).
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHSLFShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent)Create a Shape object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidafterInsert(HSLFSheet sh)Event which fires when a shape is inserted in the sheet.protected EscherContainerRecordcreateSpContainer(boolean isChild)Create and assign the lower level escher record to this shapevoiddraw(Graphics2D graphics, Rectangle2D bounds)Rectangle2DgetAnchor()Returns the anchor (the bounding box rectangle) of this shape.protected HSLFEscherClientDataRecordgetClientData(boolean create)Create a new HSLF-specific EscherClientDataRecord<T extends Record>
TgetClientDataRecord(int recordType)Find a record in the underlying EscherClientDataRecordprotected List<? extends Record>getClientRecords()Search for EscherClientDataRecord, if found, convert its contents into an array of HSLF records<T extends EscherRecord>
TgetEscherChild(int recordId)static <T extends EscherRecord>
TgetEscherChild(EscherContainerRecord owner, int recordId)Helper method to return escher child by record IDstatic <T extends EscherRecord>
TgetEscherChild(EscherContainerRecord owner, EscherRecordTypes recordId)<T extends EscherRecord>
TgetEscherChild(EscherRecordTypes recordId)AbstractEscherOptRecordgetEscherOptRecord()intgetEscherProperty(short propId)Get the value of a simple escher property for this shape.intgetEscherProperty(short propId, int defaultValue)Deprecated.usegetEscherProperty(EscherPropertyTypes, int)insteadstatic <T extends EscherProperty>
TgetEscherProperty(AbstractEscherOptRecord opt, int propId)Deprecated.usegetEscherProperty(EscherPropertyTypes)insteadstatic <T extends EscherProperty>
TgetEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type)Returns escher property by type.intgetEscherProperty(EscherPropertyTypes propType)Get the value of a simple escher property for this shape.intgetEscherProperty(EscherPropertyTypes type, int defaultValue)Get the value of a simple escher property for this shape.HSLFFillgetFill()Fill properties of this shapeFillStylegetFillStyle()booleangetFlipHorizontal()booleangetFlipVertical()ShapeContainer<HSLFShape,HSLFTextParagraph>getParent()doublegetRotation()intgetShapeId()StringgetShapeName()ShapeTypegetShapeType()HSLFSheetgetSheet()EscherContainerRecordgetSpContainer()booleanisPlaceholder()voidmoveTo(double x, double y)Moves the top left corner of the shape to the specified point.voidsetAnchor(Rectangle2D anchor)Sets the anchor (the bounding box rectangle) of this shape.voidsetEscherProperty(short propId, int value)Deprecated.static voidsetEscherProperty(AbstractEscherOptRecord opt, short propId, int value)static voidsetEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes propType, boolean isBlipId, int value)static voidsetEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes propType, int value)Set an escher property for this shape.voidsetEscherProperty(EscherPropertyTypes propType, int value)Set an simple escher property for this shape.voidsetFlipHorizontal(boolean flip)voidsetFlipVertical(boolean flip)voidsetRotation(double theta)voidsetShapeId(int id)Sets shape IDvoidsetShapeType(ShapeType type)voidsetSheet(HSLFSheet sheet)Assign theSlideShowthis shape belongs to
-
-
-
Constructor Detail
-
HSLFShape
protected HSLFShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent)
Create a Shape object. This constructor is used when an existing Shape is read from a PowerPoint document.- Parameters:
escherRecord-EscherSpContainercontainer which holds information about this shapeparent- the parent of this Shape
-
-
Method Detail
-
createSpContainer
protected EscherContainerRecord createSpContainer(boolean isChild)
Create and assign the lower level escher record to this shape
-
getParent
public ShapeContainer<HSLFShape,HSLFTextParagraph> getParent()
- Specified by:
getParentin interfaceShape<HSLFShape,HSLFTextParagraph>- Returns:
- the parent of this shape
-
getShapeName
public String getShapeName()
- Specified by:
getShapeNamein interfaceShape<HSLFShape,HSLFTextParagraph>- Returns:
- name of the shape.
-
getShapeType
public ShapeType getShapeType()
-
setShapeType
public void setShapeType(ShapeType type)
-
getAnchor
public Rectangle2D getAnchor()
Returns the anchor (the bounding box rectangle) of this shape. All coordinates are expressed in points (72 dpi).- Specified by:
getAnchorin interfaceShape<HSLFShape,HSLFTextParagraph>- Returns:
- the anchor of this shape
-
setAnchor
public void setAnchor(Rectangle2D anchor)
Sets the anchor (the bounding box rectangle) of this shape. All coordinates should be expressed in points (72 dpi).- Parameters:
anchor- new anchor
-
moveTo
public final void moveTo(double x, double y)Moves the top left corner of the shape to the specified point.- Parameters:
x- the x coordinate of the top left corner of the shapey- the y coordinate of the top left corner of the shape
-
getEscherChild
public static <T extends EscherRecord> T getEscherChild(EscherContainerRecord owner, int recordId)
Helper method to return escher child by record ID- Returns:
- escher record or
nullif not found.
-
getEscherChild
public static <T extends EscherRecord> T getEscherChild(EscherContainerRecord owner, EscherRecordTypes recordId)
- Since:
- POI 3.14-Beta2
-
getEscherChild
public <T extends EscherRecord> T getEscherChild(int recordId)
-
getEscherChild
public <T extends EscherRecord> T getEscherChild(EscherRecordTypes recordId)
- Since:
- POI 3.14-Beta2
-
getEscherProperty
@Deprecated @Removal(version="5.0.0") public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, int propId)
Deprecated.usegetEscherProperty(EscherPropertyTypes)insteadReturns escher property by id.- Returns:
- escher property or
nullif not found.
-
getEscherProperty
public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type)
Returns escher property by type.- Returns:
- escher property or
nullif not found.
-
setEscherProperty
@Deprecated @Removal(version="5.0.0") public static void setEscherProperty(AbstractEscherOptRecord opt, short propId, int value)
Set an escher property for this shape.- Parameters:
opt- The opt record to set the properties to.propId- The id of the property. One of the constants defined in EscherOptRecord.value- value of the property. If value = -1 then the property is removed.
-
setEscherProperty
public static void setEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes propType, int value)
Set an escher property for this shape.- Parameters:
opt- The opt record to set the properties to.propType- The type of the property.value- value of the property. If value = -1 then the property is removed.
-
setEscherProperty
public static void setEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes propType, boolean isBlipId, int value)
-
setEscherProperty
@Deprecated @Removal(version="5.0.0") public void setEscherProperty(short propId, int value)
Deprecated.Set an simple escher property for this shape.- Parameters:
propId- The id of the property. One of the constants defined in EscherOptRecord.value- value of the property. If value = -1 then the property is removed.
-
setEscherProperty
public void setEscherProperty(EscherPropertyTypes propType, int value)
Set an simple escher property for this shape.- Parameters:
propType- The type of the property.value- value of the property. If value = -1 then the property is removed.
-
getEscherProperty
public int getEscherProperty(short propId)
Get the value of a simple escher property for this shape.- Parameters:
propId- The id of the property. One of the constants defined in EscherOptRecord.
-
getEscherProperty
public int getEscherProperty(EscherPropertyTypes propType)
Get the value of a simple escher property for this shape.- Parameters:
propType- The type of the property. One of the constants defined in EscherOptRecord.
-
getEscherProperty
@Deprecated @Removal(version="5.0.0") public int getEscherProperty(short propId, int defaultValue)
Deprecated.usegetEscherProperty(EscherPropertyTypes, int)insteadGet the value of a simple escher property for this shape.- Parameters:
propId- The id of the property. One of the constants defined in EscherOptRecord.
-
getEscherProperty
public int getEscherProperty(EscherPropertyTypes type, int defaultValue)
Get the value of a simple escher property for this shape.- Parameters:
type- The type of the property.
-
getSpContainer
public EscherContainerRecord getSpContainer()
- Returns:
- The shape container and its children that can represent this shape.
-
afterInsert
protected void afterInsert(HSLFSheet sh)
Event which fires when a shape is inserted in the sheet. In some cases we need to propagate changes to upper level containers.
Default implementation does nothing.- Parameters:
sh- - owning shape
-
getSheet
public HSLFSheet getSheet()
- Specified by:
getSheetin interfaceShape<HSLFShape,HSLFTextParagraph>- Returns:
- the
SlideShowthis shape belongs to
-
setSheet
public void setSheet(HSLFSheet sheet)
Assign theSlideShowthis shape belongs to- Parameters:
sheet- owner of this shape
-
getShapeId
public int getShapeId()
- Specified by:
getShapeIdin interfaceShape<HSLFShape,HSLFTextParagraph>
-
setShapeId
public void setShapeId(int id)
Sets shape ID- Parameters:
id- of the shape
-
getFill
public HSLFFill getFill()
Fill properties of this shape- Returns:
- fill properties of this shape
-
getFillStyle
public FillStyle getFillStyle()
-
draw
public void draw(Graphics2D graphics, Rectangle2D bounds)
- Specified by:
drawin interfaceShape<HSLFShape,HSLFTextParagraph>
-
getEscherOptRecord
public AbstractEscherOptRecord getEscherOptRecord()
-
getFlipHorizontal
public boolean getFlipHorizontal()
-
setFlipHorizontal
public void setFlipHorizontal(boolean flip)
-
getFlipVertical
public boolean getFlipVertical()
-
setFlipVertical
public void setFlipVertical(boolean flip)
-
getRotation
public double getRotation()
-
setRotation
public void setRotation(double theta)
-
isPlaceholder
public boolean isPlaceholder()
-
getClientDataRecord
public <T extends Record> T getClientDataRecord(int recordType)
Find a record in the underlying EscherClientDataRecord- Parameters:
recordType- type of the record to search
-
getClientRecords
protected List<? extends Record> getClientRecords()
Search for EscherClientDataRecord, if found, convert its contents into an array of HSLF records- Returns:
- an array of HSLF records contained in the shape's EscherClientDataRecord or
null
-
getClientData
protected HSLFEscherClientDataRecord getClientData(boolean create)
Create a new HSLF-specific EscherClientDataRecord- Parameters:
create- if true, create the missing record- Returns:
- the client record or null if it was missing and create wasn't activated
-
-