import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.image.*; public class BluredBarMeter extends BarMeter { protected BufferedImage filteredImage; protected ConvolveOp blur; public void createBufferImage(){ // アプレットのサイズをえる Dimension size = this.getSize(); height = size.height; width = size.width; float[] blurElements = new float[25]; for(int i = 0 ; i < 25 ; i++){ blurElements[i] = 1.0f/25.0f; } Kernel kernel = new Kernel(5, 5, blurElements); blur = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); // イメージの生成 if(width != 0 && height != 0){ image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); filteredImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); graphics = image.getGraphics(); } } public void paint(Graphics g){ // ダブルバッファリング用のイメージがなければ、 // 生成し、グラフィックコンテキストをえる。 if(image == null || resizeFlag){ createBufferImage(); resizeFlag = false; } // 背景色で塗りつぶす graphics.setColor(this.getBackground()); graphics.fillRect(0, 0, width, height); // バーの描画 drawBar(graphics, value); // Java2D のグラフィックコンテキストに変換 Graphics2D g2 = (Graphics2D)g; blur.filter((BufferedImage)image, filteredImage); // イメージバッファの描画 g2.drawImage(filteredImage, 0 , 0, this); } }