KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > rtf > rtflib > testdocs > ExternalGraphic


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: ExternalGraphic.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20
21 /*
22  * This file is part of the RTF library of the FOP project, which was originally
23  * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
24  * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
25  * the FOP project.
26  */

27
28 package org.apache.fop.render.rtf.rtflib.testdocs;
29
30 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
31 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
32 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
33 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
34
35 import java.io.IOException JavaDoc;
36 /**
37  * Generate a test document containing external graphics.
38  *
39  * @author <a HREF="mailto:a.putz@skynamics.com">Andreas Putz</a>
40  */

41 class ExternalGraphic extends TestDocument {
42     private String JavaDoc file = "file:///tmp/jfor-images/logo.";
43
44     //////////////////////////////////////////////////
45
// @@ Construction
46
//////////////////////////////////////////////////
47

48     /**
49      * Default constructor.
50      */

51     public ExternalGraphic () {
52
53     }
54     /** generate the body of the test document */
55     protected void generateDocument (RtfDocumentArea rda, RtfSection sect) throws IOException JavaDoc {
56         RtfParagraph p = sect.newParagraph ();
57         p.newLineBreak();
58         p.newLineBreak();
59         p.newLineBreak();
60         p.newText ("EMF image with 150 % height");
61         p.newLineBreak();
62         RtfExternalGraphic imageA = p.newImage ();
63         imageA.setURL (file + "emf");
64         imageA.setHeight ("150%");
65         p.newLineBreak();
66         p.close();
67
68         p = sect.newParagraph();
69         p.newLineBreak();
70         p.newText ("PNG image with 150 % width");
71         p.newLineBreak();
72         RtfExternalGraphic imageB = sect.newImage ();
73         imageB.setURL (file + "png");
74         imageB.setWidth ("150%");
75         p.newLineBreak();
76         p.close();
77
78         p = sect.newParagraph();
79         p.newLineBreak();
80         p.newLineBreak();
81         p.newText ("JPG image with width = 200px and height = 20 px");
82         p.newLineBreak();
83         RtfExternalGraphic imageC = sect.newImage ();
84         imageC.setURL (file + "jpg");
85         imageC.setWidth ("200");
86         imageC.setHeight ("20");
87         p.newLineBreak();
88         p.close();
89
90         p = sect.newParagraph();
91         p.newLineBreak();
92         p.newLineBreak();
93         p.newText ("GIF image with width = 200px and scaling = 'uniform', that means the image "
94                 + "size will adjusted automatically");
95         p.newLineBreak();
96         RtfExternalGraphic imageD = sect.newImage ();
97         imageD.setURL (file + "gif");
98         imageD.setWidth ("200");
99         imageD.setScaling ("uniform");
100         p.newLineBreak();
101         p.close();
102
103         p = sect.newParagraph();
104         p.newLineBreak();
105         p.newLineBreak();
106         p.newText ("GIF image");
107         p.newLineBreak();
108         RtfExternalGraphic imageE = sect.newImage ();
109         imageE.setURL (file + "gif");
110         p.newLineBreak();
111         p.close();
112
113     }
114
115
116
117 }
118
Popular Tags