本文整理汇总了Java中org.eclipse.jface.text.TextAttribute.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java TextAttribute.getFont方法的具体用法?Java TextAttribute.getFont怎么用?Java TextAttribute.getFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.TextAttribute
的用法示例。
在下文中一共展示了TextAttribute.getFont方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: merge
import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
private TextAttribute merge(TextAttribute first, TextAttribute second) {
if (first == null)
return second;
if (second == null)
return first;
int style = first.getStyle() | second.getStyle();
Color fgColor = second.getForeground();
if (fgColor == null)
fgColor = first.getForeground();
Color bgColor = second.getBackground();
if (bgColor == null)
bgColor = first.getBackground();
Font font = second.getFont();
if (font == null)
font = first.getFont();
return new TextAttribute(fgColor, bgColor, style, font);
}
示例2: getRanges
import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
public List<StyleRange> getRanges(String expression) {
final List<StyleRange> ranges = Lists.newArrayList();
DocumentEvent event = new DocumentEvent();
event.fDocument = new DummyDocument(expression);
DocumentTokenSource tokenSource = tokenSourceProvider.get();
tokenSource.updateStructure(event);
Iterator<ILexerTokenRegion> iterator = tokenSource.getTokenInfos().iterator();
while (iterator.hasNext()) {
ILexerTokenRegion next = iterator.next();
TextAttribute attribute = attributeProvider.getAttribute(tokenTypeMapper.getId(next.getLexerTokenType()));
StyleRange range = new StyleRange(next.getOffset(), next.getLength(), attribute.getForeground(),
attribute.getBackground());
range.font = attribute.getFont();
range.fontStyle = attribute.getStyle();
ranges.add(range);
}
return ranges;
}
示例3: createStyleRange
import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
/**
* @return Returns a corresponding style range.
*/
public StyleRange createStyleRange() {
int len = getLength();
TextAttribute textAttribute = attribute;
int style = textAttribute.getStyle();
int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
StyleRange styleRange = new StyleRange(getOffset(), len, textAttribute.getForeground(),
textAttribute.getBackground(), fontStyle);
styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
styleRange.font = textAttribute.getFont();
return styleRange;
}
示例4: addRange
import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
/**
* Adds style information to the given text presentation.
*
* @param presentation
* the text presentation to be extended
* @param offset
* the offset of the range to be styled
* @param length
* the length of the range to be styled
* @param attr
* the attribute describing the style of the range to be styled
* @param lastLineStyleRanges
*/
protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
if (attr != null) {
int style = attr.getStyle();
int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
StyleRange styleRange = new StyleRange(offset, length, attr.getForeground(), attr.getBackground(),
fontStyle);
styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
styleRange.font = attr.getFont();
presentation.addStyleRange(styleRange);
}
}
示例5: createStyleRange
import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
/**
* Creates a {@link StyleRange} from the given parameters.
*
* @param offset
* the offset
* @param length
* the length of the range
* @param textAttribute
* the {@link TextAttribute}
* @return a {@link StyleRange} from the given parameters
*/
public static StyleRange createStyleRange(final int offset, final int length, final TextAttribute textAttribute) {
int style = textAttribute.getStyle();
int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
StyleRange styleRange = new StyleRange(offset, length, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle);
styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
styleRange.font = textAttribute.getFont();
return styleRange;
}