1 50 51 package com.lowagie.text.pdf; 52 53 import com.lowagie.text.Rectangle; 54 55 68 69 public class PdfRectangle extends PdfArray { 70 71 73 74 private float llx = 0; 75 76 77 private float lly = 0; 78 79 80 private float urx = 0; 81 82 83 private float ury = 0; 84 85 87 97 98 public PdfRectangle(float llx, float lly, float urx, float ury, int rotation) { 99 super(); 100 if (rotation == 90 || rotation == 270) { 101 this.llx = lly; 102 this.lly = llx; 103 this.urx = ury; 104 this.ury = urx; 105 } 106 else { 107 this.llx = llx; 108 this.lly = lly; 109 this.urx = urx; 110 this.ury = ury; 111 } 112 super.add(new PdfNumber(this.llx)); 113 super.add(new PdfNumber(this.lly)); 114 super.add(new PdfNumber(this.urx)); 115 super.add(new PdfNumber(this.ury)); 116 } 117 118 public PdfRectangle(float llx, float lly, float urx, float ury) { 119 this(llx, lly, urx, ury, 0); 120 } 121 122 128 129 public PdfRectangle(float urx, float ury, int rotation) { 130 this(0, 0, urx, ury, rotation); 131 } 132 133 public PdfRectangle(float urx, float ury) { 134 this(0, 0, urx, ury, 0); 135 } 136 137 142 143 public PdfRectangle(Rectangle rectangle, int rotation) { 144 this(rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop(), rotation); 145 } 146 147 public PdfRectangle(Rectangle rectangle) { 148 this(rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop(), 0); 149 } 150 151 156 public Rectangle getRectangle() { 157 return new Rectangle(left(), bottom(), right(), top()); 158 } 159 160 166 167 public boolean add(PdfObject object) { 168 return false; 169 } 170 171 176 177 public float left() { 178 return llx; 179 } 180 181 186 187 public float right() { 188 return urx; 189 } 190 191 196 197 public float top() { 198 return ury; 199 } 200 201 206 207 public float bottom() { 208 return lly; 209 } 210 211 217 218 public float left(int margin) { 219 return llx + margin; 220 } 221 222 228 229 public float right(int margin) { 230 return urx - margin; 231 } 232 233 239 240 public float top(int margin) { 241 return ury - margin; 242 } 243 244 250 251 public float bottom(int margin) { 252 return lly + margin; 253 } 254 255 260 261 public float width() { 262 return urx - llx; 263 } 264 265 270 271 public float height() { 272 return ury - lly; 273 } 274 275 280 281 public PdfRectangle rotate() { 282 return new PdfRectangle(lly, llx, ury, urx, 0); 283 } 284 } | Popular Tags |