changeset 868:0926cdd87a6b

Only paint gradient in visible bounds review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-December/004844.html reviewed-by: rkennke
author Mario Torre <neugens.limasoftware@gmail.com>
date Mon, 17 Dec 2012 20:59:52 +0100
parents b9fb5202738f
children b7125452697f
files client/swing/src/main/java/com/redhat/thermostat/client/swing/components/GradientPanel.java
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/GradientPanel.java	Mon Dec 17 20:41:17 2012 +0100
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/GradientPanel.java	Mon Dec 17 20:59:52 2012 +0100
@@ -41,6 +41,7 @@
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.Paint;
+import java.awt.Rectangle;
 
 import javax.swing.JPanel;
 
@@ -61,9 +62,11 @@
         
         Graphics2D graphics = GraphicsUtils.getInstance().createAAGraphics(g);
         
+        Rectangle bounds = g.getClipBounds();
+        
         Paint gradient = new GradientPaint(0, 0, top, 0, getHeight(), bottom);
         graphics.setPaint(gradient);
-        graphics.fillRect(0, 0, getWidth(), getHeight());
+        graphics.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
         graphics.dispose();
     }
 }