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 java.lang.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).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
draw(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D bounds)
Convenience method to draw a single shapejava.awt.geom.Rectangle2D
getAnchor()
Returns the anchor (the bounding box rectangle) of this shape.<T extends Record>
TgetClientDataRecord(int recordType)
Find a record in the underlying EscherClientDataRecord<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, RecordTypes recordId)
<T extends EscherRecord>
TgetEscherChild(RecordTypes recordId)
AbstractEscherOptRecord
getEscherOptRecord()
int
getEscherProperty(short propId)
Get the value of a simple escher property for this shape.int
getEscherProperty(short propId, int defaultValue)
Get the value of a simple escher property for this shape.static <T extends EscherProperty>
TgetEscherProperty(AbstractEscherOptRecord opt, int propId)
Returns escher property by id.HSLFFill
getFill()
Fill properties of this shapeFillStyle
getFillStyle()
boolean
getFlipHorizontal()
boolean
getFlipVertical()
ShapeContainer<HSLFShape,HSLFTextParagraph>
getParent()
double
getRotation()
int
getShapeId()
Returns a unique identifier for this shape within the current slide.java.lang.String
getShapeName()
ShapeType
getShapeType()
HSLFSheet
getSheet()
EscherContainerRecord
getSpContainer()
boolean
isPlaceholder()
void
moveTo(double x, double y)
Moves the top left corner of the shape to the specified point.void
setAnchor(java.awt.geom.Rectangle2D anchor)
Sets the anchor (the bounding box rectangle) of this shape.void
setEscherProperty(short propId, int value)
Set an simple escher property for this shape.static void
setEscherProperty(AbstractEscherOptRecord opt, short propId, int value)
Set an escher property for this shape.void
setFlipHorizontal(boolean flip)
void
setFlipVertical(boolean flip)
void
setRotation(double theta)
void
setShapeId(int id)
Sets shape IDvoid
setShapeType(ShapeType type)
void
setSheet(HSLFSheet sheet)
Assign theSlideShow
this shape belongs to
-
-
-
Method Detail
-
getParent
public ShapeContainer<HSLFShape,HSLFTextParagraph> getParent()
- Specified by:
getParent
in interfaceShape<HSLFShape,HSLFTextParagraph>
- Returns:
- the parent of this shape
-
getShapeName
public java.lang.String getShapeName()
- Specified by:
getShapeName
in interfaceShape<HSLFShape,HSLFTextParagraph>
- Returns:
- name of the shape.
-
getShapeType
public ShapeType getShapeType()
-
setShapeType
public void setShapeType(ShapeType type)
-
getAnchor
public java.awt.geom.Rectangle2D getAnchor()
Returns the anchor (the bounding box rectangle) of this shape. All coordinates are expressed in points (72 dpi).- Specified by:
getAnchor
in interfaceShape<HSLFShape,HSLFTextParagraph>
- Returns:
- the anchor of this shape
-
setAnchor
public void setAnchor(java.awt.geom.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
null
if not found.
-
getEscherChild
public static <T extends EscherRecord> T getEscherChild(EscherContainerRecord owner, RecordTypes recordId)
- Since:
- POI 3.14-Beta2
-
getEscherChild
public <T extends EscherRecord> T getEscherChild(int recordId)
-
getEscherChild
public <T extends EscherRecord> T getEscherChild(RecordTypes recordId)
- Since:
- POI 3.14-Beta2
-
getEscherProperty
public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, int propId)
Returns escher property by id.- Returns:
- escher property or
null
if not found.
-
setEscherProperty
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 void setEscherProperty(short propId, int value)
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.
-
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(short propId, int defaultValue)
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.
-
getSpContainer
public EscherContainerRecord getSpContainer()
- Returns:
- The shape container and it's children that can represent this shape.
-
getSheet
public HSLFSheet getSheet()
- Specified by:
getSheet
in interfaceShape<HSLFShape,HSLFTextParagraph>
- Returns:
- the
SlideShow
this shape belongs to
-
setSheet
public void setSheet(HSLFSheet sheet)
Assign theSlideShow
this shape belongs to- Parameters:
sheet
- owner of this shape
-
getShapeId
public int getShapeId()
Description copied from interface:Shape
Returns a unique identifier for this shape within the current slide. This ID may be used to assist in uniquely identifying this object so that it can be referred to by other parts of the document.If multiple objects within the same slide share the same id attribute value, then the document shall be considered non-conformant.
- Specified by:
getShapeId
in interfaceShape<HSLFShape,HSLFTextParagraph>
- Returns:
- unique id of this shape
-
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(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D bounds)
Description copied from interface:Shape
Convenience method to draw a single shape- Specified by:
draw
in interfaceShape<HSLFShape,HSLFTextParagraph>
- Parameters:
graphics
- the graphics contextbounds
- the rectangle to fit the shape to. if null, the bounds of the shape are used.
-
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
-
-