Package org.apache.poi.hssf.usermodel
Class HSSFPatriarch
java.lang.Object
org.apache.poi.hssf.usermodel.HSSFPatriarch
- All Implemented Interfaces:
Iterable<HSSFShape>
,HSSFShapeContainer
,Drawing<HSSFShape>
,ShapeContainer<HSSFShape>
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add a shape to this drawingvoid
clear()
remove all shapes inside patriarchboolean
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)int
Total count of all children and their children's children.createAnchor
(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2) Creates a new client anchor and sets the top-left and bottom-right coordinates of the anchor.createCellComment
(ClientAnchor anchor) Creates a comment.createComment
(HSSFAnchor anchor) Constructs a cell comment.createGroup
(HSSFClientAnchor anchor) Creates a new group record stored under this patriarch.createObjectData
(ClientAnchor anchor, int storageId, int pictureIndex) Adds a new OLE Package ShapecreatePicture
(HSSFClientAnchor anchor, int pictureIndex) Creates a picture.createPicture
(ClientAnchor anchor, int pictureIndex) Creates a picture.createPolygon
(HSSFClientAnchor anchor) Creates a polygoncreateSimpleShape
(HSSFClientAnchor anchor) Creates a simple shape.createTextbox
(HSSFClientAnchor anchor) Constructs a textbox under the patriarch.Returns the aggregate escher record we're bound toReturns a unmodifiable list of all shapes contained by the patriarch.protected HSSFSheet
getSheet()
int
getX1()
int
getX2()
int
getY1()
int
getY2()
iterator()
protected void
check if any shapes contain wrong data At now(13.08.2010) check if patriarch contains 2 or more comments with same coordinatesboolean
removeShape
(HSSFShape shape) remove first level shapesvoid
setCoordinates
(int x1, int y1, int x2, int y2) Sets the coordinate space of this group.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
preSerialize
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 -
removeShape
Description copied from interface:HSSFShapeContainer
remove first level shapes- Specified by:
removeShape
in interfaceHSSFShapeContainer
- Parameters:
shape
- to be removed- Returns:
- true of shape is removed
-
createGroup
Creates a new group record stored under this patriarch.- Parameters:
anchor
- the client anchor describes how this group is attached to the sheet.- Returns:
- the newly created group.
-
createSimpleShape
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
- the client anchor describes how this group is attached to the sheet.- Returns:
- the newly created shape.
-
createPicture
Creates a picture.- Parameters:
anchor
- the client anchor describes how this group is attached to the sheet.pictureIndex
- - pointer to the byte array saved inside workbook in escher bse record- Returns:
- the newly created shape.
-
createPicture
Description copied from interface:Drawing
Creates a picture.- Specified by:
createPicture
in interfaceDrawing<HSSFShape>
- Parameters:
anchor
- the client anchor describes how this picture is attached to the sheet.pictureIndex
- the index of the picture in the workbook collection of pictures.- Returns:
- newly created shape
-
createObjectData
Description copied from interface:Drawing
Adds a new OLE Package Shape- Specified by:
createObjectData
in interfaceDrawing<HSSFShape>
- Parameters:
anchor
- the client anchor describes how this picture is attached to the sheet.storageId
- the storageId returned byWorkbook.addOlePackage(byte[], String, String, String)
pictureIndex
- the index of the picture (used as preview image) in the workbook collection of pictures.- Returns:
- newly created shape
-
createPolygon
Creates a polygon- Parameters:
anchor
- the client anchor describes how this group is attached to the sheet.- Returns:
- the newly created shape.
-
createTextbox
Constructs a textbox under the patriarch.- Parameters:
anchor
- the client anchor describes how this group is attached to the sheet.- Returns:
- the newly created textbox.
-
createComment
Constructs a cell comment.- Parameters:
anchor
- the client anchor describes how this comment is attached to the sheet.- Returns:
- the newly created comment.
-
createCellComment
Description copied from interface:Drawing
Creates a comment.- Specified by:
createCellComment
in interfaceDrawing<HSSFShape>
- Parameters:
anchor
- the client anchor describes how this comment is attached to the sheet.- Returns:
- the newly created comment.
-
getChildren
Returns a unmodifiable list of all shapes contained by the patriarch.- Specified by:
getChildren
in interfaceHSSFShapeContainer
- Returns:
- Any children contained by this shape.
-
addShape
add a shape to this drawing- Specified by:
addShape
in interfaceHSSFShapeContainer
- Parameters:
shape
-
-
countOfAllChildren
public int countOfAllChildren()Total count of all children and their children's children.- Returns:
- count of shapes including shapes inside shape groups
-
setCoordinates
public void setCoordinates(int x1, int y1, int x2, int y2) Sets the coordinate space of this group. All children are constrained to these coordinates.- Specified by:
setCoordinates
in interfaceHSSFShapeContainer
-
clear
public void clear()remove all shapes inside patriarch- Specified by:
clear
in interfaceHSSFShapeContainer
-
containsChart
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) -
getX1
public int getX1()- Specified by:
getX1
in interfaceHSSFShapeContainer
- Returns:
- x coordinate of the left up corner
-
getY1
public int getY1()- Specified by:
getY1
in interfaceHSSFShapeContainer
- Returns:
- y coordinate of the left up corner
-
getX2
public int getX2()- Specified by:
getX2
in interfaceHSSFShapeContainer
- Returns:
- x coordinate of the right down corner
-
getY2
public int getY2()- Specified by:
getY2
in interfaceHSSFShapeContainer
- Returns:
- y coordinate of the right down corner
-
getBoundAggregate
Returns the aggregate escher record we're bound to- Returns:
- - low level representation of sheet drawing data
-
createAnchor
public HSSFClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2) Creates a new client anchor and sets the top-left and bottom-right coordinates of the anchor.- Specified by:
createAnchor
in interfaceDrawing<HSSFShape>
- Parameters:
dx1
- the x coordinate in EMU within the first cell.dy1
- the y coordinate in EMU within the first cell.dx2
- the x coordinate in EMU within the second cell.dy2
- the y coordinate in EMU within the second cell.col1
- the column (0 based) of the first cell.row1
- the row (0 based) of the first cell.col2
- the column (0 based) of the second cell.row2
- the row (0 based) of the second cell.- Returns:
- the newly created client anchor
-
iterator
-
getSheet
-