Large gradient rects are dare. Fill them using tile technique

This commit is contained in:
Maxim Shafirov
2011-08-02 21:44:53 +04:00
parent f541e99df2
commit 3789991741
2 changed files with 19 additions and 3 deletions
@@ -184,9 +184,7 @@ public class MacStatusBarUI extends StatusBarUI implements Activatable {
final Color top = active ? ACTIVE_TOP_COLOR : INACTIVE_TOP_COLOR;
final Color bottom = active ? ACTIVE_BOTTOM_COLOR : INACTIVE_BOTTOM_COLOR;
final GradientPaint paint = new GradientPaint(0, 0, top, 0, height, bottom);
g2d.setPaint(paint);
g2d.fillRect(0, 0, width, height);
UIUtil.fillVerticalGradient(c, g, x, y, width, height, top, bottom);
if (active) {
g2d.setColor(ACTIVE_BORDER_TOP_COLOR);
@@ -158,6 +158,24 @@ public class UIUtil {
}
}
public static void fillVerticalGradient(final Component c,
final Graphics g,
final int x,
final int y,
final int width,
final int height,
final Color top,
final Color bottom) {
BufferedImage img = new BufferedImage(10, height, BufferedImage.TYPE_INT_RGB);
Graphics2D imageGraphics = (Graphics2D)img.getGraphics();
imageGraphics.setPaint(new GradientPaint(0, 0, top, 0, height, bottom));
imageGraphics.fillRect(0, 0, 10, height);
for (int i = x; i < x + width; i += 10) {
g.drawImage(img, i, y, Math.min(10, width - i), height, null);
}
}
public static boolean isReallyTypedEvent(KeyEvent e) {
char c = e.getKeyChar();
if (!(c >= 0x20 && c != 0x7F)) return false;