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.

PDFNameTreeNode.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. /**
  20. * Class representing a PDF name tree node.
  21. */
  22. public class PDFNameTreeNode extends PDFDictionary {
  23. private static final String KIDS = "Kids";
  24. private static final String NAMES = "Names";
  25. private static final String LIMITS = "Limits";
  26. /**
  27. * create a named destination
  28. */
  29. public PDFNameTreeNode() {
  30. /* generic creation of PDF object */
  31. super();
  32. }
  33. /**
  34. * Sets the Kids array.
  35. * @param kids the Kids array
  36. */
  37. public void setKids(PDFArray kids) {
  38. put(KIDS, kids);
  39. }
  40. /**
  41. * Returns the Kids array.
  42. * @return the Kids array
  43. */
  44. public PDFArray getKids() {
  45. return (PDFArray)get(KIDS);
  46. }
  47. /**
  48. * Sets the Names array.
  49. * @param names the Names array
  50. */
  51. public void setNames(PDFArray names) {
  52. put(NAMES, names);
  53. }
  54. /**
  55. * Returns the Names array.
  56. * @return the Names array
  57. */
  58. public PDFArray getNames() {
  59. return (PDFArray)get(NAMES);
  60. }
  61. /**
  62. * Sets the lower limit value of the Limits array.
  63. * @param key the lower limit value
  64. */
  65. public void setLowerLimit(String key) {
  66. PDFArray limits = prepareLimitsArray();
  67. limits.set(0, key);
  68. }
  69. /**
  70. * Returns the lower limit value of the Limits array.
  71. * @return the lower limit value
  72. */
  73. public String getLowerLimit() {
  74. PDFArray limits = prepareLimitsArray();
  75. return (String)limits.get(0);
  76. }
  77. /**
  78. * Sets the upper limit value of the Limits array.
  79. * @param key the upper limit value
  80. */
  81. public void setUpperLimit(String key) {
  82. PDFArray limits = prepareLimitsArray();
  83. limits.set(1, key);
  84. }
  85. /**
  86. * Returns the upper limit value of the Limits array.
  87. * @return the upper limit value
  88. */
  89. public String getUpperLimit() {
  90. PDFArray limits = prepareLimitsArray();
  91. return (String)limits.get(1);
  92. }
  93. private PDFArray prepareLimitsArray() {
  94. PDFArray limits = (PDFArray)get(LIMITS);
  95. if (limits == null) {
  96. limits = new PDFArray(this, new Object[2]);
  97. put(LIMITS, limits);
  98. }
  99. if (limits.length() != 2) {
  100. throw new IllegalStateException("Limits array must have 2 entries");
  101. }
  102. return limits;
  103. }
  104. }