mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Top-Center-Bottom alignment ability (it was always "top")
This commit is contained in:
@@ -22,12 +22,20 @@ import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RowIcon implements Icon {
|
||||
private final Alignment myAlignment;
|
||||
|
||||
public enum Alignment {TOP, CENTER, BOTTOM}
|
||||
|
||||
private final Icon[] myIcons;
|
||||
private int myWidth;
|
||||
private int myHeight;
|
||||
|
||||
public RowIcon(int iconCount/*, int orientation*/) {
|
||||
this(iconCount, Alignment.CENTER);
|
||||
}
|
||||
|
||||
public RowIcon(int iconCount, Alignment alignment) {
|
||||
myAlignment = alignment;
|
||||
myIcons = new Icon[iconCount];
|
||||
//myOrientation = orientation;
|
||||
}
|
||||
@@ -56,9 +64,15 @@ public class RowIcon implements Icon {
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
int _x = x;
|
||||
int _y = y;
|
||||
for (Icon icon : myIcons) {
|
||||
if (icon == null) continue;
|
||||
icon.paintIcon(c, g, _x, y);
|
||||
switch (myAlignment) {
|
||||
case TOP: _y = y;break;
|
||||
case CENTER: _y = (myHeight - icon.getIconHeight())/2;break;
|
||||
case BOTTOM: _y = (myHeight - icon.getIconHeight());break;
|
||||
}
|
||||
icon.paintIcon(c, g, _x, _y);
|
||||
_x += icon.getIconWidth();
|
||||
//_y += icon.getIconHeight();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user