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.

KnuthPenalty.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 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.layoutmgr;
  18. /**
  19. * An instance of this class represents information about a feasible
  20. * breaking point; it does not represent any piece of content.
  21. *
  22. * A KnuthPenalty is a feasible breaking point unless its value is infinity;
  23. * a KnuthPenalty whose value is -infinity represents a forced break.
  24. *
  25. * A KnuthPenalty is suppressed, and its width is ignored, if it is not a
  26. * chosen breaking point; for example, a KnuthPenalty representing a
  27. * hyphenation point has a width (the "-" width), which must be ignored if
  28. * that point is not chosen as a breaking point.
  29. *
  30. * Besides the inherited methods and attributes, this class has two more
  31. * attributes and the methods used to get them: the penalty value, which is
  32. * a kind of "aesthetic cost" (the higher the value, the more unsightly the
  33. * breaking point), and a boolean that marks KnuthPenalties which should not
  34. * be chosen as breaking points for consecutive lines.
  35. */
  36. public class KnuthPenalty extends KnuthElement {
  37. private int penalty;
  38. private boolean bFlagged;
  39. /**
  40. * Create a new KnuthPenalty.
  41. *
  42. * @param w the width of this penalty
  43. * @param p the penalty value of this penalty
  44. * @param f is this penalty flagged?
  45. * @param pos the Position stored in this penalty
  46. * @param bAux is this penalty auxiliary?
  47. */
  48. public KnuthPenalty(int w, int p, boolean f, Position pos, boolean bAux) {
  49. super(KNUTH_PENALTY, w, pos, bAux);
  50. penalty = p;
  51. bFlagged = f;
  52. }
  53. /**
  54. * Return the penalty value of this penalty.
  55. */
  56. public int getP() {
  57. return penalty;
  58. }
  59. /**
  60. * Return true is this penalty is a flagged one.
  61. */
  62. public boolean isFlagged() {
  63. return bFlagged;
  64. }
  65. }