The modification is simple, of course I'd like to see if anybody else
notices the perf. difference ...
src/java/ab5k/backgrounds/GradientBackgroud.java
+-------------------------------------------------------------------------
/**
*
* @author joshy
*/
public class GradientBackground extends DesktopBackground {
BufferedImage background;
+------------------------------------------------------------------------
public void paint(Graphics2D gc) {
if (getDesktopPane() == null) {
return;
}
if (background == null || background.getWidth() !=
desktopPane.getWidth() ||
background.getHeight() != desktopPane.getHeight()) {
background =
desktopPane.getGraphicsConfiguration().createCompatibleImage(
desktopPane.getWidth(),
desktopPane.getHeight());
Graphics2D g = background.createGraphics();
// the background
g.setPaint(new GradientPaint(new Point(0,0),
new Color(190,190,204),
new Point(desktopPane.getWidth(),
desktopPane.getHeight()),
new Color(50,50,204)));
g.fillRect(0, 0, desktopPane.getWidth(),
desktopPane.getHeight());
PinstripePainter pin = new PinstripePainter(new
Color(50,50,204,30), 45.0,8.0,8.0);
Graphics2D gfx = (Graphics2D) g.create();
if (gfx.getClip() == null) {
gfx.setClip(0, 0, desktopPane.getWidth(),
desktopPane.getHeight());
}
pin.paint(gfx, desktopPane, desktopPane.getWidth(),
desktopPane.getHeight());
gfx.dispose();
// the text
String text = "AB5k";
g.setColor(new Color(255,255,255,30));
g.setFont(new Font(Font.SANS_SERIF,Font.BOLD,400));
FontMetrics metrics = g.getFontMetrics();
Rectangle2D bounds = metrics.getStringBounds(text,g);
g.translate(desktopPane.getWidth()/
2,desktopPane.getHeight()/2);
g.translate(-(bounds.getX()+bounds.getWidth())/2,
0-bounds.getY()-bounds.getHeight()/2);
g.drawString(text,0,0);
g.dispose();
}
gc.drawImage(background, 0, 0, desktopPane);
}
+-------------------------------------------------------------