SmartArt
Contents
[
Hide
]
Bài viết này trình bày cách thêm đồ họa SmartArt, truy cập chúng, xóa chúng và thay đổi bố cục bằng cách sử dụng Aspose.Slides for Java.
Thêm SmartArt
Chèn một đồ họa SmartArt bằng một trong các bố cục có sẵn.
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();
}
}
Truy cập SmartArt
Lấy đối tượng SmartArt đầu tiên trên một slide.
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();
}
}
Xóa SmartArt
Xóa một hình SmartArt khỏi slide.
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();
}
}
Thay đổi bố cục SmartArt
Cập nhật loại bố cục của một đồ họa SmartArt hiện có.
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();
}
}