1 17 18 19 20 package org.apache.fop.visual; 21 22 import java.awt.image.BufferedImage ; 23 import java.io.File ; 24 25 import org.apache.avalon.framework.configuration.Configurable; 26 import org.apache.avalon.framework.configuration.Configuration; 27 import org.apache.avalon.framework.configuration.ConfigurationException; 28 29 41 public class ReferenceBitmapLoader extends AbstractBitmapProducer implements Configurable { 42 43 private File bitmapDirectory; 44 45 46 public void configure(Configuration cfg) throws ConfigurationException { 47 this.bitmapDirectory = new File (cfg.getChild("directory").getValue(null)); 48 if (!bitmapDirectory.exists()) { 49 throw new ConfigurationException("Directory could not be found: " + bitmapDirectory); 50 } 51 } 52 53 54 public BufferedImage produce(File src, ProducerContext context) { 55 try { 56 File bitmap = new File (bitmapDirectory, src.getName() + ".png"); 57 if (bitmap.exists()) { 58 return BitmapComparator.getImage(bitmap); 59 } else { 60 return null; 61 } 62 } catch (Exception e) { 63 log.error(e); 64 return null; 65 } 66 } 67 68 } 69 | Popular Tags |