本文整理汇总了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;
}