tabs: fixing invalidation on tab property changes
[fedora-idea.git] / platform / platform-api / src / com / intellij / ui / EdgeBorder.java
blob79563f2d6e64e430ced88de4cb6eeb96ef203ccd
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.ui;
18 import com.intellij.util.ui.UIUtil;
20 import javax.swing.*;
21 import javax.swing.border.Border;
22 import java.awt.*;
24 public class EdgeBorder implements Border {
25 public static final int EDGE_RIGHT = 61440;
26 public static final int EDGE_BOTTOM = 3840;
27 public static final int EDGE_LEFT = 240;
28 public static final int EDGE_TOP = 15;
29 public static final int EDGE_ALL = 65535;
30 private final Insets myInsets;
31 private final int b;
33 public EdgeBorder(int i) {
34 myInsets = new Insets(2, 2, 2, 2);
35 b = i;
36 recalcInsets();
39 public boolean isBorderOpaque() {
40 return true;
43 public Insets getBorderInsets(Component component) {
44 return myInsets;
47 public void paintBorder(Component component, Graphics g, int x, int y, int width, int height) {
48 java.awt.Color color = UIUtil.getSeparatorShadow();
49 java.awt.Color color1 = UIUtil.getSeparatorHighlight();
50 java.awt.Color color2 = g.getColor();
51 if ((b & 0xf) != 0){
52 g.setColor(color);
53 UIUtil.drawLine(g, x, y, (x + width) - 1, y);
54 g.setColor(color1);
55 UIUtil.drawLine(g, x, y + 1, (x + width) - 1, y + 1);
57 if ((b & 0xf0) != 0){
58 g.setColor(color);
59 UIUtil.drawLine(g, x, y, x, (y + height) - 1);
60 g.setColor(color1);
61 UIUtil.drawLine(g, x + 1, y, x + 1, (y + height) - 1);
63 if ((b & 0xf00) != 0){
64 g.setColor(color);
65 UIUtil.drawLine(g, x, (y + height) - 2, (x + width) - 1, (y + height) - 2);
66 g.setColor(color1);
67 UIUtil.drawLine(g, x, (y + height) - 1, (x + width) - 1, (y + height) - 1);
69 if ((b & 0xf000) != 0){
70 g.setColor(color1);
71 UIUtil.drawLine(g, (x + width) + 1, y, (x + width) + 1, (y + height) - 1);
72 g.setColor(color);
73 UIUtil.drawLine(g, (x + width), y, (x + width), (y + height) - 1);
75 g.setColor(color2);
78 protected void recalcInsets() {
79 myInsets.top = (b & 0xf) == 0 ? 0 : 2;
80 myInsets.left = (b & 0xf0) == 0 ? 0 : 2;
81 myInsets.bottom = (b & 0xf00) == 0 ? 0 : 2;
82 myInsets.right = (b & 0xf000) == 0 ? 0 : 2;