1 /*
2  * $Id: RectangleReadOnly.java 3746 2009-03-04 10:13:52Z blowagie $
3  *
4  * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie.
5  *
6  * The contents of this file are subject to the Mozilla Public License Version 1.1
7  * (the "License"); you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the License.
13  *
14  * The Original Code is 'iText, a free JAVA-PDF library'.
15  *
16  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
17  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
18  * All Rights Reserved.
19  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
20  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source code
23  * where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above.  If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
34  *
35  * This library is free software; you can redistribute it and/or modify it
36  * under the terms of the MPL as stated above or under the terms of the GNU
37  * Library General Public License as published by the Free Software Foundation;
38  * either version 2 of the License, or any later version.
39  *
40  * This library is distributed in the hope that it will be useful, but WITHOUT
41  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
42  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
43  * details.
44  *
45  * If you didn't download this code from the following link, you should check if
46  * you aren't using an obsolete version:
47  * http://www.lowagie.com/iText/
48  */

49
50 package com.lowagie.text;
51
52 import java.awt.Color;
53
54 /**
55  * A <CODE>RectangleReadOnly</CODE> is the representation of a geometric figure.
56  * It's the same as a <CODE>Rectangle</CODE> but immutable.
57  * Rectangles support constant width borders using
58  * {@link #setBorderWidth(float)}and {@link #setBorder(int)}.
59  * They also support borders that vary in width/color on each side using
60  * methods like {@link #setBorderWidthLeft(float)}or
61  * {@link #setBorderColorLeft(java.awt.Color)}.
62  * 
63  * @see Element
64  * @see Table
65  * @see Cell
66  * @see HeaderFooter
67  * @since 2.1.2
68  */

69
70 public class RectangleReadOnly extends Rectangle {
71
72     // CONSTRUCTORS
73
74     /**
75      * Constructs a <CODE>RectangleReadOnly</CODE> -object.
76      * 
77      * @param llx    lower left x
78      * @param lly    lower left y
79      * @param urx    upper right x
80      * @param ury    upper right y
81      */

82     public RectangleReadOnly(float llx, float lly, float urx, float ury) {
83         super(llx, lly, urx, ury);
84     }
85
86     /**
87      * Constructs a <CODE>RectangleReadOnly</CODE> -object starting from the origin
88      * (0, 0).
89      * 
90      * @param urx    upper right x
91      * @param ury    upper right y
92      */

93     public RectangleReadOnly(float urx, float ury) {
94         super(0, 0, urx, ury);
95     }
96
97     /**
98      * Constructs a <CODE>RectangleReadOnly</CODE> -object.
99      * 
100      * @param rect    another <CODE>Rectangle</CODE>
101      */

102     public RectangleReadOnly(Rectangle rect) {
103         super(rect.llx, rect.lly, rect.urx, rect.ury);
104         super.cloneNonPositionParameters(rect);
105     }
106
107     /**
108      * Throws an error because of the read only nature of this object. 
109      */

110     private void throwReadOnlyError() {
111         throw new UnsupportedOperationException("RectangleReadOnly: this Rectangle is read only.");
112     }
113     
114     // OVERWRITE METHODS SETTING THE DIMENSIONS:
115
116     /**
117      * Sets the lower left x-coordinate.
118      * 
119      * @param llx    the new value
120      */

121     public void setLeft(float llx) {
122         throwReadOnlyError();
123     }
124
125     /**
126      * Sets the upper right x-coordinate.
127      * 
128      * @param urx    the new value
129      */

130
131     public void setRight(float urx) {
132         throwReadOnlyError();
133     }
134
135     /**
136      * Sets the upper right y-coordinate.
137      * 
138      * @param ury    the new value
139      */

140     public void setTop(float ury) {
141         throwReadOnlyError();
142     }
143
144     /**
145      * Sets the lower left y-coordinate.
146      * 
147      * @param lly    the new value
148      */

149     public void setBottom(float lly) {
150         throwReadOnlyError();
151     }
152
153     /**
154      * Normalizes the rectangle.
155      * Switches lower left with upper right if necessary.
156      */

157     public void normalize() {
158         throwReadOnlyError();
159     }
160
161     // OVERWRITE METHODS SETTING THE BACKGROUND COLOR:
162
163     /**
164      * Sets the backgroundcolor of the rectangle.
165      * 
166      * @param value    the new value
167      */

168     public void setBackgroundColor(Color value) {
169         throwReadOnlyError();
170     }
171
172     /**
173      * Sets the grayscale of the rectangle.
174      * 
175      * @param value    the new value
176      */

177     public void setGrayFill(float value) {
178         throwReadOnlyError();
179     }
180     
181     // OVERWRITE METHODS SETTING THE BORDER:
182
183     /**
184      * Enables/Disables the border on the specified sides.
185      * The border is specified as an integer bitwise combination of
186      * the constants: <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE>.
187      * 
188      * @see #enableBorderSide(int)
189      * @see #disableBorderSide(int)
190      * @param border    the new value
191      */

192     public void setBorder(int border) {
193         throwReadOnlyError();
194     }
195     
196     /**
197      * Sets a parameter indicating if the rectangle has variable borders
198      * 
199      * @param useVariableBorders    indication if the rectangle has variable borders
200      */

201     public void setUseVariableBorders(boolean useVariableBorders) {
202         throwReadOnlyError();
203     }
204
205     /**
206      * Enables the border on the specified side.
207      * 
208      * @param side    the side to enable.
209      * One of <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE>
210      */

211     public void enableBorderSide(int side) {
212         throwReadOnlyError();
213     }
214
215     /**
216      * Disables the border on the specified side.
217      * 
218      * @param side    the side to disable.
219      * One of <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE>
220      */

221     public void disableBorderSide(int side) {
222         throwReadOnlyError();
223     }
224
225     // OVERWRITE METHODS SETTING THE BORDER WIDTH:
226
227     /**
228      * Sets the borderwidth of the table.
229      * 
230      * @param borderWidth    the new value
231      */

232
233     public void setBorderWidth(float borderWidth) {
234         throwReadOnlyError();
235     }
236
237     /**
238      * Sets the width of the left border
239      * 
240      * @param borderWidthLeft    a width
241      */

242     public void setBorderWidthLeft(float borderWidthLeft) {
243         throwReadOnlyError();
244     }
245
246     /**
247      * Sets the width of the right border
248      * 
249      * @param borderWidthRight    a width
250      */

251     public void setBorderWidthRight(float borderWidthRight) {
252         throwReadOnlyError();
253     }
254
255     /**
256      * Sets the width of the top border
257      * 
258      * @param borderWidthTop    a width
259      */

260     public void setBorderWidthTop(float borderWidthTop) {
261         throwReadOnlyError();
262     }
263
264     /**
265      * Sets the width of the bottom border
266      * 
267      * @param borderWidthBottom    a width
268      */

269     public void setBorderWidthBottom(float borderWidthBottom) {
270         throwReadOnlyError();
271     }
272
273     // METHODS TO GET/SET THE BORDER COLOR:
274
275     /**
276      * Sets the color of the border.
277      * 
278      * @param borderColor    a <CODE>Color</CODE>
279      */

280
281     public void setBorderColor(Color borderColor) {
282         throwReadOnlyError();
283     }
284     
285     /**
286      * Sets the color of the left border.
287      * 
288      * @param borderColorLeft    a <CODE>Color</CODE>
289      */

290     public void setBorderColorLeft(Color borderColorLeft) {
291         throwReadOnlyError();
292     }
293
294     /**
295      * Sets the color of the right border
296      * 
297      * @param borderColorRight    a <CODE>Color</CODE>
298      */

299     public void setBorderColorRight(Color borderColorRight) {
300         throwReadOnlyError();
301     }
302
303     /**
304      * Sets the color of the top border.
305      * 
306      * @param borderColorTop    a <CODE>Color</CODE>
307      */

308     public void setBorderColorTop(Color borderColorTop) {
309         throwReadOnlyError();
310     }
311
312     /**
313      * Sets the color of the bottom border.
314      * 
315      * @param borderColorBottom    a <CODE>Color</CODE>
316      */

317     public void setBorderColorBottom(Color borderColorBottom) {
318         throwReadOnlyError();
319     }
320
321     // SPECIAL METHODS:
322
323     /**
324      * Copies each of the parameters, except the position, from a
325      * <CODE>Rectangle</CODE> object
326      * 
327      * @param rect    <CODE>Rectangle</CODE> to copy from
328      */

329     public void cloneNonPositionParameters(Rectangle rect) {
330         throwReadOnlyError();
331     }
332
333     /**
334      * Copies each of the parameters, except the position, from a
335      * <CODE>Rectangle</CODE> object if the value is set there.
336      * 
337      * @param rect    <CODE>Rectangle</CODE> to copy from
338      */

339     public void softCloneNonPositionParameters(Rectangle rect) {
340         throwReadOnlyError();
341     }
342     
343     /**
344      * @return    String version of the most important rectangle properties
345      * @see java.lang.Object#toString()
346      */

347     public String toString() {
348         StringBuffer buf = new StringBuffer("RectangleReadOnly: ");
349         buf.append(getWidth());
350         buf.append('x');
351         buf.append(getHeight());
352         buf.append(" (rot: ");
353         buf.append(rotation);
354         buf.append(" degrees)");
355         return buf.toString();
356     }
357 }