001 package fang;
002
003 import java.awt.Graphics2D;
004 import java.awt.Shape;
005 import java.awt.TexturePaint;
006
007
008 public class ImageFill extends Fill
009 {
010 private TexturePaint myTexture;
011
012
013 public ImageFill (String name)
014 {
015 super(java.awt.Color.BLACK);
016 try
017 {
018 myTexture = new TexturePaint(
019 javax.imageio.ImageIO.read(new java.io.File(name)),
020 new java.awt.geom.Rectangle2D.Double(0, 0, .2, .2));
021 }
022 catch (java.io.IOException e)
023 {}
024 }
025
026
027 public void paint (Graphics2D pen, Shape shape)
028 {
029 pen.setPaint(myTexture);
030 pen.fill(shape);
031 }
032 }