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


Java TextAttributes.getBackgroundColor方法代碼示例

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


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

示例1: paint

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
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()) {
    g.drawImage( ImageLoader.loadFromResource("/gutter/unique.png"), r.x, r.y, 8, 8, editor.getComponent());
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:CoverageLineMarkerRenderer.java

示例2: 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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:38,代碼來源:JavaRearranger.java

示例3: fromTextAttributes

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@NotNull
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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:SimpleTextAttributes.java

示例4: getPolygonColor

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@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();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:TextDiffType.java

示例5: getBgColorForFragmentContainingInlines

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Nullable
private Color getBgColorForFragmentContainingInlines(@NotNull 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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:TextDiffType.java

示例6: compare

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
public int compare(RangeHighlighterEx o1, RangeHighlighterEx o2) {
  final int result = LayerComparator.INSTANCE.compare(o1, o2);
  if (result != 0) {
    return result;
  }

  // There is a possible case when more than one highlighter target the same region (e.g. 'identifier under caret' and 'identifier').
  // We want to prefer the one that defines foreground color to the one that doesn't define (has either fore- or background colors
  // while the other one has only foreground color). See IDEA-85697 for concrete example.
  final TextAttributes a1 = o1.getTextAttributes();
  final TextAttributes a2 = o2.getTextAttributes();
  if (a1 == null ^ a2 == null) {
    return a1 == null ? 1 : -1;
  }

  if (a1 == null) {
    return result;
  }

  final Color fore1 = a1.getForegroundColor();
  final Color fore2 = a2.getForegroundColor();
  if (fore1 == null ^ fore2 == null) {
    return fore1 == null ? 1 : -1;
  }

  final Color back1 = a1.getBackgroundColor();
  final Color back2 = a2.getBackgroundColor();
  if (back1 == null ^ back2 == null) {
    return back1 == null ? 1 : -1;
  }

  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:IterationState.java

示例7: compare

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
public int compare(RangeHighlighterEx o1, RangeHighlighterEx o2) {
  final int result = LayerComparator.INSTANCE.compare(o1, o2);
  if (result != 0) {
    return result;
  }
  
  // There is a possible case when more than one highlighter target the same region (e.g. 'identifier under caret' and 'identifier').
  // We want to prefer the one that defines foreground color to the one that doesn't define (has either fore- or background colors
  // while the other one has only foreground color). See IDEA-85697 for concrete example.
  final TextAttributes a1 = o1.getTextAttributes();
  final TextAttributes a2 = o2.getTextAttributes();
  if (a1 == null ^ a2 == null) {
    return a1 == null ? 1 : -1;
  }

  if (a1 == null) {
    return result;
  }
  
  final Color fore1 = a1.getForegroundColor();
  final Color fore2 = a2.getForegroundColor();
  if (fore1 == null ^ fore2 == null) {
    return fore1 == null ? 1 : -1;
  }

  final Color back1 = a1.getBackgroundColor();
  final Color back2 = a2.getBackgroundColor();
  if (back1 == null ^ back2 == null) {
    return back1 == null ? 1 : -1;
  }

  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:IterationState.java

示例8: getPastFileEndBackground

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Nullable
public Color getPastFileEndBackground() {
  boolean isInCaretRow = myEditor.getCaretModel().getLogicalPosition().line >= myDocument.getLineCount() - 1;

  Color caret = isInCaretRow && myCaretRowAttributes != null ? myCaretRowAttributes.getBackgroundColor() : null;

  ContainerUtil.quickSort(myCurrentHighlighters, LayerComparator.INSTANCE);

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < myCurrentHighlighters.size(); i++) {
    RangeHighlighterEx highlighter = myCurrentHighlighters.get(i);
    if (caret != null && highlighter.getLayer() < HighlighterLayer.CARET_ROW) {
      return caret;
    }

    if (highlighter.getTargetArea() != HighlighterTargetArea.LINES_IN_RANGE
        || myDocument.getLineNumber(highlighter.getEndOffset()) < myDocument.getLineCount() - 1) {
      continue;
    }

    TextAttributes textAttributes = highlighter.getTextAttributes();
    if (textAttributes != null) {
      Color backgroundColor = textAttributes.getBackgroundColor();
      if (backgroundColor != null) return backgroundColor;
    }
  }

  return caret;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:IterationState.java

示例9: 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);
        }
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:36,代碼來源:BreakpointItem.java

示例10: setSelected

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
/**
 * 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();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:ArrangementAtomMatchConditionComponent.java

示例11: MyColorAndFontDescription

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
public MyColorAndFontDescription(@NotNull TextDiffType diffType, @NotNull EditorColorsScheme scheme) {
  myScheme = scheme;
  myDiffType = diffType;
  TextAttributes attrs = diffType.getTextAttributes(myScheme);
  myBackgroundColor = attrs.getBackgroundColor();
  myStripebarColor = attrs.getErrorStripeColor();
  myOriginalBackground = myBackgroundColor;
  myOriginalStripebar = myStripebarColor;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:DiffOptionsPanel.java

示例12: advance

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:TextWithMarkupProcessor.java

示例13: generateDoc

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
public String generateDoc(final PsiElement element, @Nullable final PsiElement originalElement) {
  if (element instanceof IProperty) {
    IProperty property = (IProperty)element;
    String text = property.getDocCommentText();

    @NonNls String info = "";
    if (text != null) {
      TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(PropertiesHighlighter.PROPERTY_COMMENT).clone();
      Color background = attributes.getBackgroundColor();
      if (background != null) {
        info +="<div bgcolor=#"+ GuiUtils.colorToHex(background)+">";
      }
      String doc = StringUtil.join(ContainerUtil.map(StringUtil.split(text, "\n"), new Function<String, String>() {
        @Override
        public String fun(String s) {
          return StringUtil.trimStart(StringUtil.trimStart(s, "#"), "!").trim();
        }
      }), "<br>");
      info += "<font color=#" + GuiUtils.colorToHex(attributes.getForegroundColor()) + ">" + doc + "</font>\n<br>";
      if (background != null) {
        info += "</div>";
      }
    }
    info += "\n<b>" + property.getName() + "</b>=\"" + renderPropertyValue(((IProperty)element)) + "\"";
    info += getLocationString(element);
    return info;
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:PropertiesDocumentationProvider.java

示例14: getScrollmarkColor

import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Nullable
private static Color getScrollmarkColor(TextAttributes textAttributes) {
  if (textAttributes.getErrorStripeColor() != null) {
    return textAttributes.getErrorStripeColor();
  } else if (textAttributes.getBackgroundColor() != null) {
    return textAttributes.getBackgroundColor().darker();
  } else {
    return null;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:VariableInlineHandler.java

示例15: 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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:ComponentTree.java


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