diff --git a/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java b/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java index c418a61c061d..5bd893ee1128 100644 --- a/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java +++ b/platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java @@ -31,6 +31,7 @@ import com.intellij.psi.util.PsiUtilBase; import com.intellij.util.Function; import com.intellij.util.FunctionUtil; import com.intellij.util.ui.ColorIcon; +import com.intellij.util.ui.TwoColorsIcon; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -62,10 +63,12 @@ public final class ColorLineMarkerProvider implements LineMarkerProvider { private static class MyInfo extends MergeableLineMarkerInfo { + private final Color myColor; + public MyInfo(@NotNull final PsiElement element, final Color color, final ElementColorProvider colorProvider) { super(element, element.getTextRange(), - new ColorIcon(10, color), + new ColorIcon(12, color), Pass.UPDATE_ALL, FunctionUtil.nullConstant(), new GutterIconNavigationHandler() { @@ -87,7 +90,8 @@ public final class ColorLineMarkerProvider implements LineMarkerProvider { } } }, - GutterIconRenderer.Alignment.RIGHT); + GutterIconRenderer.Alignment.LEFT); + myColor = color; } @Override @@ -97,6 +101,9 @@ public final class ColorLineMarkerProvider implements LineMarkerProvider { @Override public Icon getCommonIcon(@NotNull List infos) { + if (infos.size() == 2 && infos.get(0) instanceof MyInfo && infos.get(1) instanceof MyInfo) { + return new TwoColorsIcon(12, ((MyInfo)infos.get(1)).myColor, ((MyInfo)infos.get(0)).myColor); + } return AllIcons.Gutter.Colors; } diff --git a/platform/util/src/com/intellij/util/ui/TwoColorsIcon.java b/platform/util/src/com/intellij/util/ui/TwoColorsIcon.java new file mode 100644 index 000000000000..b75c9cc53dfc --- /dev/null +++ b/platform/util/src/com/intellij/util/ui/TwoColorsIcon.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util.ui; + +import org.jetbrains.annotations.NotNull; + +import java.awt.*; + +/** + * User: Vassiliy.Kudryashov + */ +public class TwoColorsIcon extends EmptyIcon { + @NotNull private final Color myColor1; + @NotNull private final Color myColor2; + + public TwoColorsIcon(int size, @NotNull Color color1, @NotNull Color color2) { + super(size, size); + myColor1 = color1; + myColor2 = color2; + } + + @Override + public void paintIcon(final Component component, final Graphics g, final int x, final int y) { + final int w = getIconWidth(); + final int h = getIconHeight(); + g.setColor(myColor1); + g.fillPolygon(new int[]{x, x + w - 1, x}, new int[]{y, y, y + h - 1}, 3); + g.setColor(myColor2); + g.fillPolygon(new int[]{x + w, x + w, x}, new int[]{y, y + h, y + h}, 3); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + + TwoColorsIcon icon = (TwoColorsIcon)o; + + if (getIconWidth() != icon.getIconWidth()) return false; + if (getIconHeight() != icon.getIconHeight()) return false; + if (!myColor1.equals(icon.myColor1)) return false; + if (!myColor2.equals(icon.myColor2)) return false; + return true; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + myColor1.hashCode(); + result = 31 * result + myColor2.hashCode(); + return result; + } +}