How to create trapezoid shape with POI
Previous | Home | Next |
In this page of the example we are trying to create a trapezoid shape on PowerPoint slide with help of java plateform. In this program, we are creating a master slide for the slide show. for creation of the slide show we can use the SlideShow constructor and for master slide creation we can use SlideMaster constructor. Then we create an object of Slide to create a slide .To make the trapezoid shape in power point slide we have to use an object of AutoShape class in which we pass the shape type as trapezoid. To set the position we are using setAnchor() method. To set the color we are usingsetFillColor(Color.Red).
package r4r; import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.model.Slide; import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hslf.usermodel.*; import java.io.*; import java.awt.*; import org.apache.poi.hslf.model.TextBox; public class createtrapezoidshape { public static void main(String a[]) { try { SlideShow Show = new SlideShow(); Slide slide = Show.createSlide(); AutoShape as1 = new AutoShape(ShapeTypes.Trapezoid); as1.setAnchor(new java.awt.Rectangle(0, 0, 700, 700)); as1.setFillColor(Color.DARK_GRAY); AutoShape as2 = new AutoShape(ShapeTypes.Trapezoid); as2.setAnchor(new java.awt.Rectangle(50, 100, 500, 500)); as2.setFillColor(Color.CYAN); AutoShape as3 = new AutoShape(ShapeTypes.Trapezoid); as3.setAnchor(new java.awt.Rectangle(100, 150, 400, 400)); as3.setFillColor(Color.green); AutoShape as4 = new AutoShape(ShapeTypes.Trapezoid); as4.setAnchor(new java.awt.Rectangle(250, 250, 100, 100)); as4.setFillColor(Color.yellow); slide.addShape(as1); slide.addShape(as2); slide.addShape(as3); slide.addShape(as4); FileOutputStream fos = new FileOutputStream("Trapezoidcreation.ppt"); Show.write(fos); fos.close(); }catch(Exception e){} } }
Previous | Home | Next |