1. /*
  2. * @(#)GlyphJustificationInfo.java 1.17 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. /*
  8. * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
  9. * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
  10. *
  11. * The original version of this source code and documentation is
  12. * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
  13. * of IBM. These materials are provided under terms of a License
  14. * Agreement between Taligent and Sun. This technology is protected
  15. * by multiple US and International patents.
  16. *
  17. * This notice and attribution to Taligent may not be removed.
  18. * Taligent is a registered trademark of Taligent, Inc.
  19. */
  20. package java.awt.font;
  21. /**
  22. * The <code>GlyphJustificationInfo</code> class represents information
  23. * about the justification properties of a glyph. A glyph is the visual
  24. * representation of one or more characters. Many different glyphs can
  25. * be used to represent a single character or combination of characters.
  26. * The four justification properties represented by
  27. * <code>GlyphJustificationInfo</code> are weight, priority, absorb and
  28. * limit.
  29. * <p>
  30. * Weight is the overall 'weight' of the glyph in the line. Generally it is
  31. * proportional to the size of the font. Glyphs with larger weight are
  32. * allocated a correspondingly larger amount of the change in space.
  33. * <p>
  34. * Priority determines the justification phase in which this glyph is used.
  35. * All glyphs of the same priority are examined before glyphs of the next
  36. * priority. If all the change in space can be allocated to these glyphs
  37. * without exceeding their limits, then glyphs of the next priority are not
  38. * examined. There are four priorities, kashida, whitespace, interchar,
  39. * and none. KASHIDA is the first priority examined. NONE is the last
  40. * priority examined.
  41. * <p>
  42. * Absorb determines whether a glyph absorbs all change in space. Within a
  43. * given priority, some glyphs may absorb all the change in space. If any of
  44. * these glyphs are present, no glyphs of later priority are examined.
  45. * <p>
  46. * Limit determines the maximum or minimum amount by which the glyph can
  47. * change. Left and right sides of the glyph can have different limits.
  48. * <p>
  49. * Each <code>GlyphJustificationInfo</code> represents two sets of
  50. * metrics, which are <i>growing</i> and <i>shrinking</i>. Growing
  51. * metrics are used when the glyphs on a line are to be
  52. * spread apart to fit a larger width. Shrinking metrics are used when
  53. * the glyphs are to be moved together to fit a smaller width.
  54. */
  55. public final class GlyphJustificationInfo {
  56. /**
  57. * Constructs information about the justification properties of a
  58. * glyph.
  59. * @param weight the weight of this glyph when allocating space
  60. * @param growAbsorb if <code>true</code> this glyph absorbs
  61. * all extra space at this priority and lower priority levels when it
  62. * grows
  63. * @param growPriority the priority level of this glyph when it
  64. * grows
  65. * @param growLeftLimit the maximum amount by which the left side of this
  66. * glyph can grow
  67. * @param growRightLimit the maximum amount by which the right side of this
  68. * glyph can grow
  69. * @param shrinkAbsorb if <code>true</code>, this glyph absorbs all
  70. * remaining shrinkage at this and lower priority levels when it
  71. * shrinks
  72. * @param shrinkPriority the priority level of this glyph when
  73. * it shrinks
  74. * @param shrinkLeftLimit the maximum amount by which the left side of this
  75. * glyph can shrink (a positive number)
  76. * @param shrinkRightLimit the maximum amount by which the right side
  77. * of this glyph can shrink (a postive number)
  78. */
  79. public GlyphJustificationInfo(float weight,
  80. boolean growAbsorb,
  81. int growPriority,
  82. float growLeftLimit,
  83. float growRightLimit,
  84. boolean shrinkAbsorb,
  85. int shrinkPriority,
  86. float shrinkLeftLimit,
  87. float shrinkRightLimit)
  88. {
  89. this.weight = weight;
  90. this.growAbsorb = growAbsorb;
  91. this.growPriority = (byte)growPriority;
  92. this.growLeftLimit = growLeftLimit;
  93. this.growRightLimit = growRightLimit;
  94. this.shrinkAbsorb = shrinkAbsorb;
  95. this.shrinkPriority = (byte)shrinkPriority;
  96. this.shrinkLeftLimit = shrinkLeftLimit;
  97. this.shrinkRightLimit = shrinkRightLimit;
  98. }
  99. /** The highest justification priority. */
  100. public static final int PRIORITY_KASHIDA = 0;
  101. /** The second highest justification priority. */
  102. public static final int PRIORITY_WHITESPACE = 1;
  103. /** The second lowest justification priority. */
  104. public static final int PRIORITY_INTERCHAR = 2;
  105. /** The lowest justification priority. */
  106. public static final int PRIORITY_NONE = 3;
  107. /**
  108. * The weight of this glyph.
  109. */
  110. public final float weight;
  111. /**
  112. * The priority level of this glyph as it is growing.
  113. */
  114. public final int growPriority;
  115. /**
  116. * If <code>true</code>, this glyph absorbs all extra
  117. * space at this and lower priority levels when it grows.
  118. */
  119. public final boolean growAbsorb;
  120. /**
  121. * The maximum amount by which the left side of this glyph can grow.
  122. */
  123. public final float growLeftLimit;
  124. /**
  125. * The maximum amount by which the right side of this glyph can grow.
  126. */
  127. public final float growRightLimit;
  128. /**
  129. * The priority level of this glyph as it is shrinking.
  130. */
  131. public final int shrinkPriority;
  132. /**
  133. * If <code>true</code>,this glyph absorbs all remaining shrinkage at
  134. * this and lower priority levels as it shrinks.
  135. */
  136. public final boolean shrinkAbsorb;
  137. /**
  138. * The maximum amount by which the left side of this glyph can shrink
  139. * (a positive number).
  140. */
  141. public final float shrinkLeftLimit;
  142. /**
  143. * The maximum amount by which the right side of this glyph can shrink
  144. * (a positive number).
  145. */
  146. public final float shrinkRightLimit;
  147. }