本文整理匯總了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;
}