本文整理汇总了Java中com.intellij.openapi.editor.markup.TextAttributes.setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java TextAttributes.setBackgroundColor方法的具体用法?Java TextAttributes.setBackgroundColor怎么用?Java TextAttributes.setBackgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.markup.TextAttributes
的用法示例。
在下文中一共展示了TextAttributes.setBackgroundColor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTextAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Nullable
@Override
public TextAttributes getTextAttributes(@NotNull EditorColorsScheme scheme, @NotNull ArrangementSettingsToken token, boolean selected) {
if (selected) {
TextAttributes attributes = new TextAttributes();
attributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
attributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
return attributes;
}
else if (SUPPORTED_TYPES.contains(token)) {
return getAttributes(scheme, JavaHighlightingColors.KEYWORD);
}
else if (SUPPORTED_MODIFIERS.contains(token)) {
getAttributes(scheme, JavaHighlightingColors.KEYWORD);
}
return null;
}
示例2: itemHovered
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Override
public void itemHovered(@Nullable BreadcrumbsPsiItem item) {
if (!Registry.is("editor.breadcrumbs.highlight.on.hover")) {
return;
}
HighlightManager hm = HighlightManager.getInstance(myProject);
if (myHighlighed != null) {
for (RangeHighlighter highlighter : myHighlighed) {
hm.removeSegmentHighlighter(myEditor, highlighter);
}
myHighlighed = null;
}
if (item != null) {
final TextRange range = item.getPsiElement().getTextRange();
final TextAttributes attributes = new TextAttributes();
final CrumbPresentation p = item.getPresentation();
final Color color = p != null ? p.getBackgroundColor(false, false, false) : BreadcrumbsComponent.ButtonSettings.DEFAULT_BG_COLOR;
final Color background = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.CARET_ROW_COLOR);
attributes.setBackgroundColor(XmlTagTreeHighlightingUtil.makeTransparent(color, background != null ? background : Gray._200, 0.3));
myHighlighed = new ArrayList<RangeHighlighter>(1);
int flags = HighlightManager.HIDE_BY_ESCAPE | HighlightManager.HIDE_BY_TEXT_CHANGE | HighlightManager.HIDE_BY_ANY_KEY;
hm.addOccurrenceHighlight(myEditor, range.getStartOffset(), range.getEndOffset(), attributes, flags, myHighlighed, null);
}
}
示例3: addLinesHighlighter
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
private static void addLinesHighlighter(Project project, ArrayList<Integer> lines) {
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
//editor.getMarkupModel().removeAllHighlighters();
final TextAttributes attr = new TextAttributes();
attr.setBackgroundColor(JBColor.LIGHT_GRAY);
// attr.setForegroundColor(JBColor.BLACK);
// TODO: Check if line is illegal
for (int line : lines){
log.info("line:" + line);
if (line >= 1) {
editor.getMarkupModel().addLineHighlighter(line - 1, flag++, attr);
}
}
}
示例4: removeHightlight
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
private static void removeHightlight(Project project, VirtualFile file, ArrayList<Integer> linesArrayList) {
FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(file);
Editor editor= fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null;
editor.getMarkupModel().getDocument();
final TextAttributes attr = new TextAttributes();
attr.setBackgroundColor(JBColor.WHITE);
// attr.setForegroundColor(JBColor.BLACK);
for (int line : linesArrayList){
log.info("remove line:" + line);
editor.getMarkupModel().addLineHighlighter(line - 1, flag++, attr);
}
}
示例5: getAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Nullable
private static TextAttributes getAttributes(@NotNull EditorColorsScheme scheme, @NotNull TextAttributesKey ... keys) {
TextAttributes result = null;
for (TextAttributesKey key : keys) {
TextAttributes attributes = scheme.getAttributes(key);
if (attributes == null) {
continue;
}
if (result == null) {
result = attributes;
}
Color currentForegroundColor = result.getForegroundColor();
if (currentForegroundColor == null) {
result.setForegroundColor(attributes.getForegroundColor());
}
Color currentBackgroundColor = result.getBackgroundColor();
if (currentBackgroundColor == null) {
result.setBackgroundColor(attributes.getBackgroundColor());
}
if (result.getForegroundColor() != null && result.getBackgroundColor() != null) {
return result;
}
}
if (result != null && result.getForegroundColor() == null) {
return null;
}
if (result != null && result.getBackgroundColor() == null) {
result.setBackgroundColor(scheme.getDefaultBackground());
}
return result;
}
示例6: getTextAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Nullable
public TextAttributes getTextAttributes(@NotNull Editor editor) {
TextAttributes originalAttrs = getTextAttributes(editor.getColorsScheme());
if (originalAttrs == null) {
return null;
}
TextAttributes overridingAttributes = new TextAttributes();
if (myApplied) {
overridingAttributes.setBackgroundColor(((EditorEx)editor).getBackgroundColor());
}
else if (myInlineWrapper) {
overridingAttributes.setBackgroundColor(getBgColorForFragmentContainingInlines((EditorEx)editor));
}
return TextAttributes.merge(originalAttrs, overridingAttributes);
}
示例7: getTextAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Override
public TextAttributes getTextAttributes() {
if (myTextAttributes == null) {
TextAttributes textAttributes = new TextAttributes();
EditorColorsScheme scheme = myEditor.getColorsScheme();
textAttributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
textAttributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
myTextAttributes = textAttributes;
}
return myTextAttributes;
}
示例8: showInEditor
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
TextAttributes attributes =
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);
if (state.equals(panel.getEditorState())) {
return;
}
panel.navigateInPreviewEditor(state);
TextAttributes softerAttributes = attributes.clone();
Color backgroundColor = softerAttributes.getBackgroundColor();
if (backgroundColor != null) {
softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor));
}
final Editor editor = panel.getEditor();
if (editor != null) {
final MarkupModel editorModel = editor.getMarkupModel();
final MarkupModel documentModel =
DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
if (line1 != line) {
editorModel.addLineHighlighter(line1,
DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
}
}
}
}
}
示例9: setInheritedAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
private void setInheritedAttributes(@NotNull TextAttributes attributes) {
attributes.setFontType(myFallbackAttributes.getFontType());
attributes.setForegroundColor(myFallbackAttributes.getForegroundColor());
attributes.setBackgroundColor(myFallbackAttributes.getBackgroundColor());
attributes.setErrorStripeColor(myFallbackAttributes.getErrorStripeColor());
attributes.setEffectColor(myFallbackAttributes.getEffectColor());
attributes.setEffectType(myFallbackAttributes.getEffectType());
}
示例10: appendHighlightName
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
private void appendHighlightName(String substringToHighlight, String name) {
final int begin = name.indexOf(substringToHighlight);
// if (name.length() <= begin) return;
final String first = name.substring(0, begin);
append(first, SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
final TextAttributes textAttributes = new TextAttributes();
textAttributes.setBackgroundColor(UIUtil.getListSelectionBackground());
append(substringToHighlight, SimpleTextAttributes.fromTextAttributes(textAttributes));
append(name.substring(first.length() + substringToHighlight.length()), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
}
示例11: getAttributeWrapper
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
private AttributeWrapper getAttributeWrapper(RadComponent component) {
AttributeWrapper wrapper = AttributeWrapper.DEFAULT;
final HighlightDisplayLevel level = getHighlightDisplayLevel(myDesigner.getProject(), component);
if (level != null) {
TextAttributesKey attributesKey =
SeverityRegistrar.getSeverityRegistrar(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity())
.getAttributesKey();
final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
wrapper = new AttributeWrapper() {
@Override
public SimpleTextAttributes getAttribute(SimpleTextAttributes attributes) {
Color bgColor = textAttributes.getBackgroundColor();
try {
textAttributes.setBackgroundColor(null);
return SimpleTextAttributes.fromTextAttributes(TextAttributes.merge(attributes.toTextAttributes(), textAttributes));
}
finally {
textAttributes.setBackgroundColor(bgColor);
}
}
};
}
return wrapper;
}
示例12: apply
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Override
public void apply(@NotNull TextAttributes ta) {
int fontType = Font.PLAIN;
if (myCbBold.isSelected()) {
fontType |= Font.BOLD;
}
if (myCbItalic.isSelected()) {
fontType |= Font.ITALIC;
}
ta.setFontType(fontType);
if (myCbForeground.isSelected()) {
ta.setForegroundColor(myForegroundChooser.getSelectedColor());
} else {
ta.setForegroundColor(null);
}
if (myCbBackground.isSelected()) {
ta.setBackgroundColor(myBackgroundChooser.getSelectedColor());
} else {
ta.setBackgroundColor(null);
}
if (myCbErrorStripe.isSelected()) {
ta.setErrorStripeColor(myErrorStripeColorChooser.getSelectedColor());
} else {
ta.setErrorStripeColor(null);
}
if (myCbEffects.isSelected()) {
Color effectColor = myEffectsColorChooser.getSelectedColor();
ta.setEffectColor(effectColor);
//noinspection SuspiciousMethodCalls
if (effectColor == null) {
ta.setEffectType(null);
} else {
//noinspection SuspiciousMethodCalls
ta.setEffectType(myEffectsMap.get(myEffectsCombo.getModel().getSelectedItem()));
}
} else {
ta.setEffectColor(null);
ta.setEffectType(null);
}
}
示例13: getOutputKey
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@NotNull
public Key getOutputKey(@NonNls String attribute) {
final String completeAttribute = attribute;
if (attribute.startsWith("\u001B[")) {
attribute = attribute.substring(2);
}
else if (attribute.startsWith("[")) {
attribute = attribute.substring(1);
}
if (attribute.endsWith("m")) {
attribute = attribute.substring(0, attribute.length() - 1);
}
if (attribute.equals("0")) {
return ProcessOutputTypes.STDOUT;
}
TextAttributes attrs = new TextAttributes();
final String[] strings = attribute.split(";");
for (String string : strings) {
int value;
try {
value = Integer.parseInt(string);
}
catch (NumberFormatException e) {
continue;
}
if (value == 1) {
attrs.setFontType(Font.BOLD);
}
else if (value == 4) {
attrs.setEffectType(EffectType.LINE_UNDERSCORE);
}
else if (value == 22) {
attrs.setFontType(Font.PLAIN);
}
else if (value == 24) { //not underlined
attrs.setEffectType(null);
}
else if (value >= 30 && value <= 37) {
attrs.setForegroundColor(getAnsiColor(value - 30));
}
else if (value == 38) {
//TODO: 256 colors foreground
}
else if (value == 39) {
attrs.setForegroundColor(getColorByKey(ConsoleViewContentType.NORMAL_OUTPUT_KEY));
}
else if (value >= 40 && value <= 47) {
attrs.setBackgroundColor(getAnsiColor(value - 40));
}
else if (value == 48) {
//TODO: 256 colors background
}
else if (value == 49) {
attrs.setBackgroundColor(getColorByKey(ConsoleViewContentType.NORMAL_OUTPUT_KEY));
}
else if (value >= 90 && value <= 97) {
attrs.setForegroundColor(
getAnsiColor(value - 82));
}
else if (value >= 100 && value <= 107) {
attrs.setBackgroundColor(
getAnsiColor(value - 92));
}
}
if (attrs.getEffectType() == EffectType.LINE_UNDERSCORE) {
attrs.setEffectColor(attrs.getForegroundColor());
}
Key newKey = new Key(completeAttribute);
ConsoleViewContentType contentType = new ConsoleViewContentType(completeAttribute, attrs);
ConsoleViewContentType.registerNewConsoleViewType(newKey, contentType);
return newKey;
}
示例14: run
import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Override
public void run() {
checkInstallation();
cleanUpIdePreferences();
if (!Boolean.getBoolean(USE_IDEA_NEW_PROJECT_WIZARDS)) {
replaceIdeaNewProjectActions();
}
if (!Boolean.getBoolean(USE_IDEA_PROJECT_STRUCTURE)) {
replaceProjectStructureActions();
}
if (!Boolean.getBoolean(USE_JPS_MAKE_ACTIONS)) {
replaceIdeaMakeActions();
}
if (!Boolean.getBoolean(USE_IDEA_NEW_FILE_POPUPS)) {
hideIdeaNewFilePopupActions();
}
try {
// Setup JDK and Android SDK if necessary
setupSdks();
} catch (Exception e) {
LOG.error("Unexpected error while setting up SDKs: ", e);
}
addExtraBuildActions();
hideMiscActions();
registerAppClosing();
// Always reset the Default scheme to match Android standards
// User modifications won't be lost since they are made in a separate scheme (copied off of this default scheme)
CodeStyleScheme scheme = CodeStyleSchemes.getInstance().getDefaultScheme();
if (scheme != null) {
CodeStyleSettings settings = scheme.getCodeStyleSettings();
if (settings != null) {
AndroidCodeStyleSettingsModifier.modify(settings);
}
}
// Modify built-in "Default" color scheme to remove background from XML tags.
// "Darcula" and user schemes will not be touched.
EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
TextAttributes textAttributes = colorsScheme.getAttributes(HighlighterColors.TEXT);
TextAttributes xmlTagAttributes = colorsScheme.getAttributes(XmlHighlighterColors.XML_TAG);
xmlTagAttributes.setBackgroundColor(textAttributes.getBackgroundColor());
checkAndSetAndroidSdkSources();
}