You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PDFRectangle.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.pdf;
  18. /**
  19. * class representing a rectangle
  20. *
  21. * Rectangles are specified on page 183 of the PDF 1.3 spec.
  22. */
  23. public class PDFRectangle {
  24. /**
  25. * lower left x coordinate
  26. */
  27. protected int llx;
  28. /**
  29. * lower left y coordinate
  30. */
  31. protected int lly;
  32. /**
  33. * upper right x coordinate
  34. */
  35. protected int urx;
  36. /**
  37. * upper right y coordinate
  38. */
  39. protected int ury;
  40. /**
  41. * create a rectangle giving the four separate values
  42. *
  43. * @param llx lower left x coordinate
  44. * @param lly lower left y coordinate
  45. * @param urx upper right x coordinate
  46. * @param ury upper right y coordinate
  47. */
  48. public PDFRectangle(int llx, int lly, int urx, int ury) {
  49. this.llx = llx;
  50. this.lly = lly;
  51. this.urx = urx;
  52. this.ury = ury;
  53. }
  54. /**
  55. * create a rectangle giving an array of four values
  56. *
  57. * @param array values in the order llx, lly, urx, ury
  58. */
  59. public PDFRectangle(int[] array) {
  60. this.llx = array[0];
  61. this.lly = array[1];
  62. this.urx = array[2];
  63. this.ury = array[3];
  64. }
  65. /**
  66. * produce the PDF representation for the object
  67. *
  68. * @return the PDF
  69. */
  70. public byte[] toPDF() {
  71. return toPDFString().getBytes();
  72. }
  73. /**
  74. * Create a PDF string for this rectangle.
  75. *
  76. * @return the pdf string
  77. */
  78. public String toPDFString() {
  79. return new String(" [" + llx + " " + lly + " " + urx + " " + ury
  80. + "] ");
  81. }
  82. }