public void paint(Graphics2D g2d) { frameNumber++; Dimension dimension = getDimension(); BufferedImage mainStage = createMainStage(); BufferedImage frame = mainStage.getSubimage(0, 48 - frameNumber * 2, dimension.width, dimension.height); g2d.drawImage(frame, null, null); Color progressbarBackgroundColor = new Color(basicColor); Color progressbarShadowStartColor = ColorUtils.overwriteAlpha( ColorUtils.adjustLightness(progressbarBackgroundColor, 0.7f), 0.6f); Color progressbarShadowEndColor = ColorUtils.overwriteAlpha( ColorUtils.adjustLightness(progressbarBackgroundColor, 0.3f), 0.6f); // paint a shadow in the form of semi-transparent gradient g2d.setPaint( new GradientPaint(0, 0, progressbarShadowStartColor, 0, 7, progressbarShadowEndColor)); g2d.fillRect(0, 0, dimension.width, 7); }
/** * Creates a main stage for progress bar background. * * @param context resource context * @return a <code>BufferedImage</code> object */ private BufferedImage createMainStage() { Color progressbarBackgroundColor = new Color(basicColor); Color progressbarSpiralColor = ColorUtils.adjustLightness(progressbarBackgroundColor, 0.2f); Dimension dimension = getDimension(); BufferedImage retVal = getImageType().createImage(dimension.width, dimension.height * 2); Graphics g = retVal.getGraphics(); try { g.setColor(progressbarBackgroundColor); g.fillRect(0, 0, dimension.width, dimension.height * 2); g.setColor(progressbarSpiralColor); for (int k : new int[] {-24, 0, 24, 48, 72}) { g.fillPolygon(new int[] {0, 24, 24, 0}, new int[] {24 + k, k, 12 + k, 36 + k}, 4); } } finally { if (g != null) { g.dispose(); } } return retVal; }