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