01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: PDFRectangle.java 533986 2007-05-01 09:41:05Z jeremias $ */
19:
20: package org.apache.fop.pdf;
21:
22: /**
23: * class representing a rectangle
24: *
25: * Rectangles are specified on page 183 of the PDF 1.3 spec.
26: */
27: public class PDFRectangle {
28:
29: /**
30: * lower left x coordinate
31: */
32: protected int llx;
33:
34: /**
35: * lower left y coordinate
36: */
37: protected int lly;
38:
39: /**
40: * upper right x coordinate
41: */
42: protected int urx;
43:
44: /**
45: * upper right y coordinate
46: */
47: protected int ury;
48:
49: /**
50: * create a rectangle giving the four separate values
51: *
52: * @param llx lower left x coordinate
53: * @param lly lower left y coordinate
54: * @param urx upper right x coordinate
55: * @param ury upper right y coordinate
56: */
57: public PDFRectangle(int llx, int lly, int urx, int ury) {
58: this .llx = llx;
59: this .lly = lly;
60: this .urx = urx;
61: this .ury = ury;
62: }
63:
64: /**
65: * create a rectangle giving an array of four values
66: *
67: * @param array values in the order llx, lly, urx, ury
68: */
69: public PDFRectangle(int[] array) {
70: this .llx = array[0];
71: this .lly = array[1];
72: this .urx = array[2];
73: this .ury = array[3];
74: }
75:
76: /**
77: * produce the PDF representation for the object
78: *
79: * @return the PDF
80: */
81: public byte[] toPDF() {
82: return PDFDocument.encode(toPDFString());
83: }
84:
85: /**
86: * Create a PDF string for this rectangle.
87: *
88: * @return the pdf string
89: */
90: public String toPDFString() {
91: return new String(" [" + llx + " " + lly + " " + urx + " "
92: + ury + "] ");
93: }
94:
95: }
|