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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * 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. /* $Id$ */
  18. package org.apache.fop.pdf;
  19. import java.io.IOException;
  20. import java.io.OutputStream;
  21. import java.io.Writer;
  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 implements PDFWritable {
  28. /**
  29. * lower left x coordinate
  30. */
  31. protected int llx;
  32. /**
  33. * lower left y coordinate
  34. */
  35. protected int lly;
  36. /**
  37. * upper right x coordinate
  38. */
  39. protected int urx;
  40. /**
  41. * upper right y coordinate
  42. */
  43. protected int ury;
  44. /**
  45. * create a rectangle giving the four separate values
  46. *
  47. * @param llx lower left x coordinate
  48. * @param lly lower left y coordinate
  49. * @param urx upper right x coordinate
  50. * @param ury upper right y coordinate
  51. */
  52. public PDFRectangle(int llx, int lly, int urx, int ury) {
  53. this.llx = llx;
  54. this.lly = lly;
  55. this.urx = urx;
  56. this.ury = ury;
  57. }
  58. /**
  59. * create a rectangle giving an array of four values
  60. *
  61. * @param array values in the order llx, lly, urx, ury
  62. */
  63. public PDFRectangle(int[] array) {
  64. this.llx = array[0];
  65. this.lly = array[1];
  66. this.urx = array[2];
  67. this.ury = array[3];
  68. }
  69. private String format() {
  70. return "[" + llx + " " + lly + " " + urx + " " + ury + "]";
  71. }
  72. /** {@inheritDoc} */
  73. public String toString() {
  74. return "PDFRectangle" + format();
  75. }
  76. /** {@inheritDoc} */
  77. public void outputInline(OutputStream out, Writer writer) throws IOException {
  78. writer.write(format());
  79. }
  80. }