1 18 package org.apache.batik.svggen; 19 20 import java.awt.Graphics ; 21 import java.awt.Graphics2D ; 22 import java.awt.image.BufferedImage ; 23 24 import javax.swing.JComponent ; 25 26 33 public class JPainterComponent extends JComponent { 34 37 protected Painter painter; 38 39 42 public void paint(Graphics _g){ 43 Graphics2D g = (Graphics2D )_g; 44 BufferedImage buf = new BufferedImage (getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); 45 painter.paint(buf.createGraphics()); 46 g.drawImage(buf, 0, 0, null); 47 } 48 49 52 public JPainterComponent(Painter painter){ 53 this.painter = painter; 54 } 55 56 } 57 | Popular Tags |