Top Description Fields Constructors Methods
org.apache.poi.hssf.usermodel

public final Class HSSFPatriarch

extends Object
implements HSSFShapeContainer, Drawing<HSSFShape>
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.usermodel.Drawing, org.apache.poi.ss.usermodel.ShapeContainer, java.lang.Iterable, org.apache.poi.hssf.usermodel.HSSFShapeContainer
Imports
java.io.FileNotFoundException, java.util.ArrayList, .Collections, .HashSet, .Iterator, .List, .Map, .Set, .Spliterator, org.apache.poi.ddf.EscherComplexProperty, .EscherContainerRecord, .EscherDgRecord, .EscherOptRecord, .EscherProperty, .EscherRecord, .EscherSpRecord, .EscherSpgrRecord, org.apache.poi.hssf.model.DrawingManager2, org.apache.poi.hssf.record.CommonObjectDataSubRecord, .EmbeddedObjectRefSubRecord, .EndSubRecord, .EscherAggregate, .FtCfSubRecord, .FtPioGrbitSubRecord, .NoteRecord, .ObjRecord, org.apache.poi.ss.util.CellReference, org.apache.poi.poifs.filesystem.DirectoryEntry, .DirectoryNode, org.apache.poi.ss.usermodel.ClientAnchor, .Drawing, .Workbook, org.apache.poi.util.HexDump, .Internal, .StringUtil

The patriarch is the toplevel container for shapes in a sheet. It does little other than act as a container for other shapes and groups.

Field Summary

Modifier and TypeField and Description
private EscherAggregate
_boundAggregate

The EscherAggregate we have been bound to.

private final EscherContainerRecord
private final List<HSSFShape>
private final HSSFSheet
private final EscherSpgrRecord

Constructor Summary

AccessConstructor and Description
pack-priv
HSSFPatriarch(HSSFSheet
the sheet this patriarch is stored in.
sheet
,
EscherAggregate
-low level representation of all binary data inside sheet
boundAggregate
)

Creates the patriarch.

Method Summary

Modifier and TypeMethod and Description
public void
pack-priv void
pack-priv void
buildShapeTree()

create shape tree from existing escher records tree

public void
clear()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.clear.

remove all shapes inside patriarch

public boolean
containsChart()

Does this HSSFPatriarch contain a chart?

public int

Returns:

count of shapes including shapes inside shape groups
countOfAllChildren
()

Total count of all children and their children's children.

public HSSFClientAnchor

Returns:

the newly created client anchor
createAnchor
(int
the x coordinate in EMU within the first cell.
dx1
,
int
the y coordinate in EMU within the first cell.
dy1
,
int
the x coordinate in EMU within the second cell.
dx2
,
int
the y coordinate in EMU within the second cell.
dy2
,
int
the column (0 based) of the first cell.
col1
,
int
the row (0 based) of the first cell.
row1
,
int
the column (0 based) of the second cell.
col2
,
int
the row (0 based) of the second cell.
row2
)

Implements org.apache.poi.ss.usermodel.Drawing.createAnchor.

Creates a new client anchor and sets the top-left and bottom-right coordinates of the anchor.

public HSSFComment
createCellComment(ClientAnchor
the client anchor describes how this comment is attached to the sheet.
anchor
)

Implements org.apache.poi.ss.usermodel.Drawing.createCellComment.

Creates a comment.

pack-priv HSSFSimpleShape
createComboBox(HSSFAnchor anchor)

YK: used to create autofilters

public HSSFComment

Returns:

the newly created comment.
createComment
(HSSFAnchor
the client anchor describes how this comment is attached to the sheet.
anchor
)

Constructs a cell comment.

public HSSFShapeGroup

Returns:

the newly created group.
createGroup
(HSSFClientAnchor
the client anchor describes how this group is attached to the sheet.
anchor
)

Creates a new group record stored under this patriarch.

public HSSFObjectData
createObjectData(ClientAnchor
the client anchor describes how this picture is attached to the sheet.
anchor
,
int storageId, int
the index of the picture (used as preview image) in the workbook collection of pictures.
pictureIndex
)

Implements org.apache.poi.ss.usermodel.Drawing.createObjectData.

Adds a new OLE Package Shape

pack-priv static HSSFPatriarch

Returns:

new patriarch with copies of all shapes from the existing patriarch
createPatriarch
(HSSFPatriarch
- copy all the shapes from this patriarch to new one
patriarch
,
HSSFSheet
where must be located new patriarch
sheet
)

used to clone patriarch create patriarch from existing one

public HSSFPicture

Returns:

the newly created shape.
createPicture
(HSSFClientAnchor
the client anchor describes how this group is attached to the sheet.
anchor
,
int
- pointer to the byte array saved inside workbook in escher bse record
pictureIndex
)

Creates a picture.

public HSSFPicture

Returns:

newly created shape
createPicture
(ClientAnchor
the client anchor describes how this picture is attached to the sheet.
anchor
,
int
the index of the picture in the workbook collection of pictures.
pictureIndex
)

Implements org.apache.poi.ss.usermodel.Drawing.createPicture.

Creates a picture.

public HSSFPolygon

Returns:

the newly created shape.
createPolygon
(HSSFClientAnchor
the client anchor describes how this group is attached to the sheet.
anchor
)

Creates a polygon

public HSSFSimpleShape

Returns:

the newly created shape.
createSimpleShape
(HSSFClientAnchor
the client anchor describes how this group is attached to the sheet.
anchor
)

Creates a simple shape.

public HSSFTextbox

Returns:

the newly created textbox.
createTextbox
(HSSFClientAnchor
the client anchor describes how this group is attached to the sheet.
anchor
)

Constructs a textbox under the patriarch.

public EscherAggregate

Returns:

- low level representation of sheet drawing data
getBoundAggregate
()

Returns the aggregate escher record we're bound to

public List<HSSFShape>
getChildren()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getChildren.

Returns an unmodifiable list of all shapes contained by the patriarch.

protected HSSFSheet
public int

Returns:

x coordinate of the left up corner
getX1
()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getX1.

public int

Returns:

x coordinate of the right down corner
getX2
()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getX2.

public int

Returns:

y coordinate of the left up corner
getY1
()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getY1.

public int

Returns:

y coordinate of the right down corner
getY2
()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getY2.

public Iterator<HSSFShape>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

pack-priv int

Returns:

new unique shapeId
newShapeId
()

private void
protected void
preSerialize()

check if any shapes contain wrong data At now(13.08.2010) check if patriarch contains 2 or more comments with same coordinates

public boolean

Returns:

true of shape is removed
removeShape
(HSSFShape
to be removed
shape
)

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.removeShape.

remove first level shapes

public void
setCoordinates(int x1, int y1, int x2, int y2)

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.setCoordinates.

Sets the coordinate space of this group.

private void
public Spliterator<HSSFShape>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_boundAggregateback to summary
private EscherAggregate _boundAggregate

The EscherAggregate we have been bound to. (This will handle writing us out into records, and building up our shapes from the records)

_mainSpgrContainerback to summary
private final EscherContainerRecord _mainSpgrContainer
_shapesback to summary
private final List<HSSFShape> _shapes
_sheetback to summary
private final HSSFSheet _sheet
_spgrRecordback to summary
private final EscherSpgrRecord _spgrRecord

Constructor Detail

HSSFPatriarchback to summary
pack-priv HSSFPatriarch(HSSFSheet sheet, EscherAggregate boundAggregate)

Creates the patriarch.

Parameters
sheet:HSSFSheet

the sheet this patriarch is stored in.

boundAggregate:EscherAggregate

-low level representation of all binary data inside sheet

Method Detail

addShapeback to summary
public void addShape(HSSFShape shape)

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.addShape.

add a shape to this drawing

Annotations
@Override
@Internal
afterCreateback to summary
pack-priv void afterCreate()
buildShapeTreeback to summary
pack-priv void buildShapeTree()

create shape tree from existing escher records tree

clearback to summary
public void clear()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.clear.

remove all shapes inside patriarch

Annotations
@Override
containsChartback to summary
public boolean containsChart()

Does this HSSFPatriarch contain a chart? (Technically a reference to a chart, since they get stored in a different block of records) FIXME - detect chart in all cases (only seems to work on some charts so far)

countOfAllChildrenback to summary
public int countOfAllChildren()

Total count of all children and their children's children.

Returns:int

count of shapes including shapes inside shape groups

createAnchorback to summary
public HSSFClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2)

Implements org.apache.poi.ss.usermodel.Drawing.createAnchor.

Creates a new client anchor and sets the top-left and bottom-right coordinates of the anchor.

Parameters
dx1:int

the x coordinate in EMU within the first cell.

dy1:int

the y coordinate in EMU within the first cell.

dx2:int

the x coordinate in EMU within the second cell.

dy2:int

the y coordinate in EMU within the second cell.

col1:int

the column (0 based) of the first cell.

row1:int

the row (0 based) of the first cell.

col2:int

the column (0 based) of the second cell.

row2:int

the row (0 based) of the second cell.

Returns:HSSFClientAnchor

the newly created client anchor

Annotations
@Override
createCellCommentback to summary
public HSSFComment createCellComment(ClientAnchor anchor)

Implements org.apache.poi.ss.usermodel.Drawing.createCellComment.

Doc from org.apache.poi.ss.usermodel.Drawing.createCellComment.

Creates a comment.

Parameters
anchor:ClientAnchor

the client anchor describes how this comment is attached to the sheet.

Returns:HSSFComment

the newly created comment.

Annotations
@Override
createComboBoxback to summary
pack-priv HSSFSimpleShape createComboBox(HSSFAnchor anchor)

YK: used to create autofilters

See Also
org.apache.poi.hssf.usermodel.HSSFSheet#setAutoFilter(org.apache.poi.ss.util.CellRangeAddress)
createCommentback to summary
public HSSFComment createComment(HSSFAnchor anchor)

Constructs a cell comment.

Parameters
anchor:HSSFAnchor

the client anchor describes how this comment is attached to the sheet.

Returns:HSSFComment

the newly created comment.

createGroupback to summary
public HSSFShapeGroup createGroup(HSSFClientAnchor anchor)

Creates a new group record stored under this patriarch.

Parameters
anchor:HSSFClientAnchor

the client anchor describes how this group is attached to the sheet.

Returns:HSSFShapeGroup

the newly created group.

createObjectDataback to summary
public HSSFObjectData createObjectData(ClientAnchor anchor, int storageId, int pictureIndex)

Implements org.apache.poi.ss.usermodel.Drawing.createObjectData.

Doc from org.apache.poi.ss.usermodel.Drawing.createObjectData.

Adds a new OLE Package Shape

Parameters
anchor:ClientAnchor

the client anchor describes how this picture is attached to the sheet.

storageId:int

the storageId returned by Workbook#addOlePackage(byte[], String, String, String)

pictureIndex:int

the index of the picture (used as preview image) in the workbook collection of pictures.

Returns:HSSFObjectData

newly created shape

Annotations
@Override
createPatriarchback to summary
pack-priv static HSSFPatriarch createPatriarch(HSSFPatriarch patriarch, HSSFSheet sheet)

used to clone patriarch create patriarch from existing one

Parameters
patriarch:HSSFPatriarch

- copy all the shapes from this patriarch to new one

sheet:HSSFSheet

where must be located new patriarch

Returns:HSSFPatriarch

new patriarch with copies of all shapes from the existing patriarch

createPictureback to summary
public HSSFPicture createPicture(HSSFClientAnchor anchor, int pictureIndex)

Creates a picture.

Parameters
anchor:HSSFClientAnchor

the client anchor describes how this group is attached to the sheet.

pictureIndex:int

- pointer to the byte array saved inside workbook in escher bse record

Returns:HSSFPicture

the newly created shape.

createPictureback to summary
public HSSFPicture createPicture(ClientAnchor anchor, int pictureIndex)

Implements org.apache.poi.ss.usermodel.Drawing.createPicture.

Doc from org.apache.poi.ss.usermodel.Drawing.createPicture.

Creates a picture.

Parameters
anchor:ClientAnchor

the client anchor describes how this picture is attached to the sheet.

pictureIndex:int

the index of the picture in the workbook collection of pictures.

Returns:HSSFPicture

newly created shape

Annotations
@Override
createPolygonback to summary
public HSSFPolygon createPolygon(HSSFClientAnchor anchor)

Creates a polygon

Parameters
anchor:HSSFClientAnchor

the client anchor describes how this group is attached to the sheet.

Returns:HSSFPolygon

the newly created shape.

createSimpleShapeback to summary
public HSSFSimpleShape createSimpleShape(HSSFClientAnchor anchor)

Creates a simple shape. This includes such shapes as lines, rectangles, and ovals.

Note

Microsoft Excel seems to sometimes disallow higher y1 than y2 or higher x1 than x2 in the anchor, you might need to reverse them and draw shapes vertically or horizontally flipped!

Parameters
anchor:HSSFClientAnchor

the client anchor describes how this group is attached to the sheet.

Returns:HSSFSimpleShape

the newly created shape.

createTextboxback to summary
public HSSFTextbox createTextbox(HSSFClientAnchor anchor)

Constructs a textbox under the patriarch.

Parameters
anchor:HSSFClientAnchor

the client anchor describes how this group is attached to the sheet.

Returns:HSSFTextbox

the newly created textbox.

getBoundAggregateback to summary
public EscherAggregate getBoundAggregate()

Returns the aggregate escher record we're bound to

Returns:EscherAggregate

- low level representation of sheet drawing data

Annotations
@Internal
getChildrenback to summary
public List<HSSFShape> getChildren()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getChildren.

Returns an unmodifiable list of all shapes contained by the patriarch.

Returns:List<HSSFShape>

Doc from org.apache.poi.hssf.usermodel.HSSFShapeContainer.getChildren.

Any children contained by this shape.

Annotations
@Override
getSheetback to summary
protected HSSFSheet getSheet()
getX1back to summary
public int getX1()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getX1.

Returns:int

x coordinate of the left up corner

Annotations
@Override
getX2back to summary
public int getX2()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getX2.

Returns:int

x coordinate of the right down corner

Annotations
@Override
getY1back to summary
public int getY1()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getY1.

Returns:int

y coordinate of the left up corner

Annotations
@Override
getY2back to summary
public int getY2()

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.getY2.

Returns:int

y coordinate of the right down corner

Annotations
@Override
iteratorback to summary
public Iterator<HSSFShape> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<HSSFShape>

an Iterator.

Annotations
@Override
newShapeIdback to summary
pack-priv int newShapeId()
Returns:int

new unique shapeId

onCreateback to summary
private void onCreate(HSSFShape shape)
preSerializeback to summary
protected void preSerialize()

check if any shapes contain wrong data At now(13.08.2010) check if patriarch contains 2 or more comments with same coordinates

removeShapeback to summary
public boolean removeShape(HSSFShape shape)

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.removeShape.

Doc from org.apache.poi.hssf.usermodel.HSSFShapeContainer.removeShape.

remove first level shapes

Parameters
shape:HSSFShape

to be removed

Returns:boolean

true of shape is removed

Annotations
@Override
setCoordinatesback to summary
public void setCoordinates(int x1, int y1, int x2, int y2)

Implements org.apache.poi.hssf.usermodel.HSSFShapeContainer.setCoordinates.

Sets the coordinate space of this group. All children are constrained to these coordinates.

Annotations
@Override
setFlipFlagsback to summary
private void setFlipFlags(HSSFShape shape)
spliteratorback to summary
public Spliterator<HSSFShape> spliterator()

Overrides default java.lang.Iterable.spliterator.

Doc from java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

Returns:Spliterator<HSSFShape>

a Spliterator over the elements described by this Iterable.

Annotations
@Override
Since
POI 5.2.0