1 | /* | |
2 | * $Id: RectangleReadOnly.java 4065 2009-09-16 23:09:11Z psoares33 $ | |
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 | import com.lowagie.text.error_messages.MessageLocalization; | |
54 | ||
55 | /** | |
56 | * A <CODE>RectangleReadOnly</CODE> is the representation of a geometric figure. | |
57 | * It's the same as a <CODE>Rectangle</CODE> but immutable. | |
58 | * Rectangles support constant width borders using | |
59 | * {@link #setBorderWidth(float)}and {@link #setBorder(int)}. | |
60 | * They also support borders that vary in width/color on each side using | |
61 | * methods like {@link #setBorderWidthLeft(float)}or | |
62 | * {@link #setBorderColorLeft(java.awt.Color)}. | |
63 | * | |
64 | * @see Element | |
65 | * @see Table | |
66 | * @see Cell | |
67 | * @see HeaderFooter | |
68 | * @since 2.1.2 | |
69 | */ | |
70 | ||
71 | public class RectangleReadOnly extends Rectangle { | |
72 | ||
73 | // CONSTRUCTORS | |
74 | ||
75 | /** | |
76 | * Constructs a <CODE>RectangleReadOnly</CODE> -object. | |
77 | * | |
78 | * @param llx lower left x | |
79 | * @param lly lower left y | |
80 | * @param urx upper right x | |
81 | * @param ury upper right y | |
82 | */ | |
83 | public RectangleReadOnly(float llx, float lly, float urx, float ury) { | |
84 | super(llx, lly, urx, ury); | |
85 | } | |
86 | ||
87 | /** | |
88 | * Constructs a <CODE>RectangleReadOnly</CODE> -object starting from the origin | |
89 | * (0, 0). | |
90 | * | |
91 | * @param urx upper right x | |
92 | * @param ury upper right y | |
93 | */ | |
94 | public RectangleReadOnly(float urx, float ury) { | |
95 | super(0, 0, urx, ury); | |
96 | } | |
97 | ||
98 | /** | |
99 | * Constructs a <CODE>RectangleReadOnly</CODE> -object. | |
100 | * | |
101 | * @param rect another <CODE>Rectangle</CODE> | |
102 | */ | |
103 | public RectangleReadOnly(Rectangle rect) { | |
104 | super(rect.llx, rect.lly, rect.urx, rect.ury); | |
105 |
1
1. |
super.cloneNonPositionParameters(rect); |
106 | } | |
107 | ||
108 | /** | |
109 | * Throws an error because of the read only nature of this object. | |
110 | */ | |
111 | private void throwReadOnlyError() { | |
112 | throw new UnsupportedOperationException(MessageLocalization.getComposedMessage("rectanglereadonly.this.rectangle.is.read.only")); | |
113 | } | |
114 | | |
115 | // OVERWRITE METHODS SETTING THE DIMENSIONS: | |
116 | ||
117 | /** | |
118 | * Sets the lower left x-coordinate. | |
119 | * | |
120 | * @param llx the new value | |
121 | */ | |
122 | public void setLeft(float llx) { | |
123 | throwReadOnlyError(); | |
124 | } | |
125 | ||
126 | /** | |
127 | * Sets the upper right x-coordinate. | |
128 | * | |
129 | * @param urx the new value | |
130 | */ | |
131 | ||
132 | public void setRight(float urx) { | |
133 | throwReadOnlyError(); | |
134 | } | |
135 | ||
136 | /** | |
137 | * Sets the upper right y-coordinate. | |
138 | * | |
139 | * @param ury the new value | |
140 | */ | |
141 | public void setTop(float ury) { | |
142 | throwReadOnlyError(); | |
143 | } | |
144 | ||
145 | /** | |
146 | * Sets the lower left y-coordinate. | |
147 | * | |
148 | * @param lly the new value | |
149 | */ | |
150 | public void setBottom(float lly) { | |
151 | throwReadOnlyError(); | |
152 | } | |
153 | ||
154 | /** | |
155 | * Normalizes the rectangle. | |
156 | * Switches lower left with upper right if necessary. | |
157 | */ | |
158 | public void normalize() { | |
159 | throwReadOnlyError(); | |
160 | } | |
161 | ||
162 | // OVERWRITE METHODS SETTING THE BACKGROUND COLOR: | |
163 | ||
164 | /** | |
165 | * Sets the backgroundcolor of the rectangle. | |
166 | * | |
167 | * @param value the new value | |
168 | */ | |
169 | public void setBackgroundColor(Color value) { | |
170 | throwReadOnlyError(); | |
171 | } | |
172 | ||
173 | /** | |
174 | * Sets the grayscale of the rectangle. | |
175 | * | |
176 | * @param value the new value | |
177 | */ | |
178 | public void setGrayFill(float value) { | |
179 | throwReadOnlyError(); | |
180 | } | |
181 | | |
182 | // OVERWRITE METHODS SETTING THE BORDER: | |
183 | ||
184 | /** | |
185 | * Enables/Disables the border on the specified sides. | |
186 | * The border is specified as an integer bitwise combination of | |
187 | * the constants: <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE>. | |
188 | * | |
189 | * @see #enableBorderSide(int) | |
190 | * @see #disableBorderSide(int) | |
191 | * @param border the new value | |
192 | */ | |
193 | public void setBorder(int border) { | |
194 | throwReadOnlyError(); | |
195 | } | |
196 | | |
197 | /** | |
198 | * Sets a parameter indicating if the rectangle has variable borders | |
199 | * | |
200 | * @param useVariableBorders indication if the rectangle has variable borders | |
201 | */ | |
202 | public void setUseVariableBorders(boolean useVariableBorders) { | |
203 | throwReadOnlyError(); | |
204 | } | |
205 | ||
206 | /** | |
207 | * Enables the border on the specified side. | |
208 | * | |
209 | * @param side the side to enable. | |
210 | * One of <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE> | |
211 | */ | |
212 | public void enableBorderSide(int side) { | |
213 | throwReadOnlyError(); | |
214 | } | |
215 | ||
216 | /** | |
217 | * Disables the border on the specified side. | |
218 | * | |
219 | * @param side the side to disable. | |
220 | * One of <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE> | |
221 | */ | |
222 | public void disableBorderSide(int side) { | |
223 | throwReadOnlyError(); | |
224 | } | |
225 | ||
226 | // OVERWRITE METHODS SETTING THE BORDER WIDTH: | |
227 | ||
228 | /** | |
229 | * Sets the borderwidth of the table. | |
230 | * | |
231 | * @param borderWidth the new value | |
232 | */ | |
233 | ||
234 | public void setBorderWidth(float borderWidth) { | |
235 | throwReadOnlyError(); | |
236 | } | |
237 | ||
238 | /** | |
239 | * Sets the width of the left border | |
240 | * | |
241 | * @param borderWidthLeft a width | |
242 | */ | |
243 | public void setBorderWidthLeft(float borderWidthLeft) { | |
244 | throwReadOnlyError(); | |
245 | } | |
246 | ||
247 | /** | |
248 | * Sets the width of the right border | |
249 | * | |
250 | * @param borderWidthRight a width | |
251 | */ | |
252 | public void setBorderWidthRight(float borderWidthRight) { | |
253 | throwReadOnlyError(); | |
254 | } | |
255 | ||
256 | /** | |
257 | * Sets the width of the top border | |
258 | * | |
259 | * @param borderWidthTop a width | |
260 | */ | |
261 | public void setBorderWidthTop(float borderWidthTop) { | |
262 | throwReadOnlyError(); | |
263 | } | |
264 | ||
265 | /** | |
266 | * Sets the width of the bottom border | |
267 | * | |
268 | * @param borderWidthBottom a width | |
269 | */ | |
270 | public void setBorderWidthBottom(float borderWidthBottom) { | |
271 | throwReadOnlyError(); | |
272 | } | |
273 | ||
274 | // METHODS TO GET/SET THE BORDER COLOR: | |
275 | ||
276 | /** | |
277 | * Sets the color of the border. | |
278 | * | |
279 | * @param borderColor a <CODE>Color</CODE> | |
280 | */ | |
281 | ||
282 | public void setBorderColor(Color borderColor) { | |
283 | throwReadOnlyError(); | |
284 | } | |
285 | | |
286 | /** | |
287 | * Sets the color of the left border. | |
288 | * | |
289 | * @param borderColorLeft a <CODE>Color</CODE> | |
290 | */ | |
291 | public void setBorderColorLeft(Color borderColorLeft) { | |
292 | throwReadOnlyError(); | |
293 | } | |
294 | ||
295 | /** | |
296 | * Sets the color of the right border | |
297 | * | |
298 | * @param borderColorRight a <CODE>Color</CODE> | |
299 | */ | |
300 | public void setBorderColorRight(Color borderColorRight) { | |
301 | throwReadOnlyError(); | |
302 | } | |
303 | ||
304 | /** | |
305 | * Sets the color of the top border. | |
306 | * | |
307 | * @param borderColorTop a <CODE>Color</CODE> | |
308 | */ | |
309 | public void setBorderColorTop(Color borderColorTop) { | |
310 | throwReadOnlyError(); | |
311 | } | |
312 | ||
313 | /** | |
314 | * Sets the color of the bottom border. | |
315 | * | |
316 | * @param borderColorBottom a <CODE>Color</CODE> | |
317 | */ | |
318 | public void setBorderColorBottom(Color borderColorBottom) { | |
319 | throwReadOnlyError(); | |
320 | } | |
321 | ||
322 | // SPECIAL METHODS: | |
323 | ||
324 | /** | |
325 | * Copies each of the parameters, except the position, from a | |
326 | * <CODE>Rectangle</CODE> object | |
327 | * | |
328 | * @param rect <CODE>Rectangle</CODE> to copy from | |
329 | */ | |
330 | public void cloneNonPositionParameters(Rectangle rect) { | |
331 | throwReadOnlyError(); | |
332 | } | |
333 | ||
334 | /** | |
335 | * Copies each of the parameters, except the position, from a | |
336 | * <CODE>Rectangle</CODE> object if the value is set there. | |
337 | * | |
338 | * @param rect <CODE>Rectangle</CODE> to copy from | |
339 | */ | |
340 | public void softCloneNonPositionParameters(Rectangle rect) { | |
341 | throwReadOnlyError(); | |
342 | } | |
343 | | |
344 | /** | |
345 | * @return String version of the most important rectangle properties | |
346 | * @see java.lang.Object#toString() | |
347 | */ | |
348 | public String toString() { | |
349 | StringBuilder buf = new StringBuilder("RectangleReadOnly: "); | |
350 | buf.append(getWidth()); | |
351 | buf.append('x'); | |
352 | buf.append(getHeight()); | |
353 | buf.append(" (rot: "); | |
354 | buf.append(rotation); | |
355 | buf.append(" degrees)"); | |
356 | return buf.toString(); | |
357 | } | |
358 | } | |
Mutations | ||
105 |
1.1 |