summaryrefslogtreecommitdiffstats
path: root/awt/java/awt/font/TextMeasurer.java
diff options
context:
space:
mode:
Diffstat (limited to 'awt/java/awt/font/TextMeasurer.java')
-rw-r--r--awt/java/awt/font/TextMeasurer.java117
1 files changed, 66 insertions, 51 deletions
diff --git a/awt/java/awt/font/TextMeasurer.java b/awt/java/awt/font/TextMeasurer.java
index 017f3d9..9741f59 100644
--- a/awt/java/awt/font/TextMeasurer.java
+++ b/awt/java/awt/font/TextMeasurer.java
@@ -21,7 +21,6 @@
package java.awt.font;
-
import java.text.AttributedCharacterIterator;
import org.apache.harmony.awt.gl.font.TextMetricsCalculator;
@@ -29,26 +28,38 @@ import org.apache.harmony.awt.gl.font.TextRunBreaker;
/**
* The TextMeasurer class provides utilities for line break operations.
+ *
+ * @since Android 1.0
*/
public final class TextMeasurer implements Cloneable {
-
- /** The aci. */
+
+ /**
+ * The aci.
+ */
AttributedCharacterIterator aci;
-
- /** The frc. */
+
+ /**
+ * The frc.
+ */
FontRenderContext frc;
-
- /** The breaker. */
+
+ /**
+ * The breaker.
+ */
TextRunBreaker breaker = null;
-
- /** The tmc. */
+
+ /**
+ * The tmc.
+ */
TextMetricsCalculator tmc = null;
/**
* Instantiates a new text measurer from the specified text.
*
- * @param text the source text.
- * @param frc the FontRenderContext.
+ * @param text
+ * the source text.
+ * @param frc
+ * the FontRenderContext.
*/
public TextMeasurer(AttributedCharacterIterator text, FontRenderContext frc) {
this.aci = text;
@@ -58,17 +69,19 @@ public final class TextMeasurer implements Cloneable {
}
/**
- * Replaces the current text with the new text, inserting a break
- * character at the specified insert position.
+ * Replaces the current text with the new text, inserting a break character
+ * at the specified insert position.
*
- * @param newParagraph the new paragraph text.
- * @param insertPos the position in the text where the character is inserted.
+ * @param newParagraph
+ * the new paragraph text.
+ * @param insertPos
+ * the position in the text where the character is inserted.
*/
public void insertChar(AttributedCharacterIterator newParagraph, int insertPos) {
AttributedCharacterIterator oldAci = aci;
aci = newParagraph;
- if ((oldAci.getEndIndex() - oldAci.getBeginIndex()) -
- (aci.getEndIndex() - aci.getBeginIndex()) != -1) {
+ if ((oldAci.getEndIndex() - oldAci.getBeginIndex())
+ - (aci.getEndIndex() - aci.getBeginIndex()) != -1) {
breaker = new TextRunBreaker(aci, this.frc);
tmc = new TextMetricsCalculator(breaker);
} else {
@@ -77,17 +90,19 @@ public final class TextMeasurer implements Cloneable {
}
/**
- * Replaces the current text with the new text and deletes a
- * character at the specified position.
+ * Replaces the current text with the new text and deletes a character at
+ * the specified position.
*
- * @param newParagraph the paragraph text after deletion.
- * @param deletePos the position in the text where the character is removed.
+ * @param newParagraph
+ * the paragraph text after deletion.
+ * @param deletePos
+ * the position in the text where the character is removed.
*/
public void deleteChar(AttributedCharacterIterator newParagraph, int deletePos) {
AttributedCharacterIterator oldAci = aci;
aci = newParagraph;
- if ((oldAci.getEndIndex() - oldAci.getBeginIndex()) -
- (aci.getEndIndex() - aci.getBeginIndex()) != 1) {
+ if ((oldAci.getEndIndex() - oldAci.getBeginIndex())
+ - (aci.getEndIndex() - aci.getBeginIndex()) != 1) {
breaker = new TextRunBreaker(aci, this.frc);
tmc = new TextMetricsCalculator(breaker);
} else {
@@ -102,39 +117,39 @@ public final class TextMeasurer implements Cloneable {
*/
@Override
protected Object clone() {
- return new TextMeasurer((AttributedCharacterIterator) aci.clone(), frc);
+ return new TextMeasurer((AttributedCharacterIterator)aci.clone(), frc);
}
/**
* Returns a TextLayout of the specified character range.
*
- * @param start the index of the first character.
- * @param limit the index after the last character.
- *
- * @return a TextLayout for the characters beginning at "start" up
- * to "end".
+ * @param start
+ * the index of the first character.
+ * @param limit
+ * the index after the last character.
+ * @return a TextLayout for the characters beginning at "start" up to "end".
*/
public TextLayout getLayout(int start, int limit) {
breaker.pushSegments(start - aci.getBeginIndex(), limit - aci.getBeginIndex());
breaker.createAllSegments();
- TextLayout layout = new TextLayout((TextRunBreaker) breaker.clone());
+ TextLayout layout = new TextLayout((TextRunBreaker)breaker.clone());
breaker.popSegments();
return layout;
}
/**
- * Returns the graphical width of a line beginning at "start"
- * parameter and including characters up to "end" parameter.
- * "start" and "end" are absolute indices, not relative to the
- * "start" of the paragraph.
- *
- * @param start the character index at which to start measuring.
- * @param end the character index at which to stop measuring.
+ * Returns the graphical width of a line beginning at "start" parameter and
+ * including characters up to "end" parameter. "start" and "end" are
+ * absolute indices, not relative to the "start" of the paragraph.
*
- * @return the graphical width of a line beginning at "start"
- * and including characters up to "end".
+ * @param start
+ * the character index at which to start measuring.
+ * @param end
+ * the character index at which to stop measuring.
+ * @return the graphical width of a line beginning at "start" and including
+ * characters up to "end".
*/
public float getAdvanceBetween(int start, int end) {
breaker.pushSegments(start - aci.getBeginIndex(), end - aci.getBeginIndex());
@@ -147,21 +162,21 @@ public final class TextMeasurer implements Cloneable {
}
/**
- * Returns the index of the first character which is not fit on
- * a line beginning at start and possible measuring up to maxAdvance
- * in graphical width.
- *
- * @param start he character index at which to start measuring.
- * @param maxAdvance the graphical width in which the line must fit.
- *
- * @return the index after the last character that is fit on a line
- * beginning at start, which is not longer than maxAdvance in graphical
+ * Returns the index of the first character which is not fit on a line
+ * beginning at start and possible measuring up to maxAdvance in graphical
* width.
+ *
+ * @param start
+ * he character index at which to start measuring.
+ * @param maxAdvance
+ * the graphical width in which the line must fit.
+ * @return the index after the last character that is fit on a line
+ * beginning at start, which is not longer than maxAdvance in
+ * graphical width.
*/
public int getLineBreakIndex(int start, float maxAdvance) {
breaker.createAllSegments();
- return breaker.getLineBreakIndex(
- start - aci.getBeginIndex(), maxAdvance) + aci.getBeginIndex();
+ return breaker.getLineBreakIndex(start - aci.getBeginIndex(), maxAdvance)
+ + aci.getBeginIndex();
}
}
-