Clover coverage report - Common - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:13:46 CET
file stats: LOC: 103   Methods: 4
NCLOC: 53   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PNGFileTools.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * EJTools, the Enterprise Java Tools
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at www.gnu.org.
 6   
  */
 7   
 package org.ejtools.util.export;
 8   
 
 9   
 import java.awt.Component;
 10   
 import java.awt.image.BufferedImage;
 11   
 import java.awt.image.RenderedImage;
 12   
 import java.io.File;
 13   
 import java.io.IOException;
 14   
 import java.util.ResourceBundle;
 15   
 
 16   
 import org.apache.log4j.Logger;
 17   
 import org.ejtools.util.FileTools;
 18   
 import org.ejtools.util.Platform;
 19   
 
 20   
 /**
 21   
  * Description of the Class
 22   
  *
 23   
  * @author    Laurent Etiemble
 24   
  * @version   $Revision: 1.2 $
 25   
  */
 26   
 public class PNGFileTools extends FileTools
 27   
 {
 28   
    /** Description of the Field */
 29   
    private static Logger logger = Logger.getLogger(PNGFileTools.class);
 30   
    /** Description of the Field */
 31   
    private static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.util.Resources");
 32   
    /** Description of the Field */
 33   
    public final static SimpleFileFilter PNG_FILE_FILTER = new FileTools.SimpleFileFilter(".png", resources.getString("png.file.dialog.extension.description"));
 34   
 
 35   
 
 36   
    /** Constructor for the FileUtil object */
 37  0
    protected PNGFileTools() { }
 38   
 
 39   
 
 40   
    /**
 41   
     * Description of the Method
 42   
     *
 43   
     * @param image   Description of the Parameter
 44   
     * @param output  Description of the Parameter
 45   
     */
 46  0
    public static void exportAsPNG(RenderedImage image, File output)
 47   
    {
 48  0
       if (Platform.isJavaVersionCompatible(Platform.JAVA_1_4))
 49   
       {
 50  0
          try
 51   
          {
 52   
             // Qualified name is mandatory
 53  0
             javax.imageio.ImageIO.write(image, "PNG", output);
 54   
          }
 55   
          catch (IOException ioe)
 56   
          {
 57  0
             logger.error("Can't export image as PNG", ioe);
 58   
          }
 59   
       }
 60   
    }
 61   
 
 62   
 
 63   
    /**
 64   
     * Description of the Method
 65   
     *
 66   
     * @param component  Description of the Parameter
 67   
     * @param output     Description of the Parameter
 68   
     */
 69  0
    public static void exportAsPNG(Component component, File output)
 70   
    {
 71  0
       if (Platform.isJavaVersionCompatible(Platform.JAVA_1_4))
 72   
       {
 73  0
          try
 74   
          {
 75  0
             BufferedImage image = paintAsPNG(component);
 76   
             // Qualified name is mandatory
 77  0
             javax.imageio.ImageIO.write(image, "PNG", output);
 78   
          }
 79   
          catch (IOException ioe)
 80   
          {
 81  0
             logger.error("Can't export image as PNG", ioe);
 82   
          }
 83   
       }
 84   
    }
 85   
 
 86   
 
 87   
    /**
 88   
     * Description of the Method
 89   
     *
 90   
     * @param component  Description of the Parameter
 91   
     * @return           Description of the Return Value
 92   
     */
 93  0
    public static BufferedImage paintAsPNG(Component component)
 94   
    {
 95  0
       BufferedImage image = null;
 96   
 
 97  0
       image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB);
 98  0
       component.paint(image.getGraphics());
 99   
 
 100  0
       return image;
 101   
    }
 102   
 }
 103