Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

UnresolvedListElementWithLength.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.layoutmgr;
  19. import org.apache.commons.logging.Log;
  20. import org.apache.commons.logging.LogFactory;
  21. import org.apache.fop.traits.MinOptMax;
  22. /**
  23. * This class represents an unresolved list element element with a (conditional) length. This
  24. * is the base class for spaces, borders and paddings.
  25. */
  26. public abstract class UnresolvedListElementWithLength extends UnresolvedListElement {
  27. /** Logger instance */
  28. protected static final Log log = LogFactory.getLog(UnresolvedListElementWithLength.class);
  29. private MinOptMax length;
  30. private boolean conditional;
  31. private RelSide side;
  32. private boolean isFirst;
  33. private boolean isLast;
  34. /**
  35. * Main constructor
  36. * @param position the Position instance needed by the addAreas stage of the LMs.
  37. * @param length the length of the element
  38. * @param side the side to which this element applies
  39. * @param conditional true if it's a conditional element (conditionality=discard)
  40. * @param isFirst true if this is a space-before of the first area generated.
  41. * @param isLast true if this is a space-after of the last area generated.
  42. */
  43. public UnresolvedListElementWithLength(Position position, MinOptMax length,
  44. RelSide side,
  45. boolean conditional, boolean isFirst, boolean isLast) {
  46. super(position);
  47. this.length = length;
  48. this.side = side;
  49. this.conditional = conditional;
  50. this.isFirst = isFirst;
  51. this.isLast = isLast;
  52. }
  53. /** {@inheritDoc} */
  54. public boolean isConditional() {
  55. return this.conditional;
  56. }
  57. /** @return the space as resolved MinOptMax instance */
  58. public MinOptMax getLength() {
  59. return this.length;
  60. }
  61. /** @return the side this element was generated for */
  62. public RelSide getSide() {
  63. return this.side;
  64. }
  65. /** @return true if this is a space-before of the first area generated. */
  66. public boolean isFirst() {
  67. return this.isFirst;
  68. }
  69. /** @return true if this is a space-after of the last area generated. */
  70. public boolean isLast() {
  71. return this.isLast;
  72. }
  73. /**
  74. * Called to notify the affected layout manager about the effective length after resolution.
  75. * This method is called once before each call to the layout manager's addAreas() method.
  76. * @param effectiveLength the effective length after resolution (may be null which equals to
  77. * zero effective length)
  78. */
  79. public abstract void notifyLayoutManager(MinOptMax effectiveLength);
  80. /** {@inheritDoc} */
  81. public String toString() {
  82. StringBuffer sb = new StringBuffer();
  83. sb.append(getSide().getName()).append(", ");
  84. sb.append(this.length.toString());
  85. if (isConditional()) {
  86. sb.append("[discard]");
  87. } else {
  88. sb.append("[RETAIN]");
  89. }
  90. if (isFirst()) {
  91. sb.append("[first]");
  92. }
  93. if (isLast()) {
  94. sb.append("[last]");
  95. }
  96. return sb.toString();
  97. }
  98. }