Shape Class
A shape in presentations.
Declaration
public class Shape extends FilledShape
Remarks
Shapes are the primary visual elements in a presentation. The DevExpress Presentation API allows you to create, customize, arrange, connect, group, and remove shapes programmatically.
Slide masters, slide layouts, and slides store shapes in their IShapeCollection. Use the getShapes() method to access the shape collection.
Each item in the collection can be one of the following types:
Shape— A preset or custom geometric shape (rectangle, star, arrow, etc.).- PictureShape — A shape that displays an embedded image.
- GroupShape — A container that groups multiple shapes. Grouped shapes can be transformed as a single unit.
- ConnectorShape — A line or curve that links two shapes at defined connection points.
The following code snippet retrieves shapes from a slide’s getShapes() collection and casts them to their corresponding types:
// Retrieve the first shape and cast it to a Shape object.
Shape shape = (Shape)slide.getShapes().getFirst();
// Retrieve the third shape and cast it to a ConnectorShape object.
ConnectorShape connector = (ConnectorShape)slide.getShapes().get(2);
// Retrieve the fourth shape and cast it to a PictureShape object.
PictureShape picture = (PictureShape)slide.getShapes().get(3);
Refer to the following help topics for additional information:
- Work with Shapes — Presentation API for Java
- Modify Shape Text and Content in Presentations (Java)
- Work with Tables — Presentation API for Java
Inherited Members
Inheritance
Constructors
Shape(ShapeType type, float x, float y, float width, float height) Constructor
Initializes a new instance of the Shape class with specified settings.
Declaration
public Shape(ShapeType type, float x, float y, float width, float height)
Parameters
| Name | Type | Description |
|---|---|---|
| type | ShapeType | The shape type. |
| x | float | The X-coordinate. |
| y | float | The Y-coordinate. |
| width | float | The shape width. |
| height | float | The shape height. |
Remarks
// Create a new shape (5-point star) and specify its position and size.
Shape shape = new Shape(ShapeType.getStar5(), 100, 100, 1000, 1000);
Shape(ShapeType type, float x, float y, float width) Constructor
Initializes a new instance of the Shape class with specified settings.
Declaration
public Shape(ShapeType type, float x, float y, float width)
Parameters
| Name | Type | Description |
|---|---|---|
| type | ShapeType | The shape type. |
| x | float | The X-coordinate. |
| y | float | The Y-coordinate. |
| width | float | The shape width. |
Shape(ShapeType type, float x, float y) Constructor
Initializes a new instance of the Shape class with specified settings.
Declaration
public Shape(ShapeType type, float x, float y)
Parameters
| Name | Type | Description |
|---|---|---|
| type | ShapeType | The shape type. |
| x | float | The X-coordinate. |
| y | float | The Y-coordinate. |
Remarks
// Create a new shape (5-point star) and specify its position.
Shape shape = new Shape(ShapeType.getStar5(), 100, 100);
Shape(ShapeType type, float x) Constructor
Initializes a new instance of the Shape class with specified settings.
Declaration
public Shape(ShapeType type, float x)
Parameters
| Name | Type | Description |
|---|---|---|
| type | ShapeType | The shape type. |
| x | float | The X-coordinate. |
Shape(ShapeType type) Constructor
Initializes a new instance of the Shape class with specified settings.
Declaration
public Shape(ShapeType type)
Parameters
| Name | Type | Description |
|---|---|---|
| type | ShapeType | The shape type. |
Remarks
// Create a new shape (5-point star).
Shape shape = new Shape(ShapeType.getStar5());
Methods
deepClone() Method
Clones the current Shape instance.
Declaration
public Shape deepClone()
Returns
| Type | Description |
|---|---|
Shape |
The cloned |
Remarks
The following code snippet creates a deep copy of an existing shape and adds the cloned shape to the slide:
// Clone an existing shape.
Shape clonedShape = shape.deepClone();
// Add the cloned shape to the slide.
slide.getShapes().add(clonedShape);
getLockSettings() Method
Returns shape lock settings. Lock settings restrict user operations or hide certain visual elements.
Declaration
public ShapeLockSettings getLockSettings()
Returns
| Type | Description |
|---|---|
| ShapeLockSettings | Contains lock settings. |
Remarks
The following code snippet gets a shape’s lock settings and disables shape movement and resizing:
// Get lock settings for a shape.
ShapeLockSettings lockSettings = shape.getLockSettings();
// Disable moving and resizing.
lockSettings.setDisableMoving(true);
lockSettings.setDisableResize(true);
Refer to the following help topic for additional information: Lock Settings.
getTextArea() Method
Returns the shape’s text area.
Declaration
public TextArea getTextArea()
Returns
| Type | Description |
|---|---|
| TextArea | The shape’s text area. |
Remarks
TextArea contains all text within a shape. Use the shape’s getTextArea() method to access the its text area:
shape.getTextArea().setText("Text Area");
Refer to the following topic for additional information: Modify Shape Text and Content in Presentations (Java).
getType() Method
Returns the shape type.
Declaration
public ShapeType getType()
Returns
| Type | Description |
|---|---|
| ShapeType | Shape type. |
getUseBackgroundFill() Method
Indicates whether the shape uses the background fill.
Declaration
public boolean getUseBackgroundFill()
Returns
| Type | Description |
|---|---|
| boolean |
|
Remarks
Refer to the following help topic for additional information: Visual Effects.
setTextArea(TextArea value) Method
Sets the shape’s text area.
Declaration
public void setTextArea(TextArea value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | TextArea | The shape’s text area. |
Remarks
The following code snippet creates a shared TextArea object, customizes its settings, and applies it to multiple shapes:
// Create a text area.
TextArea sharedTextArea = new TextArea("Text Area");
// Center paragraph text and make it bold.
sharedTextArea.getParagraphProperties()
.setAlignment(TextParagraphAlignment.CENTER);
sharedTextArea.getParagraphProperties()
.getTextProperties()
.setBold(true);
// Assign the same text area instance to both shapes.
shape1.setTextArea(sharedTextArea);
shape2.setTextArea(sharedTextArea);
setType(ShapeType value) Method
Sets the shape type.
Declaration
public void setType(ShapeType value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ShapeType | Shape type. |
setUseBackgroundFill(boolean value) Method
Indicates whether the shape uses the background fill.
Declaration
public void setUseBackgroundFill(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|