当前位置: 首页>>代码示例>>Java>>正文


Java TextAttribute.getBackground方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.TextAttribute.getBackground方法的典型用法代码示例。如果您正苦于以下问题:Java TextAttribute.getBackground方法的具体用法?Java TextAttribute.getBackground怎么用?Java TextAttribute.getBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.TextAttribute的用法示例。


在下文中一共展示了TextAttribute.getBackground方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:TextAttributeProvider.java

示例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;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:StyleRanges.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: getBackground

import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
public Color getBackground(String scope)
{
	TextAttribute attr = getTextAttribute(scope);
	if (attr == null)
	{
		return null;
	}
	return attr.getBackground();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:10,代码来源:Theme.java

示例8: 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

示例9: activate

import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
private void activate(String namedStyle) {
	Color foreground = fDefaultForeground;
	Color background = fDefaultBackground;
	if (namedStyle == null) {
		fClearStyle.setEnabled(false);
		fBold.setEnabled(false);
		fItalic.setEnabled(false);
		fStrike.setEnabled(false);
		fUnderline.setEnabled(false);
		fForegroundLabel.setEnabled(false);
		fBackgroundLabel.setEnabled(false);
		fForegroundColorEditor.setEnabled(false);
		fBackgroundColorEditor.setEnabled(false);
		fBold.setSelection(false);
		fItalic.setSelection(false);
		fStrike.setSelection(false);
		fUnderline.setSelection(false);
	} else {
		TextAttribute attribute = getAttributeFor(namedStyle);
		fClearStyle.setEnabled(true);
		fBold.setEnabled(true);
		fItalic.setEnabled(true);
		fStrike.setEnabled(true);
		fUnderline.setEnabled(true);
		fForegroundLabel.setEnabled(true);
		fBackgroundLabel.setEnabled(true);
		fForegroundColorEditor.setEnabled(true);
		fBackgroundColorEditor.setEnabled(true);
		fBold.setSelection((attribute.getStyle() & SWT.BOLD) != 0);
		fItalic.setSelection((attribute.getStyle() & SWT.ITALIC) != 0);
		fStrike.setSelection((attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0);
		fUnderline.setSelection((attribute.getStyle() & TextAttribute.UNDERLINE) != 0);
		if (attribute.getForeground() != null) {
			foreground = attribute.getForeground();
		}
		if (attribute.getBackground() != null) {
			background = attribute.getBackground();
		}
	}

	fForegroundColorEditor.setColorValue(foreground.getRGB());
	fBackgroundColorEditor.setColorValue(background.getRGB());
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:44,代码来源:HTMLAngularEditorSyntaxColoringPreferencePage.java

示例10: 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

示例11: activate

import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
private void activate(String namedStyle) {
	Color foreground = fDefaultForeground;
	Color background = fDefaultBackground;
	if (namedStyle == null) {
		fClearStyle.setEnabled(false);
		fBold.setEnabled(false);
		fItalic.setEnabled(false);
		fStrike.setEnabled(false);
		fUnderline.setEnabled(false);
		fForegroundLabel.setEnabled(false);
		fBackgroundLabel.setEnabled(false);
		fForegroundColorEditor.setEnabled(false);
		fBackgroundColorEditor.setEnabled(false);
		fBold.setSelection(false);
		fItalic.setSelection(false);
		fStrike.setSelection(false);
		fUnderline.setSelection(false);
	} else {
		TextAttribute attribute = getAttributeFor(namedStyle);
		fClearStyle.setEnabled(true);
		fBold.setEnabled(true);
		fItalic.setEnabled(true);
		fStrike.setEnabled(true);
		fUnderline.setEnabled(true);
		fForegroundLabel.setEnabled(true);
		fBackgroundLabel.setEnabled(true);
		fForegroundColorEditor.setEnabled(true);
		fBackgroundColorEditor.setEnabled(true);
		fBold.setSelection((attribute.getStyle() & SWT.BOLD) != 0);
		fItalic.setSelection((attribute.getStyle() & SWT.ITALIC) != 0);
		fStrike.setSelection((attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0);
		fUnderline
				.setSelection((attribute.getStyle() & TextAttribute.UNDERLINE) != 0);
		if (attribute.getForeground() != null) {
			foreground = attribute.getForeground();
		}
		if (attribute.getBackground() != null) {
			background = attribute.getBackground();
		}
	}

	fForegroundColorEditor.setColorValue(foreground.getRGB());
	fBackgroundColorEditor.setColorValue(background.getRGB());
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:45,代码来源:JSONSyntaxColoringPage.java

示例12: lineGetBackground

import org.eclipse.jface.text.TextAttribute; //导入方法依赖的package包/类
public void lineGetBackground(LineBackgroundEvent event)
{
	if (fViewer == null)
	{
		return;
	}
	final StyledText textWidget = fViewer.getTextWidget();
	if (textWidget == null)
	{
		return;
	}

	try
	{
		final int offset = event.lineOffset;
		IDocument document = fViewer.getDocument();
		int line = document.getLineOfOffset(offset);
		final IRegion lineRegion = document.getLineInformation(line);

		// Handle fully opaque line highlight here. A modified approach from CursorLinePainter.
		if (fEnabled && isOpaque() && isCurrentLine(line))
		{
			// draw current line
			drawCurrentLine(event, lineRegion);
			return;
		}

		// Not drawing an opaque line highlight, so we need to do our normal line coloring here.
		// This extends the bg color out for a given line based on it's end scope.
		String endOfLineScope = getScopeManager().getScopeAtOffset(document, lineRegion.getLength() + offset);
		String commonPrefix = getScope(document, line, endOfLineScope);
		TextAttribute at = getCurrentTheme().getTextAttribute(commonPrefix);

		// if we have no color we need to extend to end of line, but this used to be the highlight line, force the
		// theme bg color
		if (at.getBackground() == null && isOpaque() && fLastLine.includes(offset))
		{
			event.lineBackground = getColorManager().getColor(getCurrentTheme().getBackground());
		}
		else
		{
			event.lineBackground = at.getBackground();
		}
	}
	catch (BadLocationException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:50,代码来源:LineBackgroundPainter.java

示例13: 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

示例14: 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.getBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。