tabs: fixing invalidation on tab property changes
[fedora-idea.git] / platform / platform-api / src / com / intellij / ui / RowIcon.java
blob01b80b79fde2bcc0187a9abeb4760daa9d383117
2 /*
3 * Copyright 2000-2009 JetBrains s.r.o.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package com.intellij.ui;
20 import javax.swing.*;
21 import java.awt.*;
22 import java.util.Arrays;
24 /**
27 public class RowIcon implements Icon {
29 private final Icon[] myIcons;
30 private int myWidth;
31 private int myHeight;
33 public RowIcon(int iconCount/*, int orientation*/) {
34 myIcons = new Icon[iconCount];
35 //myOrientation = orientation;
38 public int hashCode() {
39 return myIcons.length > 0 ? myIcons[0].hashCode() : 0;
42 public boolean equals(Object obj) {
43 return obj instanceof RowIcon && Arrays.equals(((RowIcon)obj).myIcons, myIcons);
46 public int getIconCount() {
47 return myIcons.length;
50 public void setIcon(Icon icon, int layer) {
51 myIcons[layer] = icon;
52 recalculateSize();
55 public Icon getIcon(int index) {
56 return myIcons[index];
59 public void paintIcon(Component c, Graphics g, int x, int y) {
60 int _x = x;
61 for (Icon icon : myIcons) {
62 if (icon == null) continue;
63 icon.paintIcon(c, g, _x, y);
64 _x += icon.getIconWidth();
65 //_y += icon.getIconHeight();
69 public int getIconWidth() {
70 return myWidth;
73 public int getIconHeight() {
74 return myHeight;
77 private void recalculateSize() {
78 int width = 0;
79 int height = 0;
80 for (Icon icon : myIcons) {
81 if (icon == null) continue;
82 width += icon.getIconWidth();
83 //height += icon.getIconHeight();
84 height = Math.max(height, icon.getIconHeight());
86 myWidth = width;
87 myHeight = height;