Java Code Examples for com.intellij.openapi.editor.markup.TextAttributes#getBackgroundColor()
The following examples show how to use
com.intellij.openapi.editor.markup.TextAttributes#getBackgroundColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoverageLineMarkerRenderer.java From consulo with Apache License 2.0 | 6 votes |
public void paint(Editor editor, Graphics g, Rectangle r) { final TextAttributes color = editor.getColorsScheme().getAttributes(myKey); Color bgColor = color.getBackgroundColor(); if (bgColor == null) { bgColor = color.getForegroundColor(); } if (editor.getSettings().isLineNumbersShown() || ((EditorGutterComponentEx)editor.getGutter()).isAnnotationsShown()) { if (bgColor != null) { bgColor = ColorUtil.toAlpha(bgColor, 150); } } if (bgColor != null) { g.setColor(bgColor); } g.fillRect(r.x, r.y, r.width, r.height); final LineData lineData = getLineData(editor.xyToLogicalPosition(new Point(0, r.y)).line); if (lineData != null && lineData.isCoveredByOneTest()) { AllIcons.Gutter.Unique.paintIcon(editor.getComponent(), g, r.x, r.y); } }
Example 2
Source File: FlutterLogView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void computeTextAttributesByLogLevelCache() { final EditorColorsScheme globalEditorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); textAttributesByLogLevelCache.clear(); for (Level level : FlutterLog.Level.values()) { try { final TextAttributesKey key = LOG_LEVEL_TEXT_ATTRIBUTES_KEY_MAP.get(level); final TextAttributes attributes = globalEditorColorsScheme.getAttributes(key); int fontType = attributes.getFontType(); final Color effectColor = attributes.getEffectColor(); final Integer textStyle = EFFECT_TYPE_TEXT_STYLE_MAP.get(attributes.getEffectType()); // TextStyle can exist even when unchecked in settings page. // only effectColor is null when setting effect is unchecked in setting page. // So, we have to check that both effectColor & textStyle are not null. if (effectColor != null && textStyle != null) { fontType = fontType | textStyle; } final SimpleTextAttributes textAttributes = new SimpleTextAttributes( attributes.getBackgroundColor(), attributes.getForegroundColor(), effectColor, fontType ); textAttributesByLogLevelCache.put(level, textAttributes); } catch (Exception e) { // Should never go here. FlutterUtils.warn(LOG, "Error when get text attributes by log level", e); } } }
Example 3
Source File: SyntaxInfoBuilder.java From consulo with Apache License 2.0 | 5 votes |
private void findNextSuitableRange() { myNextAttributes = null; while (myIterator.hasNext()) { RangeHighlighterEx highlighter = myIterator.next(); if (highlighter == null || !highlighter.isValid() || !isInterestedInLayer(highlighter.getLayer())) { continue; } // LINES_IN_RANGE highlighters are not supported currently myNextStart = Math.max(highlighter.getStartOffset(), myStartOffset); myNextEnd = Math.min(highlighter.getEndOffset(), myEndOffset); if (myNextStart >= myEndOffset) { break; } if (myNextStart < myCurrentEnd) { continue; // overlapping ranges withing document markup model are not supported currently } TextAttributes attributes = null; HighlightInfo info = HighlightInfo.fromRangeHighlighter(highlighter); if (info != null) { TextAttributesKey key = info.forcedTextAttributesKey; if (key == null) { HighlightInfoType type = info.type; key = type.getAttributesKey(); } if (key != null) { attributes = myColorsScheme.getAttributes(key); } } if (attributes == null) { continue; } Color foreground = attributes.getForegroundColor(); Color background = attributes.getBackgroundColor(); if ((foreground == null || myDefaultForeground.equals(foreground)) && (background == null || myDefaultBackground.equals(background)) && attributes.getFontType() == Font.PLAIN) { continue; } myNextAttributes = attributes; break; } }
Example 4
Source File: SyntaxInfoBuilder.java From consulo with Apache License 2.0 | 5 votes |
public void advance() { if (mySegmentIterator.atEnd()) { myRangeIterator.advance(); TextAttributes textAttributes = myRangeIterator.getTextAttributes(); myCurrentFontStyle = textAttributes == null ? Font.PLAIN : textAttributes.getFontType(); myCurrentForegroundColor = textAttributes == null ? null : textAttributes.getForegroundColor(); myCurrentBackgroundColor = textAttributes == null ? null : textAttributes.getBackgroundColor(); mySegmentIterator.reset(myRangeIterator.getRangeStart(), myRangeIterator.getRangeEnd(), myCurrentFontStyle); } mySegmentIterator.advance(); }
Example 5
Source File: DiffOptionsPanel.java From consulo with Apache License 2.0 | 5 votes |
public MyColorAndFontDescription(@Nonnull TextDiffType diffType, @Nonnull EditorColorsScheme scheme) { myScheme = scheme; myDiffType = diffType; TextAttributes attrs = diffType.getTextAttributes(myScheme); myBackgroundColor = attrs.getBackgroundColor(); myStripebarColor = attrs.getErrorStripeColor(); myOriginalBackground = myBackgroundColor; myOriginalStripebar = myStripebarColor; }
Example 6
Source File: ArrangementAtomMatchConditionComponent.java From consulo with Apache License 2.0 | 5 votes |
/** * Instructs current component that it should {@link #getUiComponent() draw} itself according to the given 'selected' state. * * @param selected flag that indicates if current component should be drawn as 'selected' */ @Override public void setSelected(boolean selected) { boolean notifyListener = selected != mySelected; mySelected = selected; TextAttributes attributes = updateComponentText(selected); myBorder.setColor(myColorsProvider.getBorderColor(selected)); myBackgroundColor = attributes.getBackgroundColor(); if (notifyListener && myListener != null) { myListener.stateChanged(); } }
Example 7
Source File: ParameterHintsPresentationManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paint(@Nonnull Editor editor, @Nonnull Graphics g, @Nonnull Rectangle r, @Nonnull TextAttributes textAttributes) { if (myText != null && (step > steps || startWidth != 0)) { TextAttributes attributes = editor.getColorsScheme().getAttributes(DefaultLanguageHighlighterColors.INLINE_PARAMETER_HINT); if (attributes != null) { MyFontMetrics fontMetrics = getFontMetrics(editor); Color backgroundColor = attributes.getBackgroundColor(); if (backgroundColor != null) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); GraphicsUtil.paintWithAlpha(g, BACKGROUND_ALPHA); g.setColor(backgroundColor); int gap = r.height < (fontMetrics.lineHeight + 2) ? 1 : 2; g.fillRoundRect(r.x + 2, r.y + gap, r.width - 4, r.height - gap * 2, 8, 8); config.restore(); } Color foregroundColor = attributes.getForegroundColor(); if (foregroundColor != null) { g.setColor(foregroundColor); g.setFont(getFont(editor)); Shape savedClip = g.getClip(); g.clipRect(r.x + 3, r.y + 2, r.width - 6, r.height - 4); int editorAscent = editor.getAscent(); FontMetrics metrics = fontMetrics.metrics; g.drawString(myText, r.x + 7, r.y + Math.max(editorAscent, (r.height + metrics.getAscent() - metrics.getDescent()) / 2) - 1); g.setClip(savedClip); } } } }
Example 8
Source File: BreakpointItem.java From consulo with Apache License 2.0 | 5 votes |
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(); 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); } } } }
Example 9
Source File: LineExtensionInfo.java From consulo with Apache License 2.0 | 5 votes |
public LineExtensionInfo(@Nonnull String text, @Nonnull TextAttributes attr) { myText = text; myColor = attr.getForegroundColor(); myEffectType = attr.getEffectType(); myEffectColor = attr.getEffectColor(); myFontType = attr.getFontType(); myBgColor = attr.getBackgroundColor(); }
Example 10
Source File: TextDiffType.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private Color getBgColorForFragmentContainingInlines(@Nonnull EditorEx editor) { TextAttributes originalAttrs = getTextAttributes(editor.getColorsScheme()); if (originalAttrs == null) { return null; } Color fg = originalAttrs.getBackgroundColor(); if (fg == null) { return null; } Color bg = editor.getBackgroundColor(); return getMiddleColor(fg, bg, MIDDLE_COLOR_FACTOR); }
Example 11
Source File: TextDiffType.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public Color getPolygonColor(Editor editor) { if (isApplied()) { return getLegendColor(editor.getColorsScheme()); } else if (isInlineWrapper()) { return getBgColorForFragmentContainingInlines((EditorEx)editor); } else { TextAttributes attributes = getTextAttributes(editor); return attributes == null ? null : attributes.getBackgroundColor(); } }
Example 12
Source File: SimpleTextAttributes.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static SimpleTextAttributes fromTextAttributes(TextAttributes attributes) { if (attributes == null) return REGULAR_ATTRIBUTES; Color foregroundColor = attributes.getForegroundColor(); if (foregroundColor == null) foregroundColor = REGULAR_ATTRIBUTES.getFgColor(); int style = attributes.getFontType(); if (attributes.getEffectColor() != null) { EffectType effectType = attributes.getEffectType(); if (effectType == EffectType.STRIKEOUT) { style |= STYLE_STRIKEOUT; } else if (effectType == EffectType.WAVE_UNDERSCORE) { style |= STYLE_WAVED; } else if (effectType == EffectType.LINE_UNDERSCORE || effectType == EffectType.BOLD_LINE_UNDERSCORE || effectType == EffectType.BOLD_DOTTED_LINE) { style |= STYLE_UNDERLINE; } else if (effectType == EffectType.SEARCH_MATCH) { style |= STYLE_SEARCH_MATCH; } else { // not supported } } return new SimpleTextAttributes(attributes.getBackgroundColor(), foregroundColor, attributes.getEffectColor(), style); }
Example 13
Source File: FlutterLogView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void computeTextAttributesByLogLevelCache() { final EditorColorsScheme globalEditorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); textAttributesByLogLevelCache.clear(); for (Level level : FlutterLog.Level.values()) { try { final TextAttributesKey key = LOG_LEVEL_TEXT_ATTRIBUTES_KEY_MAP.get(level); final TextAttributes attributes = globalEditorColorsScheme.getAttributes(key); int fontType = attributes.getFontType(); final Color effectColor = attributes.getEffectColor(); final Integer textStyle = EFFECT_TYPE_TEXT_STYLE_MAP.get(attributes.getEffectType()); // TextStyle can exist even when unchecked in settings page. // only effectColor is null when setting effect is unchecked in setting page. // So, we have to check that both effectColor & textStyle are not null. if (effectColor != null && textStyle != null) { fontType = fontType | textStyle; } final SimpleTextAttributes textAttributes = new SimpleTextAttributes( attributes.getBackgroundColor(), attributes.getForegroundColor(), effectColor, fontType ); textAttributesByLogLevelCache.put(level, textAttributes); } catch (Exception e) { // Should never go here. FlutterUtils.warn(LOG, "Error when get text attributes by log level", e); } } }
Example 14
Source File: TextDiffType.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public Color getTextBackground(Editor editor) { TextAttributes attributes = getTextAttributes(editor); return attributes != null ? attributes.getBackgroundColor() : null; }
Example 15
Source File: TextDiffType.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public Color getLegendColor(EditorColorsScheme colorScheme) { TextAttributes attributes = colorScheme.getAttributes(myAttributesKey); return attributes != null ? attributes.getBackgroundColor() : null; }
Example 16
Source File: Breadcrumbs.java From consulo with Apache License 2.0 | 4 votes |
protected Color getBackground(Crumb crumb) { TextAttributes attributes = getAttributes(crumb); return attributes == null ? null : attributes.getBackgroundColor(); }
Example 17
Source File: MultiLineCellRenderer.java From intellij-csv-validator with Apache License 2.0 | 4 votes |
private Color getColumnBackgroundColor(int column, Color fallback) { TextAttributes textAttributes = getColumnTextAttributes(column); return textAttributes == null || textAttributes.getBackgroundColor() == null ? fallback : textAttributes.getBackgroundColor(); }