1794 return pathToShape(getCaretPath(hit, bounds), false, textLine.getLayoutPath());
1795 }
1796
1797 /**
1798 * Returns a <code>Shape</code> representing the caret at the specified
1799 * hit inside the natural bounds of this <code>TextLayout</code>.
1800 * @param hit the hit at which to generate the caret
1801 * @return a <code>Shape</code> representing the caret. The returned
1802 * shape is in standard coordinates.
1803 */
1804 public Shape getCaretShape(TextHitInfo hit) {
1805
1806 return getCaretShape(hit, getNaturalBounds());
1807 }
1808
1809 /**
1810 * Return the "stronger" of the TextHitInfos. The TextHitInfos
1811 * should be logical or visual counterparts. They are not
1812 * checked for validity.
1813 */
1814 private final TextHitInfo getStrongHit(TextHitInfo hit1, TextHitInfo hit2) {
1815
1816 // right now we're using the following rule for strong hits:
1817 // A hit on a character with a lower level
1818 // is stronger than one on a character with a higher level.
1819 // If this rule ties, the hit on the leading edge of a character wins.
1820 // If THIS rule ties, hit1 wins. Both rules shouldn't tie, unless the
1821 // infos aren't counterparts of some sort.
1822
1823 byte hit1Level = getCharacterLevel(hit1.getCharIndex());
1824 byte hit2Level = getCharacterLevel(hit2.getCharIndex());
1825
1826 if (hit1Level == hit2Level) {
1827 if (hit2.isLeadingEdge() && !hit1.isLeadingEdge()) {
1828 return hit2;
1829 }
1830 else {
1831 return hit1;
1832 }
1833 }
1834 else {
|
1794 return pathToShape(getCaretPath(hit, bounds), false, textLine.getLayoutPath());
1795 }
1796
1797 /**
1798 * Returns a <code>Shape</code> representing the caret at the specified
1799 * hit inside the natural bounds of this <code>TextLayout</code>.
1800 * @param hit the hit at which to generate the caret
1801 * @return a <code>Shape</code> representing the caret. The returned
1802 * shape is in standard coordinates.
1803 */
1804 public Shape getCaretShape(TextHitInfo hit) {
1805
1806 return getCaretShape(hit, getNaturalBounds());
1807 }
1808
1809 /**
1810 * Return the "stronger" of the TextHitInfos. The TextHitInfos
1811 * should be logical or visual counterparts. They are not
1812 * checked for validity.
1813 */
1814 private TextHitInfo getStrongHit(TextHitInfo hit1, TextHitInfo hit2) {
1815
1816 // right now we're using the following rule for strong hits:
1817 // A hit on a character with a lower level
1818 // is stronger than one on a character with a higher level.
1819 // If this rule ties, the hit on the leading edge of a character wins.
1820 // If THIS rule ties, hit1 wins. Both rules shouldn't tie, unless the
1821 // infos aren't counterparts of some sort.
1822
1823 byte hit1Level = getCharacterLevel(hit1.getCharIndex());
1824 byte hit2Level = getCharacterLevel(hit2.getCharIndex());
1825
1826 if (hit1Level == hit2Level) {
1827 if (hit2.isLeadingEdge() && !hit1.isLeadingEdge()) {
1828 return hit2;
1829 }
1830 else {
1831 return hit1;
1832 }
1833 }
1834 else {
|