org.apache.poi.xslf.usermodel
Class XSLFShape

java.lang.Object
  extended by org.apache.poi.xslf.usermodel.XSLFShape
All Implemented Interfaces:
Shape<XSLFShape,XSLFTextParagraph>
Direct Known Subclasses:
XSLFGraphicFrame, XSLFGroupShape, XSLFShadow, XSLFSimpleShape

@Beta
public abstract class XSLFShape
extends java.lang.Object
implements Shape<XSLFShape,XSLFTextParagraph>

Base super-class class for all shapes in PresentationML

Author:
Yegor Kozlov

Constructor Summary
protected XSLFShape(org.apache.xmlbeans.XmlObject shape, XSLFSheet sheet)
           
 
Method Summary
 void draw(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D bounds)
          Convenience method to draw a single shape
protected  boolean fetchShapeProperty(PropertyFetcher<?> visitor)
          Walk up the inheritance tree and fetch shape properties.
protected  org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties getBgPr()
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference getBgRef()
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps getCNvPr()
           
protected  org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder getCTPlaceholder()
           
protected  PaintStyle getFillPaint()
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties getGrpSpPr()
           
protected  PaintStyle getPaint(org.apache.xmlbeans.XmlObject spPr, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr)
           
 XSLFShapeContainer getParent()
           
 Placeholder getPlaceholder()
           
 int getShapeId()
          Returns a unique identifier for this shape within the current document.
 java.lang.String getShapeName()
           
 XSLFSheet getSheet()
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties getSpPr()
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle getSpStyle()
           
 org.apache.xmlbeans.XmlObject getXmlObject()
           
protected  PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties blipFill, PackagePart parentPart)
           
protected  PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties gradFill, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr)
           
protected  PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties solidFill, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr)
           
protected  PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference fillRef)
           
protected  PaintStyle selectPaint(org.apache.xmlbeans.XmlObject obj, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr, PackagePart parentPart)
          Convert shape fill into java.awt.Paint.
protected
<T extends org.apache.xmlbeans.XmlObject>
T
selectProperty(java.lang.Class<T> resultClass, java.lang.String xquery)
          As there's no xmlbeans hierarchy, but XSLF works with subclassing, not all child classes work with a CTShape object, but often contain the same properties.
 void setParent(XSLFShapeContainer parent)
           
protected  void setPlaceholder(Placeholder placeholder)
          Specifies that the corresponding shape should be represented by the generating application as a placeholder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.poi.sl.usermodel.Shape
getAnchor
 

Constructor Detail

XSLFShape

protected XSLFShape(org.apache.xmlbeans.XmlObject shape,
                    XSLFSheet sheet)
Method Detail

getXmlObject

public final org.apache.xmlbeans.XmlObject getXmlObject()
Returns:
the xml bean holding this shape's data

getSheet

public XSLFSheet getSheet()
Specified by:
getSheet in interface Shape<XSLFShape,XSLFTextParagraph>
Returns:
the sheet this shape belongs to

getShapeName

public java.lang.String getShapeName()
Returns:
human-readable name of this shape, e.g. "Rectange 3"

getShapeId

public int getShapeId()
Returns a unique identifier for this shape within the current document. 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 document share the same id attribute value, then the document shall be considered non-conformant.

Returns:
unique id of this shape

setParent

public void setParent(XSLFShapeContainer parent)

getParent

public XSLFShapeContainer getParent()
Specified by:
getParent in interface Shape<XSLFShape,XSLFTextParagraph>

getFillPaint

protected PaintStyle getFillPaint()

getBgPr

protected org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties getBgPr()

getBgRef

protected org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference getBgRef()

getGrpSpPr

protected org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties getGrpSpPr()

getCNvPr

protected org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps getCNvPr()

getSpPr

protected org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties getSpPr()

getSpStyle

protected org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle getSpStyle()

getCTPlaceholder

protected org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder getCTPlaceholder()

getPlaceholder

public Placeholder getPlaceholder()

setPlaceholder

protected void setPlaceholder(Placeholder placeholder)
Specifies that the corresponding shape should be represented by the generating application as a placeholder. When a shape is considered a placeholder by the generating application it can have special properties to alert the user that they may enter content into the shape. Different types of placeholders are allowed and can be specified by using the placeholder type attribute for this element

Parameters:
placeholder -

selectProperty

protected <T extends org.apache.xmlbeans.XmlObject> T selectProperty(java.lang.Class<T> resultClass,
                                                                     java.lang.String xquery)
As there's no xmlbeans hierarchy, but XSLF works with subclassing, not all child classes work with a CTShape object, but often contain the same properties. This method is the generalized form of selecting and casting those properties.

Parameters:
resultClass - the requested result class
xquery - the simple (xmlbean) xpath expression to the property
Returns:
the xml object at the xpath location, or null if not found

fetchShapeProperty

protected boolean fetchShapeProperty(PropertyFetcher<?> visitor)
Walk up the inheritance tree and fetch shape properties. The following order of inheritance is assumed:

slide <-- slideLayout <-- slideMaster

Parameters:
visitor - the object that collects the desired property
Returns:
true if the property was fetched

getPaint

protected PaintStyle getPaint(org.apache.xmlbeans.XmlObject spPr,
                              org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr)

selectPaint

protected PaintStyle selectPaint(org.apache.xmlbeans.XmlObject obj,
                                 org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr,
                                 PackagePart parentPart)
Convert shape fill into java.awt.Paint. The result is either Color or TexturePaint or GradientPaint or null

Parameters:
obj - the xml to read. Must contain elements from the EG_ColorChoice group: a:scrgbClr RGB Color Model - Percentage Variant a:srgbClr RGB Color Model - Hex Variant a:hslClr Hue, Saturation, Luminance Color Model a:sysClr System Color a:schemeClr Scheme Color a:prstClr Preset Color
phClr - context color
parentPart - the parent package part. Any external references (images, etc.) are resolved relative to it.
Returns:
the applied Paint or null if none was applied

selectPaint

protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties solidFill,
                                 org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr)

selectPaint

protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties blipFill,
                                 PackagePart parentPart)

selectPaint

protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties gradFill,
                                 org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor phClr)

selectPaint

protected PaintStyle selectPaint(org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference fillRef)

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 interface Shape<XSLFShape,XSLFTextParagraph>
Parameters:
graphics - the graphics context
bounds - the rectangle to fit the shape to. if null, the bounds of the shape are used.


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