[Ejtools-cvs] libraries/common/src/main/org/ejtools/util/export CSVFileTools.java,NONE,1.1 PNGFileTo
Brought to you by:
letiemble
From: <let...@us...> - 2003-12-14 09:48:37
|
Update of /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/export In directory sc8-pr-cvs1:/tmp/cvs-serv18971/common/src/main/org/ejtools/util/export Added Files: CSVFileTools.java PNGFileTools.java package.html Log Message: Add more javadocs. Add package.html files. --- NEW FILE: CSVFileTools.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package org.ejtools.util.export; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ResourceBundle; import javax.swing.filechooser.FileFilter; import org.apache.log4j.Logger; import org.ejtools.util.FileTools; /** * Description of the Class * * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public class CSVFileTools extends FileTools { /** Description of the Field */ private static Logger logger = Logger.getLogger(CSVFileTools.class); /** Description of the Field */ private static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.util.Resources"); /** Description of the Field */ public final static FileFilter CSV_FILE_FILTER = new FileTools.SimpleFileFilter(".csv", resources.getString("csv.file.dialog.extension.description")); /** Constructor for the FileUtil object */ protected CSVFileTools() { } /** * Description of the Method * * @param output Description of the Parameter * @param content Description of the Parameter */ public static void exportAsCVS(StringBuffer content, File output) { try { FileWriter writer = new FileWriter(output); writer.write(content.toString()); writer.flush(); writer.close(); } catch (IOException ioe) { logger.error("Can't export content as CSV", ioe); } } } --- NEW FILE: PNGFileTools.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package org.ejtools.util.export; import java.awt.Component; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; import java.io.File; import java.io.IOException; import java.util.ResourceBundle; import javax.swing.filechooser.FileFilter; import org.apache.log4j.Logger; import org.ejtools.util.FileTools; import org.ejtools.util.Platform; /** * Description of the Class * * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public class PNGFileTools extends FileTools { /** Description of the Field */ private static Logger logger = Logger.getLogger(PNGFileTools.class); /** Description of the Field */ private static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.util.Resources"); /** Description of the Field */ public final static FileFilter PNG_FILE_FILTER = new FileTools.SimpleFileFilter(".png", resources.getString("png.file.dialog.extension.description")); /** Constructor for the FileUtil object */ protected PNGFileTools() { } /** * Description of the Method * * @param image Description of the Parameter * @param output Description of the Parameter */ public static void exportAsPNG(RenderedImage image, File output) { if (Platform.isJavaVersionCompatible(Platform.JAVA_1_4)) { try { // Qualified name is mandatory javax.imageio.ImageIO.write(image, "PNG", output); } catch (IOException ioe) { logger.error("Can't export image as PNG", ioe); } } } /** * Description of the Method * * @param component Description of the Parameter * @param output Description of the Parameter */ public static void exportAsPNG(Component component, File output) { if (Platform.isJavaVersionCompatible(Platform.JAVA_1_4)) { try { BufferedImage image = paintAsPNG(component); // Qualified name is mandatory javax.imageio.ImageIO.write(image, "PNG", output); } catch (IOException ioe) { logger.error("Can't export image as PNG", ioe); } } } /** * Description of the Method * * @param component Description of the Parameter * @return Description of the Return Value */ public static BufferedImage paintAsPNG(Component component) { BufferedImage image = null; image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB); component.paint(image.getGraphics()); return image; } } --- NEW FILE: package.html --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!-- EJTools, the Enterprise Java Tools Distributable under LGPL license. See terms of license at www.gnu.org. $Revision: 1.1 $ --> <html> <head/> <body> </body> </html> |