R4R
Right Place For Right Person TM
 
R4R Right ArrowJavaRight Arrow Java APIsRight ArrowPOI APIRight ArrowPOI APIs Basic Example
Previous Home Next

How to create trapezoid shape with POI


Introduction:

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).



Descriptions:
 

 


SourceCode:

 
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){}
	  }
}




Output of SourceCode:
 

How to create trapezoid shape with POI

Previous Home Next
R4R Right ArrowJavaRight Arrow Java APIsRight ArrowPOI APIRight ArrowPOI APIs Basic Example

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R