Shape

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.IShape, com.aspose.slides.IDOMObject

public class Shape implements IShape, IDOMObject

Represents a shape on a slide.

Methods

Method Description
isTextHolder() Determines whether the shape is TextHolder_PPT.
getPlaceholder() Returns the placeholder for a shape.
removePlaceholder() Defines that this shape isn’t a placeholder.
addPlaceholder(IPlaceholder placeholderToCopyFrom) Adds a new placeholder if there is no and sets placeholder properties to a specified one.
getBasePlaceholder() Returns a basic placeholder shape (shape from the layout and/or master slide that the current shape is inherited from).
getCustomData() Returns the shape’s custom data.
getRawFrame() Returns or sets the raw shape frame’s properties.
setRawFrame(IShapeFrame value) Returns or sets the raw shape frame’s properties.
getFrame() Returns or sets the shape frame’s properties.
setFrame(IShapeFrame value) Returns or sets the shape frame’s properties.
getLineFormat() Returns the LineFormat object that contains line formatting properties for a shape.
getThreeDFormat() Returns the ThreeDFormat object that 3d effect properties for a shape.
getEffectFormat() Returns the EffectFormat object which contains pixel effects applied to a shape.
getFillFormat() Returns the FillFormat object that contains fill formatting properties for a shape.
getThumbnail() Returns shape thumbnail.
getThumbnail(int bounds, float scaleX, float scaleY) Returns shape thumbnail.
writeAsSvg(OutputStream stream) Saves content of Shape as SVG file.
writeAsSvg(OutputStream stream, ISVGOptions svgOptions) Saves content of Shape as SVG file.
getHyperlinkClick() Returns or sets the hyperlink defined for mouse click.
setHyperlinkClick(IHyperlink value) Returns or sets the hyperlink defined for mouse click.
getHyperlinkMouseOver() Returns or sets the hyperlink defined for mouse over.
setHyperlinkMouseOver(IHyperlink value) Returns or sets the hyperlink defined for mouse over.
getHyperlinkManager() Returns the hyperlink manager.
getHidden() Determines whether the shape is hidden.
setHidden(boolean value) Determines whether the shape is hidden.
getZOrderPosition() Returns the position of a shape in the z-order.
getConnectionSiteCount() Returns the number of connection sites on the shape.
getRotation() Returns or sets the number of degrees the specified shape is rotated around the z-axis.
setRotation(float value) Returns or sets the number of degrees the specified shape is rotated around the z-axis.
getX() Returns or sets the x-coordinate of the upper-left corner of the shape.
setX(float value) Returns or sets the x-coordinate of the upper-left corner of the shape.
getY() Returns or sets the y-coordinate of the upper-left corner of the shape.
setY(float value) Returns or sets the y-coordinate of the upper-left corner of the shape.
getWidth() Returns or sets the width of the shape.
setWidth(float value) Returns or sets the width of the shape.
getHeight() Returns or sets the height of the shape.
setHeight(float value) Returns or sets the height of the shape.
getBlackWhiteMode() Property specifies how a shape will render in black-and-white display mode..
setBlackWhiteMode(byte value) Property specifies how a shape will render in black-and-white display mode..
getUniqueId() Gets unique shape identifier in presentation scope.
getOfficeInteropShapeId() Gets unique shape identifier in slide scope.
getAlternativeText() Returns or sets the alternative text associated with a shape.
setAlternativeText(String value) Returns or sets the alternative text associated with a shape.
getAlternativeTextTitle() Returns or sets the title of alternative text associated with a shape.
setAlternativeTextTitle(String value) Returns or sets the title of alternative text associated with a shape.
getName() Returns or sets the name of a shape.
setName(String value) Returns or sets the name of a shape.
getShapeLock() Returns shape’s locks.
isGrouped() Determines whether the shape is grouped.
getParentGroup() Returns parent GroupShape object if shape is grouped.
getParent_Immediate()
getSlide() Returns the parent slide of a shape.
getPresentation() Returns the parent presentation of a slide.

isTextHolder()

public final boolean isTextHolder()

Determines whether the shape is TextHolder_PPT. Read-only boolean .

Returns: boolean

getPlaceholder()

public final IPlaceholder getPlaceholder()

Returns the placeholder for a shape. Returns null if the shape has no placeholder. Read-only IPlaceholder.

Returns: IPlaceholder

removePlaceholder()

public final void removePlaceholder()

Defines that this shape isn’t a placeholder.

addPlaceholder(IPlaceholder placeholderToCopyFrom)

public final IPlaceholder addPlaceholder(IPlaceholder placeholderToCopyFrom)

Adds a new placeholder if there is no and sets placeholder properties to a specified one.

Parameters:

Parameter Type Description
placeholderToCopyFrom IPlaceholder Placeholder to copy content from.

Returns: IPlaceholder - New Placeholder(#getPlaceholder.getPlaceholder).

getBasePlaceholder()

public final IShape getBasePlaceholder()

Returns a basic placeholder shape (shape from the layout and/or master slide that the current shape is inherited from).


// get all (master/layout/slide) animated effects of the placeholder shape
 Presentation pres = new Presentation("sample.pptx");
 try {
     ISlide slide = pres.getSlides().get_Item(0);
     IShape shape = slide.getShapes().get_Item(0);
     IEffect[] shapeEffects = slide.getLayoutSlide().getTimeline().getMainSequence().getEffectsByShape(shape);
     IShape layoutShape = shape.getBasePlaceholder();
     IEffect[] layoutShapeEffects = slide.getLayoutSlide().getTimeline().getMainSequence().getEffectsByShape(layoutShape);
     IShape masterShape = layoutShape.getBasePlaceholder();
     IEffect[] masterShapeEffects = slide.getLayoutSlide().getMasterSlide().getTimeline().getMainSequence().getEffectsByShape(masterShape);
 } finally {
     if (pres != null) pres.dispose();
 }

A null is returned if the current shape is not inherited.

Returns: IShape

getCustomData()

public final ICustomData getCustomData()

Returns the shape’s custom data. Read-only ICustomData.

Returns: ICustomData

getRawFrame()

public final IShapeFrame getRawFrame()

Returns or sets the raw shape frame’s properties. Read/write IShapeFrame.


Code that attempts to assign undefined frame to IShape.getFrame() doesn't make sence in general case (particulary in case when parent GroupShape is multiple nested into other GroupShape-s). For example:
 
 IShape shape = ...;
 shape.setFrame(new ShapeFrame(Float.NaN, Float.NaN, Float.NaN, Float.NaN, NullableBool.NotDefined, NullableBool.NotDefined, Float.NaN));
 //or
 slide.getShapes().addAutoShape(ShapeType.RoundCornerRectangle, Float.NaN, Float.NaN, Float.NaN, Float.NaN);
 //Such code can lead to unclear situations. So restrictions had been added for using undefined values for IShape.getFrame(). Values of x, y, width, height, flipH, flipV and rotationAngle must be defined (not Float.NaN or NullableBool.NotDefined). Example code above now throws ArgumentException exception.
 //This applies to these use cases:
 IShape shape = ...;
 shape.setFrame(...); // cannot be undefined
 IShapeCollection shapes = ...;
 // x, y, width, height parameters cannot be Float.NaN:
 {
     shapes.addAudioFrameCD(...);
     shapes.addAudioFrameEmbedded(...);
     shapes.addAudioFrameLinked(...);
     shapes.addAutoShape(...);
     shapes.addChart(...);
     shapes.addConnector(...);
     shapes.addOleObjectFrame(...);
     shapes.addPictureFrame(...);
     shapes.addSmartArt(...);
     shapes.addTable(...);
     shapes.addVideoFrame(...);
     shapes.insertAudioFrameEmbedded(...);
     shapes.insertAudioFrameLinked(...);
     shapes.insertAutoShape(...);
     shapes.insertChart(...);
     shapes.insertConnector(...);
     shapes.insertOleObjectFrame(...);
     shapes.insertPictureFrame(...);
     shapes.insertTable(...);
     shapes.insertVideoFrame(...);
 }
 //But IShape.RawFrame frame properties can be undefined. This make sence when shape is linked to placeholder. Then undefined shape frame values is overridden from the parent placeholder shape. If there is no parent placeholder shape for that shape then that shape uses default values when it evaluates effective frame based on its IShape.RawFrame. Default values are 0 and NullableBool.False for x, y, width, height, flipH, flipV and rotationAngle. For example:
 IShape shape = ...; // shape is linked to placeholder
 shape.setRawFrame(new ShapeFrame(Float.NaN, Float.NaN, 100, Float.NaN, NullableBool.NotDefined, NullableBool.NotDefined, 0)); // now shape inherits x, y, height, flipH, flipV values form placeholder and overrides width=100 and rotationAngle=0.{code}

Returns: IShapeFrame

setRawFrame(IShapeFrame value)

public final void setRawFrame(IShapeFrame value)

Returns or sets the raw shape frame’s properties. Read/write IShapeFrame.


Code that attempts to assign undefined frame to IShape.getFrame() doesn't make sence in general case (particulary in case when parent GroupShape is multiple nested into other GroupShape-s). For example:
 
 IShape shape = ...;
 shape.setFrame(new ShapeFrame(Float.NaN, Float.NaN, Float.NaN, Float.NaN, NullableBool.NotDefined, NullableBool.NotDefined, Float.NaN));
 //or
 slide.getShapes().addAutoShape(ShapeType.RoundCornerRectangle, Float.NaN, Float.NaN, Float.NaN, Float.NaN);
 //Such code can lead to unclear situations. So restrictions had been added for using undefined values for IShape.getFrame(). Values of x, y, width, height, flipH, flipV and rotationAngle must be defined (not Float.NaN or NullableBool.NotDefined). Example code above now throws ArgumentException exception.
 //This applies to these use cases:
 IShape shape = ...;
 shape.setFrame(...); // cannot be undefined
 IShapeCollection shapes = ...;
 // x, y, width, height parameters cannot be Float.NaN:
 {
     shapes.addAudioFrameCD(...);
     shapes.addAudioFrameEmbedded(...);
     shapes.addAudioFrameLinked(...);
     shapes.addAutoShape(...);
     shapes.addChart(...);
     shapes.addConnector(...);
     shapes.addOleObjectFrame(...);
     shapes.addPictureFrame(...);
     shapes.addSmartArt(...);
     shapes.addTable(...);
     shapes.addVideoFrame(...);
     shapes.insertAudioFrameEmbedded(...);
     shapes.insertAudioFrameLinked(...);
     shapes.insertAutoShape(...);
     shapes.insertChart(...);
     shapes.insertConnector(...);
     shapes.insertOleObjectFrame(...);
     shapes.insertPictureFrame(...);
     shapes.insertTable(...);
     shapes.insertVideoFrame(...);
 }
 //But IShape.RawFrame frame properties can be undefined. This make sence when shape is linked to placeholder. Then undefined shape frame values is overridden from the parent placeholder shape. If there is no parent placeholder shape for that shape then that shape uses default values when it evaluates effective frame based on its IShape.RawFrame. Default values are 0 and NullableBool.False for x, y, width, height, flipH, flipV and rotationAngle. For example:
 IShape shape = ...; // shape is linked to placeholder
 shape.setRawFrame(new ShapeFrame(Float.NaN, Float.NaN, 100, Float.NaN, NullableBool.NotDefined, NullableBool.NotDefined, 0)); // now shape inherits x, y, height, flipH, flipV values form placeholder and overrides width=100 and rotationAngle=0.{code}

Parameters:

Parameter Type Description
value IShapeFrame

getFrame()

public final IShapeFrame getFrame()

Returns or sets the shape frame’s properties. Read/write IShapeFrame.


Value of each property of the returned IShapeFrame instance is not undefined (is not NaN or NotDefined). Value of each property of the assigned IShapeFrame instance must be not undefined (must be not NaN or NotDefined). You can set undefined values for RawFrame instance properties.

Returns: IShapeFrame

setFrame(IShapeFrame value)

public final void setFrame(IShapeFrame value)

Returns or sets the shape frame’s properties. Read/write IShapeFrame.


Value of each property of the returned IShapeFrame instance is not undefined (is not NaN or NotDefined). Value of each property of the assigned IShapeFrame instance must be not undefined (must be not NaN or NotDefined). You can set undefined values for RawFrame instance properties.

Parameters:

Parameter Type Description
value IShapeFrame

getLineFormat()

public ILineFormat getLineFormat()

Returns the LineFormat object that contains line formatting properties for a shape. Note: can return null for certain types of shapes which don’t have line properties. Read-only ILineFormat.

Returns: ILineFormat

getThreeDFormat()

public IThreeDFormat getThreeDFormat()

Returns the ThreeDFormat object that 3d effect properties for a shape. Note: can return null for certain types of shapes which don’t have 3d properties. Read-only IThreeDFormat.

Returns: IThreeDFormat

getEffectFormat()

public IEffectFormat getEffectFormat()

Returns the EffectFormat object which contains pixel effects applied to a shape. Note: can return null for certain types of shapes which don’t have effect properties. Read-only IEffectFormat.

Returns: IEffectFormat

getFillFormat()

public IFillFormat getFillFormat()

Returns the FillFormat object that contains fill formatting properties for a shape. Note: can return null for certain types of shapes which don’t have fill properties. Read-only IFillFormat.

Returns: IFillFormat

getThumbnail()

public final BufferedImage getThumbnail()

Returns shape thumbnail. ShapeThumbnailBounds.Shape shape thumbnail bounds type is used by default.

Returns: java.awt.image.BufferedImage - Shape thumbnail.

getThumbnail(int bounds, float scaleX, float scaleY)

public final BufferedImage getThumbnail(int bounds, float scaleX, float scaleY)

Returns shape thumbnail.

Parameters:

Parameter Type Description
bounds int Shape thumbnail bounds type.
scaleX float X scale
scaleY float Y scale

Returns: java.awt.image.BufferedImage - Shape thumbnail or null in case when ShapeThumbnailBounds.Appearance is used and a shape doesn’t have visible elements.

writeAsSvg(OutputStream stream)

public final void writeAsSvg(OutputStream stream)

Saves content of Shape as SVG file.

Parameters:

Parameter Type Description
stream java.io.OutputStream Target stream

writeAsSvg(OutputStream stream, ISVGOptions svgOptions)

public final void writeAsSvg(OutputStream stream, ISVGOptions svgOptions)

Saves content of Shape as SVG file.

Parameters:

Parameter Type Description
stream java.io.OutputStream Target stream
svgOptions ISVGOptions SVG generation options

getHyperlinkClick()

public final IHyperlink getHyperlinkClick()

Returns or sets the hyperlink defined for mouse click. Read/write IHyperlink.

Returns: IHyperlink

public final void setHyperlinkClick(IHyperlink value)

Returns or sets the hyperlink defined for mouse click. Read/write IHyperlink.

Parameters:

Parameter Type Description
value IHyperlink

getHyperlinkMouseOver()

public final IHyperlink getHyperlinkMouseOver()

Returns or sets the hyperlink defined for mouse over. Read/write IHyperlink.

Returns: IHyperlink

public final void setHyperlinkMouseOver(IHyperlink value)

Returns or sets the hyperlink defined for mouse over. Read/write IHyperlink.

Parameters:

Parameter Type Description
value IHyperlink

getHyperlinkManager()

public final IHyperlinkManager getHyperlinkManager()

Returns the hyperlink manager. Read-only IHyperlinkManager.

Returns: IHyperlinkManager

getHidden()

public final boolean getHidden()

Determines whether the shape is hidden. Read/write boolean .

Returns: boolean

setHidden(boolean value)

public final void setHidden(boolean value)

Determines whether the shape is hidden. Read/write boolean .

Parameters:

Parameter Type Description
value boolean

getZOrderPosition()

public int getZOrderPosition()

Returns the position of a shape in the z-order. Shapes[0] returns the shape at the back of the z-order, and Shapes[Shapes.Count - 1] returns the shape at the front of the z-order. Read-only int .

Returns: int

getConnectionSiteCount()

public final int getConnectionSiteCount()

Returns the number of connection sites on the shape. Read-only int .

Returns: int

getRotation()

public final float getRotation()

Returns or sets the number of degrees the specified shape is rotated around the z-axis. A positive value indicates clockwise rotation; a negative value indicates counterclockwise rotation. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Returns: float

setRotation(float value)

public final void setRotation(float value)

Returns or sets the number of degrees the specified shape is rotated around the z-axis. A positive value indicates clockwise rotation; a negative value indicates counterclockwise rotation. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Parameters:

Parameter Type Description
value float

getX()

public final float getX()

Returns or sets the x-coordinate of the upper-left corner of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Returns: float

setX(float value)

public final void setX(float value)

Returns or sets the x-coordinate of the upper-left corner of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Parameters:

Parameter Type Description
value float

getY()

public final float getY()

Returns or sets the y-coordinate of the upper-left corner of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Returns: float

setY(float value)

public final void setY(float value)

Returns or sets the y-coordinate of the upper-left corner of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Parameters:

Parameter Type Description
value float

getWidth()

public final float getWidth()

Returns or sets the width of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Returns: float

setWidth(float value)

public final void setWidth(float value)

Returns or sets the width of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Parameters:

Parameter Type Description
value float

getHeight()

public final float getHeight()

Returns or sets the height of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Returns: float

setHeight(float value)

public final void setHeight(float value)

Returns or sets the height of the shape. Read/write float .


Returned value is always defined (is not Float.NaN). Assigned value must be defined (not Float.NaN). You can set undefined values for RawFrame instance properties.

Parameters:

Parameter Type Description
value float

getBlackWhiteMode()

public final byte getBlackWhiteMode()

Property specifies how a shape will render in black-and-white display mode.. Read/write BlackWhiteMode.

Returns: byte

setBlackWhiteMode(byte value)

public final void setBlackWhiteMode(byte value)

Property specifies how a shape will render in black-and-white display mode.. Read/write BlackWhiteMode.

Parameters:

Parameter Type Description
value byte

getUniqueId()

public final long getUniqueId()

Gets unique shape identifier in presentation scope. Read-only long. See also (#getOfficeInteropShapeId.getOfficeInteropShapeId) for getting unique shape identifier in slide scope.

Returns: long

getOfficeInteropShapeId()

public final long getOfficeInteropShapeId()

Gets unique shape identifier in slide scope. Read-only long. See also (#getUniqueId.getUniqueId) for getting unique shape identifier in presentation scope.

Returns: long

getAlternativeText()

public final String getAlternativeText()

Returns or sets the alternative text associated with a shape. Read/write String.

Returns: java.lang.String

setAlternativeText(String value)

public final void setAlternativeText(String value)

Returns or sets the alternative text associated with a shape. Read/write String.

Parameters:

Parameter Type Description
value java.lang.String

getAlternativeTextTitle()

public final String getAlternativeTextTitle()

Returns or sets the title of alternative text associated with a shape. Read/write String.

Returns: java.lang.String

setAlternativeTextTitle(String value)

public final void setAlternativeTextTitle(String value)

Returns or sets the title of alternative text associated with a shape. Read/write String.

Parameters:

Parameter Type Description
value java.lang.String

getName()

public final String getName()

Returns or sets the name of a shape. Must be not null. Use empty string value if needed. Read/write String.

Returns: java.lang.String

setName(String value)

public final void setName(String value)

Returns or sets the name of a shape. Must be not null. Use empty string value if needed. Read/write String.

Parameters:

Parameter Type Description
value java.lang.String

getShapeLock()

public IBaseShapeLock getShapeLock()

Returns shape’s locks. Read-only IBaseShapeLock.

Returns: IBaseShapeLock

isGrouped()

public final boolean isGrouped()

Determines whether the shape is grouped. Read-only boolean .


Property (#getParentGroup.getParentGroup) returns parent GroupShape object if shape is grouped.

Returns: boolean

getParentGroup()

public final IGroupShape getParentGroup()

Returns parent GroupShape object if shape is grouped. Otherwise returns null. Read-only IGroupShape.


Property (#isGrouped.isGrouped) determines whether the shape is grouped.

Returns: IGroupShape

getParent_Immediate()

public final IDOMObject getParent_Immediate()

Returns Parent_Immediate object. Read-only IDOMObject.

Returns: com.aspose.slides.IDOMObject

getSlide()

public final IBaseSlide getSlide()

Returns the parent slide of a shape. Read-only IBaseSlide.

Returns: IBaseSlide

getPresentation()

public final IPresentation getPresentation()

Returns the parent presentation of a slide. Read-only IPresentation.

Returns: IPresentation