org.apache.poi.xssf.usermodel
Class XSSFDrawing

java.lang.Object
  extended by org.apache.poi.POIXMLDocumentPart
      extended by org.apache.poi.xssf.usermodel.XSSFDrawing
All Implemented Interfaces:
Drawing

public final class XSSFDrawing
extends POIXMLDocumentPart
implements Drawing

Represents a SpreadsheetML drawing

Author:
Yegor Kozlov

Field Summary
 
Fields inherited from class org.apache.poi.POIXMLDocumentPart
DEFAULT_XML_OPTIONS
 
Constructor Summary
protected XSSFDrawing()
          Create a new SpreadsheetML drawing
protected XSSFDrawing(PackagePart part, PackageRelationship rel)
          Construct a SpreadsheetML drawing from a package part
 
Method Summary
protected  PackageRelationship addPictureReference(int pictureIndex)
          Add the indexed picture to this drawing relations
protected  void commit()
          Save the content in the underlying package part.
 XSSFComment createCellComment(ClientAnchor anchor)
          Creates a cell comment.
 XSSFConnector createConnector(XSSFClientAnchor anchor)
          Creates a simple shape.
 XSSFShapeGroup createGroup(XSSFClientAnchor anchor)
          Creates a simple shape.
 XSSFPicture createPicture(ClientAnchor anchor, int pictureIndex)
           
 XSSFPicture createPicture(XSSFClientAnchor anchor, int pictureIndex)
          Creates a picture.
 XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor)
          Creates a simple shape.
 XSSFTextBox createTextbox(XSSFClientAnchor anchor)
          Constructs a textbox under the drawing.
 CTDrawing getCTDrawing()
          Return the underlying CTDrawing bean, the root element of the SpreadsheetML Drawing part.
 
Methods inherited from class org.apache.poi.POIXMLDocumentPart
addRelation, createRelationship, createRelationship, createRelationship, getPackagePart, getPackageRelationship, getParent, getRelations, onDocumentCreate, onDocumentRead, onSave, read, removeRelation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XSSFDrawing

protected XSSFDrawing()
Create a new SpreadsheetML drawing

See Also:
XSSFSheet.createDrawingPatriarch()

XSSFDrawing

protected XSSFDrawing(PackagePart part,
                      PackageRelationship rel)
               throws java.io.IOException,
                      XmlException
Construct a SpreadsheetML drawing from a package part

Parameters:
part - the package part holding the drawing data, the content type must be application/vnd.openxmlformats-officedocument.drawing+xml
rel - the package relationship holding this drawing, the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing
Throws:
java.io.IOException
XmlException
Method Detail

getCTDrawing

@Internal
public CTDrawing getCTDrawing()
Return the underlying CTDrawing bean, the root element of the SpreadsheetML Drawing part.

Returns:
the underlying CTDrawing bean

commit

protected void commit()
               throws java.io.IOException
Description copied from class: POIXMLDocumentPart
Save the content in the underlying package part. Default implementation is empty meaning that the package part is left unmodified. Sub-classes should override and add logic to marshal the "model" into Ooxml4J. For example, the code saving a generic XML entry may look as follows:

 protected void commit() throws IOException {
   PackagePart part = getPackagePart();
   OutputStream out = part.getOutputStream();
   XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
   bean.save(out, DEFAULT_XML_OPTIONS);
   out.close();
 }
  

Overrides:
commit in class POIXMLDocumentPart
Throws:
java.io.IOException

createTextbox

public XSSFTextBox createTextbox(XSSFClientAnchor anchor)
Constructs a textbox under the drawing.

Parameters:
anchor - the client anchor describes how this group is attached to the sheet.
Returns:
the newly created textbox.

createPicture

public XSSFPicture createPicture(XSSFClientAnchor anchor,
                                 int pictureIndex)
Creates a picture.

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, XSSFWorkbook.getAllPictures() .
Returns:
the newly created picture shape.

createPicture

public XSSFPicture createPicture(ClientAnchor anchor,
                                 int pictureIndex)
Specified by:
createPicture in interface Drawing

addPictureReference

protected PackageRelationship addPictureReference(int pictureIndex)
Add the indexed picture to this drawing relations

Parameters:
pictureIndex - the index of the picture in the workbook collection of pictures, XSSFWorkbook.getAllPictures() .

createSimpleShape

public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor)
Creates a simple shape. This includes such shapes as lines, rectangles, and ovals.

Parameters:
anchor - the client anchor describes how this group is attached to the sheet.
Returns:
the newly created shape.

createConnector

public XSSFConnector createConnector(XSSFClientAnchor anchor)
Creates a simple shape. This includes such shapes as lines, rectangles, and ovals.

Parameters:
anchor - the client anchor describes how this group is attached to the sheet.
Returns:
the newly created shape.

createGroup

public XSSFShapeGroup createGroup(XSSFClientAnchor anchor)
Creates a simple shape. This includes such shapes as lines, rectangles, and ovals.

Parameters:
anchor - the client anchor describes how this group is attached to the sheet.
Returns:
the newly created shape.

createCellComment

public XSSFComment createCellComment(ClientAnchor anchor)
Creates a cell comment.

Specified by:
createCellComment in interface Drawing
Parameters:
anchor - the client anchor describes how this comment is attached to the sheet.
Returns:
the newly created comment.


Copyright 2012 The Apache Software Foundation or its licensors, as applicable.