Home Java Poi Creating Trapezoid Using Java



Creating Trapezoid Using Java
Posted on: March 14, 2008 at 12:00 AM
In this example we are going to create a trapezoid on PowerPoint slide using java.

Creating Trapezoid Using Java

     


In this example we are going to create a trapezoid on PowerPoint slide using java.

In this example, we are creating a slide master for the slide show. To create slide show we use SlideShow constructor and to create master slide we use SlideMaster constructor. Then we create an object of Slide to create a slide .To create a trapezoid shape 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 using setFillColor(Color.Red).

  
 The code of the program is given below:
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;
class createTrapezoid
{
  public static void main(String a[])
  {
  try
  SlideShow slideShow = new SlideShow();
  Slide slide = slideShow.createSlide();
  AutoShape sh1 = new AutoShape(ShapeTypes.Trapezoid);
  sh1.setAnchor(new java.awt.Rectangle(00600600));
  sh1.setFillColor(Color.blue);
  AutoShape sh2 = new AutoShape(ShapeTypes.Trapezoid);
  sh2.setAnchor(new java.awt.Rectangle(50100500500));
  sh2.setFillColor(Color.red);
  AutoShape sh3 = new AutoShape(ShapeTypes.Trapezoid);
  sh3.setAnchor(new java.awt.Rectangle(100150400400));
  sh3.setFillColor(Color.green);
  AutoShape sh4 = new AutoShape(ShapeTypes.Trapezoid);
  sh4.setAnchor(new java.awt.Rectangle(250250100100));
  sh4.setFillColor(Color.yellow);
  slide.addShape(sh1);
  slide.addShape(sh2);
  slide.addShape(sh3);
  slide.addShape(sh4);  
  FileOutputStream out = new FileOutputStream
(
"createTrapezoid.ppt");
  slideShow.write(out);
  out.close();
  }catch(Exception e){}
  }}

The output of the program is given below:

Download this example.

Related Tags for Creating Trapezoid Using Java:
javacideclassconstructorobjectiostructmethodcolortypeconstanchorpowerpointusingintthisidsetpositioncreateshowforpoiexampleslideshowtopointexampowermasterposerpastshautoeilslideshapeitfilldesliusetrappeinshapassasmnttrososiosiosjclesemoidmehowobjcreatingtorxawhichwerxampsctorcolatishallcllmplgoeaandarconsstrtfslivazssthshoavstatiapctojepleplndonolo


More Tutorials from this section

Ask Questions?    Discuss: Creating Trapezoid Using Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.