
Indefinite Progress Indicator #47
Chapter 6, Transparent and Animated Windows
|
251
HACK
private void setBrightness(float multiple) {
float[] brightKernel = { multiple };
RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
BufferedImageOp bright = new ConvolveOp(new Kernel(1, 1, brightKernel),
ConvolveOp.EDGE_NO_OP, hints);
bright.filter(originalImage, convolvedImage);
repaint( );
}
The parameter multiple tells the method how many times brighter than the
original the resulting image must be. To achieve this effect, you can simply
perform a convolve operation on the original image. The kernel contains a
single value,
multiple. When the filter( ) method is invoked, every pixel
value of the original image is multiplied by the value of the kernel, making it
brighter. The result is stored in
convolveImage. It is now easy to use the
AnimatedPanel in an application:
Icon icon = UIHelper.readImageIcon("network.png");
AnimatedPanel animated = new AnimatedPanel("Waiting in vain...", icon);
getContentPane( ).add(animated);
animated.start( );
Besides the start( ) method, you can call stop( ) to interrupt the animation
thread when the task is done. This panel can be very efficient when used
with a
CardLayout. As this layout lets you stack components, you can put a
form on top of the animated panel. When the user performs an action, you
can display the animated ...