1. /*
  2. * @(#)LineMetrics.java 1.20 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. /*
  8. * @(#)LineMetrics.java 1.4 98/09/21
  9. */
  10. package java.awt.font;
  11. /**
  12. * The <code>LineMetrics</code> class allows access to the
  13. * metrics needed to layout characters along a line
  14. * and to layout of a set of lines. A <code>LineMetrics</code>
  15. * object encapsulates the measurement information associated
  16. * with a run of text.
  17. * <p>
  18. * Fonts can have different metrics for different ranges of
  19. * characters. The <code>getLineMetrics</code> methods of
  20. * {@link java.awt.Font Font} take some text as an argument
  21. * and return a <code>LineMetrics</code> object describing the
  22. * metrics of the initial number of characters in that text, as
  23. * returned by {@link #getNumChars}.
  24. */
  25. public abstract class LineMetrics {
  26. /**
  27. * Returns the number of characters (<code>char</code> values) in the text whose
  28. * metrics are encapsulated by this <code>LineMetrics</code>
  29. * object.
  30. * @return the number of characters (<code>char</code> values) in the text with which
  31. * this <code>LineMetrics</code> was created.
  32. */
  33. public abstract int getNumChars();
  34. /**
  35. * Returns the ascent of the text. The ascent
  36. * is the distance from the baseline
  37. * to the ascender line. The ascent usually represents the
  38. * the height of the capital letters of the text. Some characters
  39. * can extend above the ascender line.
  40. * @return the ascent of the text.
  41. */
  42. public abstract float getAscent();
  43. /**
  44. * Returns the descent of the text. The descent
  45. * is the distance from the baseline
  46. * to the descender line. The descent usually represents
  47. * the distance to the bottom of lower case letters like
  48. * 'p'. Some characters can extend below the descender
  49. * line.
  50. * @return the descent of the text.
  51. */
  52. public abstract float getDescent();
  53. /**
  54. * Returns the leading of the text. The
  55. * leading is the recommended
  56. * distance from the bottom of the descender line to the
  57. * top of the next line.
  58. * @return the leading of the text.
  59. */
  60. public abstract float getLeading();
  61. /**
  62. * Returns the height of the text. The
  63. * height is equal to the sum of the ascent, the
  64. * descent and the leading.
  65. * @return the height of the text.
  66. */
  67. public abstract float getHeight();
  68. /**
  69. * Returns the baseline index of the text.
  70. * The index is one of
  71. * {@link java.awt.Font#ROMAN_BASELINE ROMAN_BASELINE},
  72. * {@link java.awt.Font#CENTER_BASELINE CENTER_BASELINE},
  73. * {@link java.awt.Font#HANGING_BASELINE HANGING_BASELINE}.
  74. * @return the baseline of the text.
  75. */
  76. public abstract int getBaselineIndex();
  77. /**
  78. * Returns the baseline offsets of the text,
  79. * relative to the baseline of the text. The
  80. * offsets are indexed by baseline index. For
  81. * example, if the baseline index is
  82. * <code>CENTER_BASELINE</code> then
  83. * <code>offsets[HANGING_BASELINE]</code> is usually
  84. * negative, <code>offsets[CENTER_BASELINE]</code>
  85. * is zero, and <code>offsets[ROMAN_BASELINE]</code>
  86. * is usually positive.
  87. * @return the baseline offsets of the text.
  88. */
  89. public abstract float[] getBaselineOffsets();
  90. /**
  91. * Returns the position of the strike-through line
  92. * relative to the baseline.
  93. * @return the position of the strike-through line.
  94. */
  95. public abstract float getStrikethroughOffset();
  96. /**
  97. * Returns the thickness of the strike-through line.
  98. * @return the thickness of the strike-through line.
  99. */
  100. public abstract float getStrikethroughThickness();
  101. /**
  102. * Returns the position of the underline relative to
  103. * the baseline.
  104. * @return the position of the underline.
  105. */
  106. public abstract float getUnderlineOffset();
  107. /**
  108. * Returns the thickness of the underline.
  109. * @return the thickness of the underline.
  110. */
  111. public abstract float getUnderlineThickness();
  112. }