AutoShape
Inheritance: java.lang.Object, com.aspose.slides.Shape, com.aspose.slides.GeometryShape
All Implemented Interfaces: com.aspose.slides.IAutoShape
public final class AutoShape extends GeometryShape implements IAutoShape
Represents an AutoShape.
Methods
Method | Description |
---|---|
getShapeLock() | Returns shape’s locks. |
getAutoShapeLock() | Returns autoshape’s locks. |
getTextFrame() | Returns TextFrame object for the AutoShape. |
getUseBackgroundFill() | Determines whether this autoshape should be filled with slide’s background fill instead of specified by style or fill format. |
setUseBackgroundFill(boolean value) | Determines whether this autoshape should be filled with slide’s background fill instead of specified by style or fill format. |
addTextFrame(String text) | Adds a new TextFrame to a shape. |
isTextBox() | Specifies if the shape is a text box. |
getShapeLock()
public final IAutoShapeLock getShapeLock()
Returns shape’s locks. Read-only IAutoShapeLock.
Returns: IAutoShapeLock
getAutoShapeLock()
public final IAutoShapeLock getAutoShapeLock()
Returns autoshape’s locks. Read-only IAutoShapeLock.
Returns: IAutoShapeLock
getTextFrame()
public final ITextFrame getTextFrame()
Returns TextFrame object for the AutoShape. Read-only ITextFrame.
Returns: ITextFrame
getUseBackgroundFill()
public final boolean getUseBackgroundFill()
Determines whether this autoshape should be filled with slide’s background fill instead of specified by style or fill format. Read/write boolean.
Returns: boolean
setUseBackgroundFill(boolean value)
public final void setUseBackgroundFill(boolean value)
Determines whether this autoshape should be filled with slide’s background fill instead of specified by style or fill format. Read/write boolean.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
addTextFrame(String text)
public final ITextFrame addTextFrame(String text)
Adds a new TextFrame to a shape. If shape already has TextFrame then simply changes its text.
The following sample code shows how to add watermark text in PowerPoint Presentation. Presentation pres = new Presentation(); try { ISlide slide = pres.getSlides().get_Item(0); IAutoShape watermarkShape = slide.getShapes().addAutoShape(ShapeType.Triangle, 0, 0, 150, 50); ITextFrame watermarkTextFrame = watermarkShape.addTextFrame("Watermark"); } finally { if (pres != null) pres.dispose(); } The following example shows how to create Text Box on Slide. // Instantiates Presentation Presentation pres = new Presentation(); try { // Gets the first slide in the presentation ISlide sld = pres.getSlides().get_Item(0); // Adds an AutoShape with type set as Rectangle IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); // Adds TextFrame to the Rectangle ashp.addTextFrame(" "); // Accesses the text frame ITextFrame txtFrame = ashp.getTextFrame(); // Creates the Paragraph object for text frame IParagraph para = txtFrame.getParagraphs().get_Item(0); // Creates a Portion object for the paragraph IPortion portion = para.getPortions().get_Item(0); // Sets the text portion.setText("Aspose TextBox"); // Saves the presentation to disk pres.save("TextBox_out.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); } The following example shows how to add column in Text Box. Presentation pres = new Presentation(); try { // Gets the first slide in the presentation ISlide slide = pres.getSlides().get_Item(0); // Add an AutoShape with type set as Rectangle IAutoShape aShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 300, 300); // Add TextFrame to the Rectangle aShape.addTextFrame("All these columns are limited to be within a single text container -- " + "you can add or delete text and the new or remaining text automatically adjusts " + "itself to flow within the container. You cannot have text flow from one container " + "to other though -- we told you PowerPoint's column options for text are limited!"); // Gets the text format of TextFrame ITextFrameFormat format = aShape.getTextFrame().getTextFrameFormat(); // Specifies the number of columns in TextFrame format.setColumnCount(3); // Specifies the spacing between columns format.setColumnSpacing(10); // Saves the presentation pres.save("ColumnCount.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
text | java.lang.String | Default text for a new TextFrame. |
Returns: ITextFrame
isTextBox()
public final boolean isTextBox()
Specifies if the shape is a text box.
If shape is not specified to be a text box does not mean that it cannot have text attached to it. A text box is merely a specialized shape with specific properties.
Returns: boolean