KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > layout > inline > ForeignObjectArea


1 /*
2  * $Id: ForeignObjectArea.java,v 1.5.2.4 2003/02/25 14:07:12 jeremias Exp $
3  * ============================================================================
4  * The Apache Software License, Version 1.1
5  * ============================================================================
6  *
7  * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modifica-
10  * tion, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. The end-user documentation included with the redistribution, if any, must
20  * include the following acknowledgment: "This product includes software
21  * developed by the Apache Software Foundation (http://www.apache.org/)."
22  * Alternately, this acknowledgment may appear in the software itself, if
23  * and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. The names "FOP" and "Apache Software Foundation" must not be used to
26  * endorse or promote products derived from this software without prior
27  * written permission. For written permission, please contact
28  * apache@apache.org.
29  *
30  * 5. Products derived from this software may not be called "Apache", nor may
31  * "Apache" appear in their name, without prior written permission of the
32  * Apache Software Foundation.
33  *
34  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
35  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
36  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37  * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
38  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
39  * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
40  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
43  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  * ============================================================================
45  *
46  * This software consists of voluntary contributions made by many individuals
47  * on behalf of the Apache Software Foundation and was originally created by
48  * James Tauber <jtauber@jtauber.com>. For more information on the Apache
49  * Software Foundation, please see <http://www.apache.org/>.
50  */

51 package org.apache.fop.layout.inline;
52
53 // FOP
54
import org.apache.fop.render.Renderer;
55 import org.apache.fop.layout.*;
56
57 public class ForeignObjectArea extends InlineArea {
58
59     protected int xOffset = 0;
60     /* text-align of contents */
61     protected int align;
62     /* vertical align of contents */
63     protected int valign;
64     /* scaling method */
65     protected int scaling;
66     protected Area foreignObject;
67     /* height according to the instream-foreign-object */
68     protected int cheight;
69     /* width according to the instream-foreign-object */
70     protected int cwidth;
71     /* width of the content */
72     protected int awidth;
73     /* height of the content */
74     protected int aheight;
75     /* width */
76     protected int width;
77     boolean wauto;
78     boolean hauto;
79     boolean cwauto;
80     boolean chauto;
81     int overflow;
82
83     public ForeignObjectArea(FontState fontState, int width) {
84         super(fontState, width, 0, 0, 0);
85     }
86
87     public void render(Renderer renderer) {
88         if (foreignObject != null)
89             renderer.renderForeignObjectArea(this);
90     }
91
92     /**
93      * This is NOT the content width of the instream-foreign-object.
94      * This is the content width for a Box.
95      */

96     public int getContentWidth() {
97         return getEffectiveWidth();
98     }
99
100     /**
101      * This is NOT the content height of the instream-foreign-object.
102      * This is the content height for a Box.
103      */

104     public int getHeight() {
105         return getEffectiveHeight();
106     }
107
108     public int getContentHeight() {
109         return getEffectiveHeight();
110     }
111
112     public int getXOffset() {
113         return this.xOffset;
114     }
115
116     public void setStartIndent(int startIndent) {
117         xOffset = startIndent;
118     }
119
120     public void setObject(Area fobject) {
121         foreignObject = fobject;
122     }
123
124     public Area getObject() {
125         return foreignObject;
126     }
127
128     public void setSizeAuto(boolean wa, boolean ha) {
129         wauto = wa;
130         hauto = ha;
131     }
132
133     public void setContentSizeAuto(boolean wa, boolean ha) {
134         cwauto = wa;
135         chauto = ha;
136     }
137
138     public boolean isContentWidthAuto() {
139         return cwauto;
140     }
141
142     public boolean isContentHeightAuto() {
143         return chauto;
144     }
145
146     public void setAlign(int align) {
147         this.align = align;
148     }
149
150     public int getAlign() {
151         return this.align;
152     }
153
154     public void setVerticalAlign(int align) {
155         this.valign = align;
156     }
157
158     public int getVerticalAlign() {
159         return this.valign;
160     }
161
162     public void setOverflow(int o) {
163         this.overflow = o;
164     }
165
166     public int getOverflow() {
167         return this.overflow;
168     }
169
170     public void setHeight(int height) {
171         this.height = height;
172     }
173
174     public void setWidth(int width) {
175         this.width = width;
176     }
177
178     public void setContentHeight(int cheight) {
179         this.cheight = cheight;
180     }
181
182     public void setContentWidth(int cwidth) {
183         this.cwidth = cwidth;
184     }
185
186     public void setScaling(int scaling) {
187         this.scaling = scaling;
188     }
189
190     public int scalingMethod() {
191         return this.scaling;
192     }
193
194     public void setIntrinsicWidth(int w) {
195         awidth = w;
196     }
197
198     public void setIntrinsicHeight(int h) {
199         aheight = h;
200     }
201
202     public int getIntrinsicHeight() {
203         return aheight;
204     }
205
206     public int getIntrinsicWidth() {
207         return awidth;
208     }
209
210     public int getEffectiveHeight() {
211         if (this.hauto) {
212             if (this.chauto) {
213                 return aheight;
214             } else {
215                 // need to handle percentages, this would be a scaling factor on the
216
// instrinsic height (content determined height)
217
// if(this.properties.get("content-height").getLength().isPercentage()) {
218
// switch(scaling) {
219
// case Scaling.UNIFORM:
220
// break;
221
// case Scaling.NON_UNIFORM:
222
// break;
223
// }
224
// } else {
225
return this.cheight;
226             }
227         } else {
228             return this.height;
229         }
230     }
231
232     public int getEffectiveWidth() {
233         if (this.wauto) {
234             if (this.cwauto) {
235                 return awidth;
236             } else {
237                 // need to handle percentages, this would be a scaling factor on the
238
// instrinsic height (content determined height)
239
// if(this.properties.get("content-width").getLength().isPercentage()) {
240
// switch(scaling) {
241
// case Scaling.UNIFORM:
242
// break;
243
// case Scaling.NON_UNIFORM:
244
// break;
245
// }
246
// } else {
247
return this.cwidth;
248             }
249         } else {
250             return this.width;
251         }
252     }
253
254 }
255
Popular Tags