SmartArt
Contents
[
Hide
]
本文演示了如何使用 Aspose.Slides for Java 添加 SmartArt 图形、访问它们、删除它们以及更改布局。
添加 SmartArt
使用内置布局之一插入 SmartArt 图形。
static void addSmartArt() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess);
} finally {
presentation.dispose();
}
}
访问 SmartArt
检索幻灯片上的第一个 SmartArt 对象。
static void accessSmartArt() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess);
ISmartArt firstSmartArt = null;
for (IShape shape : slide.getShapes()) {
if (shape instanceof ISmartArt) {
firstSmartArt = (ISmartArt) shape;
break;
}
}
} finally {
presentation.dispose();
}
}
删除 SmartArt
从幻灯片中删除 SmartArt 形状。
static void removeSmartArt() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess);
slide.getShapes().remove(smartArt);
} finally {
presentation.dispose();
}
}
更改 SmartArt 布局
更新现有 SmartArt 图形的布局类型。
static void changeSmartArtLayout() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
ISmartArt smartArt = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicBlockList);
smartArt.setLayout(SmartArtLayoutType.VerticalPictureList);
} finally {
presentation.dispose();
}
}