當前位置: 首頁>>代碼示例>>Java>>正文


Java TextAttribute.getStyle方法代碼示例

本文整理匯總了Java中org.eclipse.jface.text.TextAttribute.getStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java TextAttribute.getStyle方法的具體用法?Java TextAttribute.getStyle怎麽用?Java TextAttribute.getStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.text.TextAttribute的用法示例。


在下文中一共展示了TextAttribute.getStyle方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: adaptToStyleChange

import org.eclipse.jface.text.TextAttribute; //導入方法依賴的package包/類
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
	boolean eventValue = false;
	Object value = event.getNewValue();
	if (value instanceof Boolean)
		eventValue = ((Boolean) value).booleanValue();
	else if (IPreferenceStore.TRUE.equals(value)) eventValue = true;

	Object data = token.getData();
	if (data instanceof TextAttribute) {
		TextAttribute oldAttr = (TextAttribute) data;
		boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;
		if (activeValue != eventValue)
			token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(),
					eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
	}
}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:17,代碼來源:AbstractBufferedRuleBasedScanner.java

示例2: 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);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:18,代碼來源:TextAttributeProvider.java

示例3: 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;
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:19,代碼來源:StyleRanges.java

示例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 wholeLine the boolean switch to declare that the whole line should be colored
 */
private void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr, boolean wholeLine) {
    if (attr != null) {
        int style= attr.getStyle();
        int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
        if(wholeLine) {
            try {
                int line = document.getLineOfOffset(offset);
                int start = document.getLineOffset(line);
                length = document.getLineLength(line);
                offset = start;
            } catch (BadLocationException e) {
            }
        }
        StyleRange styleRange = new StyleRange(offset,length,attr.getForeground(),attr.getBackground(),fontStyle);
        styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
        styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
        presentation.addStyleRange(styleRange);
    }
}
 
開發者ID:anb0s,項目名稱:LogViewer,代碼行數:29,代碼來源:DamageRepairer.java

示例5: applyTheme

import org.eclipse.jface.text.TextAttribute; //導入方法依賴的package包/類
/**
 * applyTheme
 * 
 * @param name
 * @param stream
 * @param defaultColor
 * @return
 */
private void applyTheme(String name, IOConsoleOutputStream stream, Color defaultColor)
{
	Theme theme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();
	Color color = defaultColor;
	int style = SWT.NONE;

	// grab theme values, if they exist
	if (theme.hasEntry(name))
	{
		TextAttribute attr = theme.getTextAttribute(name);

		color = theme.getForeground(name);
		style = attr.getStyle();
	}

	// apply new values
	stream.setColor(color);
	stream.setFontStyle(style);
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:28,代碼來源:ConsoleThemer.java

示例6: createStyleRange

import org.eclipse.jface.text.TextAttribute; //導入方法依賴的package包/類
private StyleRange createStyleRange(TextAttribute attr, Position position) {
	StyleRange result = new StyleRange(position.getOffset(), position.getLength(), attr.getForeground(),
			attr.getBackground(), attr.getStyle());
	if ((attr.getStyle() & TextAttribute.UNDERLINE) != 0) {
		result.underline = true;
		result.fontStyle &= ~TextAttribute.UNDERLINE;
	}
	if ((attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0) {
		result.strikeout = true;
		result.fontStyle &= ~TextAttribute.STRIKETHROUGH;
	}
	return result;
}
 
開發者ID:angelozerr,項目名稱:angular-eclipse,代碼行數:14,代碼來源:HTMLAngularEditorSyntaxColoringPreferencePage.java

示例7: 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;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:18,代碼來源:AttributedPosition.java

示例8: applyStyles

import org.eclipse.jface.text.TextAttribute; //導入方法依賴的package包/類
/**
 * Color the text in the sample area according to the current preferences
 */
void applyStyles() {
	if (fText == null || fText.isDisposed())
		return;
	IStructuredDocumentRegion documentRegion = fDocument
			.getFirstStructuredDocumentRegion();
	while (documentRegion != null) {
		ITextRegionList regions = documentRegion.getRegions();
		for (int i = 0; i < regions.size(); i++) {
			ITextRegion currentRegion = regions.get(i);
			// lookup the local coloring type and apply it
			String namedStyle = (String) fContextToStyleMap
					.get(currentRegion.getType());
			if (namedStyle == null)
				continue;
			TextAttribute attribute = getAttributeFor(namedStyle);
			if (attribute == null)
				continue;
			StyleRange style = new StyleRange(
					documentRegion.getStartOffset(currentRegion),
					currentRegion.getTextLength(),
					attribute.getForeground(), attribute.getBackground(),
					attribute.getStyle());
			style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
			style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0;
			fText.setStyleRange(style);
		}
		documentRegion = documentRegion.getNext();
	}
}
 
開發者ID:angelozerr,項目名稱:eclipse-wtp-json,代碼行數:33,代碼來源:JSONSyntaxColoringPage.java

示例9: setWSTToken

import org.eclipse.jface.text.TextAttribute; //導入方法依賴的package包/類
protected void setWSTToken(IEclipsePreferences prefs, Theme theme, String ourEquivalentScope, String prefKey,
		boolean revertToDefaults)
{
	if (revertToDefaults)
	{
		prefs.remove(prefKey);
	}
	else
	{
		TextAttribute attr = theme.getTextAttribute(ourEquivalentScope);
		boolean bold = (attr.getStyle() & SWT.BOLD) != 0;
		boolean italic = (attr.getStyle() & SWT.ITALIC) != 0;
		boolean strikethrough = (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
		boolean underline = (attr.getStyle() & TextAttribute.UNDERLINE) != 0;
		StringBuilder value = new StringBuilder();
		value.append(Theme.toHex(attr.getForeground().getRGB()));
		value.append('|');
		value.append(Theme.toHex(attr.getBackground().getRGB()));
		value.append('|');
		value.append(bold);
		value.append('|');
		value.append(italic);
		value.append('|');
		value.append(strikethrough);
		value.append('|');
		value.append(underline);
		prefs.put(prefKey, value.toString());
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:30,代碼來源:InvasiveThemeHijacker.java

示例10: matchesDefaults

import org.eclipse.jface.text.TextAttribute; //導入方法依賴的package包/類
private boolean matchesDefaults(TextAttribute attr)
{
	if (attr == null)
	{
		return false;
	}

	// Make sure font is just normal
	int style = attr.getStyle();
	int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
	if (fontStyle != SWT.NORMAL)
	{
		return false;
	}
	if ((style & TextAttribute.STRIKETHROUGH) != 0)
	{
		return false;
	}
	if ((style & TextAttribute.UNDERLINE) != 0)
	{
		return false;
	}

	// Is FG different?
	Color fg = attr.getForeground();
	if (fg != null && !fg.getRGB().equals(getCurrentTheme().getForeground()))
	{
		return false;
	}

	// Is BG different?
	Color bg = attr.getBackground();
	if (bg != null && !bg.getRGB().equals(getCurrentTheme().getBackground()))
	{
		return false;
	}
	return true;
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:39,代碼來源:ThemeingDamagerRepairer.java

示例11: applyStyles

import org.eclipse.jface.text.TextAttribute; //導入方法依賴的package包/類
/**
 * Color the text in the sample area according to the current preferences
 */
void applyStyles() {
	if (fText == null || fText.isDisposed())
		return;
	IStructuredModel model = null;
	try {
		model = getDomModel();
		IStructuredDocumentRegion documentRegion = model.getStructuredDocument().getFirstStructuredDocumentRegion();
		while (documentRegion != null) {
			ITextRegionList regions = documentRegion.getRegions();
			for (int i = 0; i < regions.size(); i++) {
				ITextRegion currentRegion = regions.get(i);
				// lookup the local coloring type and apply it
				String namedStyle = (String) fContextToStyleMap.get(currentRegion.getType());
				if (namedStyle == null)
					continue;
				TextAttribute attribute = getAttributeFor(namedStyle);
				if (attribute == null)
					continue;

				StyleRange style = new StyleRange(documentRegion.getStartOffset(currentRegion),
						currentRegion.getTextLength(), attribute.getForeground(), attribute.getBackground(),
						attribute.getStyle());
				style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
				style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0;
				fText.setStyleRange(style);

				Position[] positions = null;
				for (AbstractAngularSemanticHighlighting highlighting : SemanticHighlightingManager.getInstance()
						.getHighlightings()) {
					positions = highlighting.consumes(documentRegion,
							model.getIndexedRegion(documentRegion.getStartOffset()));
					if (positions != null) {
						for (int j = 0; j < positions.length; j++) {
							Position position = positions[j];
							StyleRange styleRange = createStyleRange(
									getAttributeFor(highlighting.getStyleStringKey()), position);
							fText.setStyleRange(styleRange);
						}
					}
				}

			}
			documentRegion = documentRegion.getNext();
		}
	} catch (IOException e) {
		e.printStackTrace();
	} finally {
		if (model != null) {
			model.releaseFromRead();
		}
	}
}
 
開發者ID:angelozerr,項目名稱:angular-eclipse,代碼行數:56,代碼來源:HTMLAngularEditorSyntaxColoringPreferencePage.java

示例12: 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);
	}
}
 
開發者ID:eclipse,項目名稱:tm4e,代碼行數:26,代碼來源:TMPresentationReconciler.java

示例13: 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;
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:21,代碼來源:AbstractSyntaxColoringTest.java


注:本文中的org.eclipse.jface.text.TextAttribute.getStyle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。