本文整理匯總了Java中java.text.AttributedString.addAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java AttributedString.addAttributes方法的具體用法?Java AttributedString.addAttributes怎麽用?Java AttributedString.addAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.text.AttributedString
的用法示例。
在下文中一共展示了AttributedString.addAttributes方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTickLabel
import java.text.AttributedString; //導入方法依賴的package包/類
/**
* Creates a tick label for the specified value based on the current
* tick unit (used for formatting the exponent).
*
* @param value the value.
*
* @return The label.
*
* @since 1.0.18
*/
protected AttributedString createTickLabel(double value) {
if (this.numberFormatOverride != null) {
return new AttributedString(
this.numberFormatOverride.format(value));
} else {
String baseStr = this.baseSymbol;
if (baseStr == null) {
baseStr = this.baseFormatter.format(this.base);
}
double logy = calculateLog(value);
String exponentStr = getTickUnit().valueToString(logy);
AttributedString as = new AttributedString(baseStr + exponentStr);
as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr
+ exponentStr).length());
as.addAttribute(TextAttribute.SUPERSCRIPT,
TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(),
baseStr.length() + exponentStr.length());
return as;
}
}
示例2: newLine
import java.text.AttributedString; //導入方法依賴的package包/類
private void newLine() {
String text = getCurrentLineText();
AttributedString attrString = new AttributedString(text, STYLE_BASE);
Iterator it = currentLineCache.iterator();
int startCharIndex = 0;
while (it.hasNext()) {
LineCacheEntry entry = (LineCacheEntry)it.next();
int endCharIndex = startCharIndex + entry.text.length();
attrString.addAttributes(entry.attributes, startCharIndex, endCharIndex);
startCharIndex = endCharIndex;
}
lines.add(attrString);
textLines.add(text);
if (lineHeight == 0) {
TextLayout textLayout = new TextLayout(attrString.getIterator(), frc);
lineHeight = (int)(textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading());
ascent = (int)textLayout.getAscent();
textLayout = new TextLayout("0", STYLE_BASE, frc);
characterWidth = (int)textLayout.getAdvance();
}
currentHeight += lineHeight;
currentWidth = Math.max(currentWidth, characterWidth * text.length());
currentLineCache.clear();
}
示例3: createAttributedLabel
import java.text.AttributedString; //導入方法依賴的package包/類
/**
* Creates and returns an <code>AttributedString</code> with the specified
* text and the labelFont and labelPaint applied as attributes.
*
* @param label the label ({@code null} permitted).
*
* @return An attributed string or {@code null}.
*
* @since 1.0.16
*/
public AttributedString createAttributedLabel(String label) {
if (label == null) {
return null;
}
AttributedString s = new AttributedString(label);
s.addAttributes(this.labelFont.getAttributes(), 0, label.length());
return s;
}
示例4: createAttributedLabel
import java.text.AttributedString; //導入方法依賴的package包/類
/**
* Creates and returns an {@code AttributedString} with the specified
* text and the labelFont and labelPaint applied as attributes.
*
* @param label the label ({@code null} permitted).
*
* @return An attributed string or {@code null}.
*
* @since 1.0.16
*/
public AttributedString createAttributedLabel(String label) {
if (label == null) {
return null;
}
AttributedString s = new AttributedString(label);
s.addAttributes(this.labelFont.getAttributes(), 0, label.length());
return s;
}