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.

KnuthElement.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /**
  20. * This is the super class for KnuthBox, KnuthGlue and KnuthPenalty.
  21. *
  22. * It stores information common to all sub classes, and the methods to get it:
  23. * the width, a Position and a boolean marking KnuthElements used for some
  24. * special feature (for example, the additional elements used to represent
  25. * a space when text alignment is right, left or center).
  26. */
  27. public abstract class KnuthElement extends ListElement {
  28. /** The value used as an infinite indicator. */
  29. public static final int INFINITE = 1000;
  30. private int width;
  31. private boolean auxiliary;
  32. /**
  33. * Creates a new <code>KnuthElement</code>.
  34. *
  35. * @param width the width of this element
  36. * @param pos the Position stored in this element
  37. * @param auxiliary is this an auxiliary element?
  38. */
  39. protected KnuthElement(int width, Position pos, boolean auxiliary) {
  40. super(pos);
  41. this.width = width;
  42. this.auxiliary = auxiliary;
  43. }
  44. /** @return true if this element is an auxiliary one. */
  45. public boolean isAuxiliary() {
  46. return auxiliary;
  47. }
  48. /** @return the width of this element. */
  49. public int getWidth() {
  50. return width;
  51. }
  52. /** @return the penalty value of this element, if applicable. */
  53. public int getPenalty() {
  54. throw new RuntimeException("Element is not a penalty");
  55. }
  56. /** @return the stretch value of this element, if applicable. */
  57. public int getStretch() {
  58. throw new RuntimeException("Element is not a glue");
  59. }
  60. /** @return the shrink value of this element, if applicable. */
  61. public int getShrink() {
  62. throw new RuntimeException("Element is not a glue");
  63. }
  64. /** {@inheritDoc} */
  65. public boolean isUnresolvedElement() {
  66. return false;
  67. }
  68. }