Methods Summary |
---|
protected java.lang.Object | clone()Returns a copy of this object.
TextLayout res = new TextLayout((TextRunBreaker)breaker.clone());
if (justificationWidth >= 0) {
res.handleJustify(justificationWidth);
}
return res;
|
public void | draw(java.awt.Graphics2D g2d, float x, float y)Draws this TextLayout at the specified location with the specified
Graphics2D context.
updateMetrics();
breaker.drawSegments(g2d, x, y);
|
public boolean | equals(java.awt.font.TextLayout layout)Compares this TextLayout object to the specified TextLayout object.
if (layout == null) {
return false;
}
return this.breaker.equals(layout.breaker);
|
public boolean | equals(java.lang.Object obj)Compares this TextLayout object to the specified Object.
return obj instanceof TextLayout ? equals((TextLayout)obj) : false;
|
public float | getAdvance()Gets the advance of this TextLayout object.
updateMetrics();
return metrics.getAdvance();
|
public float | getAscent()Gets the ascent of this TextLayout object.
updateMetrics();
return metrics.getAscent();
|
public byte | getBaseline()Gets the baseline of this TextLayout object.
updateMetrics();
return (byte)metrics.getBaseLineIndex();
|
public float[] | getBaselineOffsets()Gets the float array of offsets for the baselines which are used in this
TextLayout.
updateMetrics();
return tmc.getBaselineOffsets();
|
public java.awt.Shape | getBlackBoxBounds(int firstEndpoint, int secondEndpoint)Gets the black box bounds of the characters in the specified area. The
black box bounds is an Shape which contains all bounding boxes of all the
glyphs of the characters between firstEndpoint and secondEndpoint
parameters values.
updateMetrics();
if (firstEndpoint < secondEndpoint) {
return breaker.getBlackBoxBounds(firstEndpoint, secondEndpoint);
}
return breaker.getBlackBoxBounds(secondEndpoint, firstEndpoint);
|
public java.awt.geom.Rectangle2D | getBounds()Gets the bounds of this TextLayout.
updateMetrics();
return breaker.getVisualBounds();
|
public float[] | getCaretInfo(java.awt.font.TextHitInfo hitInfo)Gets information about the caret of the specified TextHitInfo.
updateMetrics();
return caretManager.getCaretInfo(hitInfo);
|
public float[] | getCaretInfo(java.awt.font.TextHitInfo hitInfo, java.awt.geom.Rectangle2D bounds)Gets information about the caret of the specified TextHitInfo of a
character in this TextLayout.
updateMetrics();
return caretManager.getCaretInfo(hitInfo);
|
public java.awt.Shape | getCaretShape(java.awt.font.TextHitInfo hitInfo, java.awt.geom.Rectangle2D bounds)Gets a Shape which represents the caret of the specified TextHitInfo in
the bounds of this TextLayout.
updateMetrics();
return caretManager.getCaretShape(hitInfo, this);
|
public java.awt.Shape | getCaretShape(java.awt.font.TextHitInfo hitInfo)Gets a Shape which represents the caret of the specified TextHitInfo in
the bounds of this TextLayout.
updateMetrics();
return caretManager.getCaretShape(hitInfo, this);
|
public java.awt.Shape[] | getCaretShapes(int offset)Gets two Shapes for the strong and weak carets with default caret policy
and null bounds: the first element is the strong caret, the second is the
weak caret or null.
return getCaretShapes(offset, null, TextLayout.DEFAULT_CARET_POLICY);
|
public java.awt.Shape[] | getCaretShapes(int offset, java.awt.geom.Rectangle2D bounds)Gets two Shapes for the strong and weak carets with the default caret
policy: the first element is the strong caret, the second is the weak
caret or null.
return getCaretShapes(offset, bounds, TextLayout.DEFAULT_CARET_POLICY);
|
public java.awt.Shape[] | getCaretShapes(int offset, java.awt.geom.Rectangle2D bounds, java.awt.font.TextLayout$CaretPolicy policy)Gets two Shapes for the strong and weak carets: the first element is the
strong caret, the second is the weak caret or null.
if (offset < 0 || offset > breaker.getCharCount()) {
// awt.195=Offset is out of bounds
throw new IllegalArgumentException(Messages.getString("awt.195")); //$NON-NLS-1$
}
updateMetrics();
return caretManager.getCaretShapes(offset, bounds, policy, this);
|
public int | getCharacterCount()Gets the number of characters in this TextLayout.
return breaker.getCharCount();
|
public byte | getCharacterLevel(int index)Gets the level of the character with the specified index.
if (index == -1 || index == getCharacterCount()) {
return (byte)breaker.getBaseLevel();
}
return breaker.getLevel(index);
|
public float | getDescent()Gets the descent of this TextLayout.
updateMetrics();
return metrics.getDescent();
|
public java.awt.font.TextLayout | getJustifiedLayout(float justificationWidth)Gets the TextLayout wich is justified with the specified width related to
this TextLayout.
float justification = breaker.getJustification();
if (justification < 0) {
// awt.196=Justification impossible, layout already justified
throw new Error(Messages.getString("awt.196")); //$NON-NLS-1$
} else if (justification == 0) {
return this;
}
TextLayout justifiedLayout = new TextLayout((TextRunBreaker)breaker.clone());
justifiedLayout.handleJustify(justificationWidth);
return justifiedLayout;
|
public float | getLeading()Gets the leading of this TextLayout.
updateMetrics();
return metrics.getLeading();
|
public java.awt.Shape | getLogicalHighlightShape(int firstEndpoint, int secondEndpoint)Gets a Shape representing the logical selection betweeen the specified
endpoints and extended to the natural bounds of this TextLayout.
updateMetrics();
return getLogicalHighlightShape(firstEndpoint, secondEndpoint, breaker.getLogicalBounds());
|
public java.awt.Shape | getLogicalHighlightShape(int firstEndpoint, int secondEndpoint, java.awt.geom.Rectangle2D bounds)Gets a Shape representing the logical selection betweeen the specified
endpoints and extended to the specified bounds of this TextLayout.
updateMetrics();
if (firstEndpoint > secondEndpoint) {
if (secondEndpoint < 0 || firstEndpoint > breaker.getCharCount()) {
// awt.197=Endpoints are out of range
throw new IllegalArgumentException(Messages.getString("awt.197")); //$NON-NLS-1$
}
return caretManager.getLogicalHighlightShape(secondEndpoint, firstEndpoint, bounds,
this);
}
if (firstEndpoint < 0 || secondEndpoint > breaker.getCharCount()) {
// awt.197=Endpoints are out of range
throw new IllegalArgumentException(Messages.getString("awt.197")); //$NON-NLS-1$
}
return caretManager.getLogicalHighlightShape(firstEndpoint, secondEndpoint, bounds, this);
|
public int[] | getLogicalRangesForVisualSelection(java.awt.font.TextHitInfo hit1, java.awt.font.TextHitInfo hit2)Gets the logical ranges of text which corresponds to a visual selection.
return caretManager.getLogicalRangesForVisualSelection(hit1, hit2);
|
public java.awt.font.TextHitInfo | getNextLeftHit(int offset)Gets the TextHitInfo for the next caret to the left (or up at the end of
the line) of the specified offset.
return getNextLeftHit(offset, DEFAULT_CARET_POLICY);
|
public java.awt.font.TextHitInfo | getNextLeftHit(java.awt.font.TextHitInfo hitInfo)Gets the TextHitInfo for the next caret to the left (or up at the end of
the line) of the specified hit.
breaker.createAllSegments();
return caretManager.getNextLeftHit(hitInfo);
|
public java.awt.font.TextHitInfo | getNextLeftHit(int offset, java.awt.font.TextLayout$CaretPolicy policy)Gets the TextHitInfo for the next caret to the left (or up at the end of
the line) of the specified offset, given the specified caret policy.
if (offset < 0 || offset > breaker.getCharCount()) {
// awt.195=Offset is out of bounds
throw new IllegalArgumentException(Messages.getString("awt.195")); //$NON-NLS-1$
}
TextHitInfo hit = TextHitInfo.afterOffset(offset);
TextHitInfo strongHit = policy.getStrongCaret(hit, hit.getOtherHit(), this);
TextHitInfo nextLeftHit = getNextLeftHit(strongHit);
if (nextLeftHit != null) {
return policy.getStrongCaret(getVisualOtherHit(nextLeftHit), nextLeftHit, this);
}
return null;
|
public java.awt.font.TextHitInfo | getNextRightHit(java.awt.font.TextHitInfo hitInfo)Gets the TextHitInfo for the next caret to the right (or down at the end
of the line) of the specified hit.
breaker.createAllSegments();
return caretManager.getNextRightHit(hitInfo);
|
public java.awt.font.TextHitInfo | getNextRightHit(int offset)Gets the TextHitInfo for the next caret to the right (or down at the end
of the line) of the specified offset.
return getNextRightHit(offset, DEFAULT_CARET_POLICY);
|
public java.awt.font.TextHitInfo | getNextRightHit(int offset, java.awt.font.TextLayout$CaretPolicy policy)Gets the TextHitInfo for the next caret to the right (or down at the end
of the line) of the specified offset, given the specified caret policy.
if (offset < 0 || offset > breaker.getCharCount()) {
// awt.195=Offset is out of bounds
throw new IllegalArgumentException(Messages.getString("awt.195")); //$NON-NLS-1$
}
TextHitInfo hit = TextHitInfo.afterOffset(offset);
TextHitInfo strongHit = policy.getStrongCaret(hit, hit.getOtherHit(), this);
TextHitInfo nextRightHit = getNextRightHit(strongHit);
if (nextRightHit != null) {
return policy.getStrongCaret(getVisualOtherHit(nextRightHit), nextRightHit, this);
}
return null;
|
public java.awt.Shape | getOutline(java.awt.geom.AffineTransform xform)Gets the outline of this TextLayout as a Shape.
breaker.createAllSegments();
GeneralPath outline = breaker.getOutline();
if (outline != null && xform != null) {
outline.transform(xform);
}
return outline;
|
public float | getVisibleAdvance()Gets the visible advance of this TextLayout which is defined as diffence
between leading (advance) and trailing whitespace.
updateMetrics();
// Trailing whitespace _SHOULD_ be reordered (Unicode spec) to
// base direction, so it is also trailing
// in logical representation. We use this fact.
int lastNonWhitespace = breaker.getLastNonWhitespace();
if (lastNonWhitespace < 0) {
return 0;
} else if (lastNonWhitespace == getCharacterCount() - 1) {
return getAdvance();
} else if (justificationWidth >= 0) { // Layout is justified
return justificationWidth;
} else {
breaker.pushSegments(breaker.getACI().getBeginIndex(), lastNonWhitespace
+ breaker.getACI().getBeginIndex() + 1);
breaker.createAllSegments();
float visAdvance = tmc.createMetrics().getAdvance();
breaker.popSegments();
return visAdvance;
}
|
public java.awt.Shape | getVisualHighlightShape(java.awt.font.TextHitInfo hit1, java.awt.font.TextHitInfo hit2, java.awt.geom.Rectangle2D bounds)Gets a Shape which corresponds to the highlighted (selected) area based
on two hit locations within the text and extends to the bounds.
return caretManager.getVisualHighlightShape(hit1, hit2, bounds, this);
|
public java.awt.Shape | getVisualHighlightShape(java.awt.font.TextHitInfo hit1, java.awt.font.TextHitInfo hit2)Gets a Shape which corresponds to the highlighted (selected) area based
on two hit locations within the text.
breaker.createAllSegments();
return caretManager.getVisualHighlightShape(hit1, hit2, breaker.getLogicalBounds(), this);
|
public java.awt.font.TextHitInfo | getVisualOtherHit(java.awt.font.TextHitInfo hitInfo)Gets the TextHitInfo for a hit on the opposite side of the specified
hit's caret.
return caretManager.getVisualOtherHit(hitInfo);
|
protected void | handleJustify(float justificationWidth)Justifies the text; this method should be overridden by subclasses.
float justification = breaker.getJustification();
if (justification < 0) {
// awt.196=Justification impossible, layout already justified
throw new IllegalStateException(Messages.getString("awt.196")); //$NON-NLS-1$
} else if (justification == 0) {
return;
}
float gap = (justificationWidth - getVisibleAdvance()) * justification;
breaker.justify(gap);
this.justificationWidth = justificationWidth;
// Correct metrics
tmc = new TextMetricsCalculator(breaker);
tmc.correctAdvance(metrics);
|
public int | hashCode()Returns a hash code of this TextLayout object.
return breaker.hashCode();
|
public java.awt.font.TextHitInfo | hitTestChar(float x, float y)Returns a TextHitInfo object that gives information on which division
point (between two characters) is corresponds to a hit (such as a mouse
click) at the specified coordinates.
return hitTestChar(x, y, getBounds());
|
public java.awt.font.TextHitInfo | hitTestChar(float x, float y, java.awt.geom.Rectangle2D bounds)Returns a TextHitInfo object that gives information on which division
point (between two characters) is corresponds to a hit (such as a mouse
click) at the specified coordinates within the specified text rectangle.
if (x > bounds.getMaxX()) {
return breaker.isLTR() ? TextHitInfo.trailing(breaker.getCharCount() - 1) : TextHitInfo
.leading(0);
}
if (x < bounds.getMinX()) {
return breaker.isLTR() ? TextHitInfo.leading(0) : TextHitInfo.trailing(breaker
.getCharCount() - 1);
}
return breaker.hitTest(x, y);
|
public boolean | isLeftToRight()Returns true if this TextLayout has a "left to right" direction.
return breaker.isLTR();
|
public boolean | isVertical()Returns true if this TextLayout is vertical, false otherwise.
return false;
|
public java.lang.String | toString()Gets the string representation for this TextLayout. // what for?
return super.toString();
|
private void | updateMetrics()Update metrics.
if (!metricsValid) {
breaker.createAllSegments();
tmc = new TextMetricsCalculator(breaker);
metrics = tmc.createMetrics();
metricsValid = true;
}
|