Java Code Examples for com.intellij.openapi.editor.colors.EditorColorsScheme#getColor()

The following examples show how to use com.intellij.openapi.editor.colors.EditorColorsScheme#getColor() . 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: AnnotationsSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
List<Integer> getAnchorIndexes(@Nullable EditorColorsScheme scheme) {
  if (scheme == null) scheme = EditorColorsManager.getInstance().getGlobalScheme();

  List<Integer> result = new ArrayList<>(ANCHORS_COUNT);

  int count = 0;
  for (ColorKey key : ANCHOR_COLOR_KEYS) {
    if (scheme.getColor(key) != null) {
      result.add(count);
      count += COLORS_BETWEEN_ANCHORS + 1;
    }
    else {
      result.add(null);
    }
  }

  return result;
}
 
Example 2
Source File: DiffDrawUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Color getDividerColorFromScheme(@Nonnull EditorColorsScheme scheme) {
  Color gutterBackground = scheme.getColor(EditorColors.GUTTER_BACKGROUND);
  if (gutterBackground == null) {
    gutterBackground = EditorColors.GUTTER_BACKGROUND.getDefaultColor();
  }
  return gutterBackground;
}
 
Example 3
Source File: DiffLineSeparatorRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Color getTopBorderColor(int i, int lineHeight, @Nonnull EditorColorsScheme scheme) {
  int border = Math.max(lineHeight / 4, 1);
  double ratio = (double)i / border;
  if (ratio > 1) return null;

  Color top = scheme.getColor(TOP_BORDER);
  if (top == null) return null;

  Color background = getBackgroundColor(scheme);
  return ColorUtil.mix(top, background, ratio);
}
 
Example 4
Source File: DiffLineSeparatorRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Color getBottomBorderColor(int i, int lineHeight, @Nonnull EditorColorsScheme scheme) {
  int height = getHeight(lineHeight);
  int border = Math.max(lineHeight / 12, 1);

  int index = (height - i - 1);
  double ratio = (double)index / border;
  if (ratio > 1) return null;

  Color bottom = scheme.getColor(BOTTOM_BORDER);
  if (bottom == null) return null;

  Color background = getBackgroundColor(scheme);
  return ColorUtil.mix(bottom, background, ratio);
}
 
Example 5
Source File: EditorFragmentComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static Color getBackgroundColor(Editor editor, boolean useCaretRowBackground) {
  EditorColorsScheme colorsScheme = editor.getColorsScheme();
  Color color = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR);
  if (!useCaretRowBackground || color == null) {
    color = colorsScheme.getDefaultBackground();
  }
  return color;
}
 
Example 6
Source File: RecentLocationsRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static JPanel createSeparatorLine(@Nonnull EditorColorsScheme colorsScheme) {
  Color color = colorsScheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
  if (color == null) {
    color = JBColor.namedColor("Group.separatorColor", new JBColor(Gray.xCD, Gray.x51));
  }

  return JBUI.Panels.simplePanel().withBorder(JBUI.Borders.customLine(color, 1, 0, 0, 0));
}
 
Example 7
Source File: LineMarkersPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static LineMarkerInfo<PsiElement> createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) {
  LineMarkerInfo<PsiElement> info = new LineMarkerInfo<>(startFrom, startFrom.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT);
  EditorColorsScheme scheme = colorsManager.getGlobalScheme();
  info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
  info.separatorPlacement = SeparatorPlacement.TOP;
  return info;
}
 
Example 8
Source File: CSharpLineMarkerProvider.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@Nonnull PsiElement element)
{
	if(myDaemonCodeAnalyzerSettings.SHOW_METHOD_SEPARATORS && (element instanceof DotNetQualifiedElement))
	{
		if(element.getNode().getTreeParent() == null)
		{
			return null;
		}

		final PsiElement parent = element.getParent();
		if(!(parent instanceof DotNetMemberOwner))
		{
			return null;
		}

		if(ArrayUtil.getFirstElement(((DotNetMemberOwner) parent).getMembers()) == element)
		{
			return null;
		}

		LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null,
				GutterIconRenderer.Alignment.RIGHT);
		EditorColorsScheme scheme = myEditorColorsManager.getGlobalScheme();
		info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
		info.separatorPlacement = SeparatorPlacement.TOP;
		return info;
	}

	final Ref<LineMarkerInfo> ref = Ref.create();
	Consumer<LineMarkerInfo> consumer = new Consumer<LineMarkerInfo>()
	{
		@Override
		public void consume(LineMarkerInfo markerInfo)
		{
			ref.set(markerInfo);
		}
	};

	//noinspection ForLoopReplaceableByForEach
	for(int j = 0; j < ourSingleCollector.length; j++)
	{
		LineMarkerCollector ourCollector = ourSingleCollector[j];
		ourCollector.collect(element, consumer);
	}

	return ref.get();
}
 
Example 9
Source File: DiffLineSeparatorRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Color getBackgroundColor(@Nonnull EditorColorsScheme scheme) {
  Color color = scheme.getColor(BACKGROUND);
  return color != null ? color : Gray._128;
}