Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Inserting Text Trapezoid Using Java

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

Inserting Text Trapezoid Using Java

                         


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

In this example, we are creating a slide master for the slide show. To create slide show we are using SlideShow constructor and to create master slide we are using SlideMaster constructor. Then we are creating 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 are passing the shape type as trapezoid. To set the position we are using setAnchor() method. To set the color we are using setFillColor(Color.Red). To insert text we are creating an object of RichTextRun constructor. In this we are passing text value. Finally we are adding it by using addShape() method.

  
 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 insertingTextInTrapezoid
{
  public static void main(String a[])
  {
  try
  {   SlideShow slideShow = new SlideShow();
      Slide slide = slideShow.createSlide();
      TextBox txt = new TextBox();
      txt.setText("Rajesh Kumar");
      txt.setAnchor(new java.awt.Rectangle(25026030050));
     RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
     rt.setFontSize(42);
     rt.setFontName("Arial");
     rt.setBold(true);
     rt.setFontColor(Color.white);
     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);
     slide.addShape(txt);
    FileOutputStream out = new FileOutputStream
(
"insertingTextInTrapezoid.ppt");
     slideShow.write(out);
      out.close();
  }catch(Exception e){}
  }}

The output of the program is given below:

Download this example.

                         

» View all related tutorials
Related Tags: c api class static script event io methods method variable sed find get type hex ip operator using ria this

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.