Example usage for javax.imageio ImageIO getWriterFormatNames

List of usage examples for javax.imageio ImageIO getWriterFormatNames

Introduction

In this page you can find the example usage for javax.imageio ImageIO getWriterFormatNames.

Prototype

public static String[] getWriterFormatNames() 

Source Link

Document

Returns an array of String s listing all of the informal format names understood by the current set of registered writers.

Usage

From source file:org.lmn.fc.common.datatranslators.DataExporter.java

/***********************************************************************************************
 * exportComponent().//from ww w  . j a  v  a 2s .c  o  m
 *
 * @param exportable
 * @param filename
 * @param timestamp
 * @param type
 * @param width
 * @param height
 * @param log
 * @param clock
 *
 * @return boolean
 */

public static boolean exportComponent(final ExportableComponentInterface exportable, final String filename,
        final boolean timestamp, final String type, final int width, final int height, final Vector<Vector> log,
        final ObservatoryClockInterface clock) {
    final String SOURCE = "DataExporter.exportComponent()";
    boolean boolSuccess;

    //        String[] arrayNames = ImageIO.getWriterFormatNames();
    //
    //        for (int i = 0;
    //             i < arrayNames.length;
    //             i++)
    //            {
    //            String arrayName = arrayNames[i];
    //            System.out.println("DataExporter.exportComponent() FORMAT NAME=" + arrayName);
    //            }
    //
    boolSuccess = false;

    if ((exportable != null) && (filename != null) && (!EMPTY_STRING.equals(filename)) && (type != null)
            && (!EMPTY_STRING.equals(type)) && (log != null) && (clock != null)
            && (Arrays.asList(ImageIO.getWriterFormatNames()).contains(type))) {
        try {
            final File file;
            final int intRealWidth;
            final int intRealHeight;

            file = new File(FileUtilities.buildFullFilename(filename, timestamp, type));
            FileUtilities.overwriteFile(file);

            intRealWidth = width;
            intRealHeight = height;

            // Support all current formats
            if ((FileUtilities.png.equalsIgnoreCase(type)) || (FileUtilities.jpg.equalsIgnoreCase(type))
                    || (FileUtilities.gif.equalsIgnoreCase(type))) {
                BufferedImage buffer;
                final Graphics2D graphics2D;

                LOGGER.debugTimedEvent(LOADER_PROPERTIES.isTimingDebug(),
                        "DataExporter.exportComponent() writing [file " + file.getAbsolutePath() + "] [width="
                                + intRealWidth + "] [height=" + intRealHeight + "]");

                buffer = new BufferedImage(intRealWidth, intRealHeight, BufferedImage.TYPE_INT_RGB);

                // Create a graphics context on the buffered image
                graphics2D = buffer.createGraphics();

                // Draw on the image
                graphics2D.clearRect(0, 0, intRealWidth, intRealHeight);
                exportable.paintForExport(graphics2D, intRealWidth, intRealHeight);

                // Export the image
                ImageIO.write(buffer, type, file);
                graphics2D.dispose();
                boolSuccess = true;

                SimpleEventLogUIComponent
                        .logEvent(
                                log, EventStatus.INFO, METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT
                                        + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR,
                                SOURCE, clock);
                // Help the GC?
                buffer = null;

                ObservatoryInstrumentHelper.runGarbageCollector();
            } else {
                SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_COMPONENT
                        + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_INVALID_FORMAT + TERMINATOR, SOURCE,
                        clock);
            }
        }

        catch (IllegalArgumentException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT
                            + EXCEPTION_PARAMETER_INVALID + TERMINATOR + SPACE + METADATA_EXCEPTION
                            + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (SecurityException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_ACCESS_DENIED
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (FileNotFoundException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_NOT_FOUND
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (IOException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_SAVE
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }
    } else {
        SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_COMPONENT
                + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_COMPONENT + TERMINATOR, SOURCE, clock);
    }

    return (boolSuccess);
}

From source file:com.aimluck.eip.fileupload.util.FileuploadUtils.java

/**
 * Java1.5BMP, bmp, jpeg, wbmp, gif, png, JPG, jpg, WBMP, JPEG
 * /*from  ww w  .  j a  va 2  s .c om*/
 * @param fileType
 * @return
 */
public static boolean isImage(String fileName) {
    if (fileName == null || "".equals(fileName)) {
        return false;
    }

    int index = fileName.lastIndexOf(".");
    if (index < 1) {
        return false;
    }

    String fileType = getFileTypeName(fileName);

    String[] format = ImageIO.getWriterFormatNames();
    int len = format.length;
    for (int i = 0; i < len; i++) {
        if (format[i].equals(fileType)) {
            return true;
        }
    }
    return false;
}

From source file:com.github.podd.example.ExamplePoddClient.java

public List<String> getImageFormatNames() {
    final String[] formats = ImageIO.getWriterFormatNames();
    // Need to de-duplicate format names that come as both upper and lower case
    final HashSet<String> formatSet = new HashSet<String>();
    for (final String s : formats) {
        formatSet.add(s.toLowerCase());/*from  w w  w  . j av  a  2 s  .c o m*/
    }
    final List<String> result = new ArrayList<>(formatSet);
    Collections.sort(result);
    return result;
}

From source file:com.aipo.social.opensocial.spi.AipoStorageService.java

/**
 * Java1.5BMP, bmp, jpeg, wbmp, gif, png, JPG, jpg, WBMP, JPEG
 *
 * @param fileType/* ww w.  j  a  v  a 2 s  .  co  m*/
 * @return
 */
@Override
public boolean isImage(String fileName, SecurityToken paramSecurityToken) throws ProtocolException {
    if (fileName == null || "".equals(fileName)) {
        return false;
    }

    int index = fileName.lastIndexOf(".");
    if (index < 1) {
        return false;
    }

    String fileType = getFileTypeName(fileName, paramSecurityToken);

    String[] format = ImageIO.getWriterFormatNames();
    int len = format.length;
    for (int i = 0; i < len; i++) {
        if (format[i].equals(fileType)) {
            return true;
        }
    }
    return false;
}

From source file:org.lmn.fc.common.datatranslators.DataExporter.java

/***********************************************************************************************
 * exportImage()./*from   ww w.  j  a  va  2  s.co m*/
 *
 * @param image
 * @param filename
 * @param timestamp
 * @param type
 * @param log
 * @param clock
 *
 * @return boolean
 */

public static boolean exportImage(final Image image, final String filename, final boolean timestamp,
        final String type, final Vector<Vector> log, final ObservatoryClockInterface clock) {
    final String SOURCE = "DataExporter.exportImage()";
    boolean boolSuccess;

    boolSuccess = false;

    if ((image != null) && (image instanceof RenderedImage) && (filename != null)
            && (!EMPTY_STRING.equals(filename)) && (type != null) && (!EMPTY_STRING.equals(type))
            && (log != null) && (clock != null)
            && (Arrays.asList(ImageIO.getWriterFormatNames()).contains(type))) {
        try {
            final File file;

            file = new File(FileUtilities.buildFullFilename(filename, timestamp, type));
            FileUtilities.overwriteFile(file);

            // Support all current formats
            if ((FileUtilities.png.equalsIgnoreCase(type)) || (FileUtilities.jpg.equalsIgnoreCase(type))
                    || (FileUtilities.gif.equalsIgnoreCase(type))) {
                LOGGER.debugTimedEvent(LOADER_PROPERTIES.isTimingDebug(),
                        "DataExporter.exportImage() writing [file " + file.getAbsolutePath() + "]");
                // Export the image
                ImageIO.write((RenderedImage) image, type, file);
                boolSuccess = true;

                SimpleEventLogUIComponent
                        .logEvent(
                                log, EventStatus.INFO, METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT
                                        + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR,
                                SOURCE, clock);
            } else {
                SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_IMAGE
                        + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_INVALID_FORMAT + TERMINATOR, SOURCE,
                        clock);
            }
        }

        catch (SecurityException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_ACCESS_DENIED
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (FileNotFoundException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_NOT_FOUND
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (IOException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_SAVE
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }
    } else {
        SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_IMAGE + TERMINATOR,
                SOURCE, clock);
    }

    return (boolSuccess);
}

From source file:com.aimluck.eip.gpdb.util.GpdbUtils.java

/**
 * ?// ww w.ja  v a 2 s.c  o m
 * 
 * @param rundata
 *          RunData
 * @param context
 *          Context
 * @param record
 *          Web
 * @param fileuploadList
 *          
 * @param folderName
 *          ??
 * @param msgList
 *          
 * @return ?TRUE FALSE
 */
public static boolean insertFileDataDelegate(RunData rundata, Context context, EipTGpdbRecord record,
        List<FileuploadLiteBean> fileuploadList, String folderName, List<String> msgList) {
    if (fileuploadList == null || fileuploadList.size() <= 0) {
        fileuploadList = new ArrayList<FileuploadLiteBean>();
    }

    int uid = ALEipUtils.getUserId(rundata);
    String orgId = Database.getDomainName();

    List<Integer> hadfileids = new ArrayList<Integer>();
    for (FileuploadLiteBean file : fileuploadList) {
        if (!file.isNewFile()) {
            hadfileids.add(file.getFileId());
        }
    }

    SelectQuery<EipTGpdbRecordFile> dbquery = Database.query(EipTGpdbRecordFile.class);
    dbquery.andQualifier(ExpressionFactory.matchDbExp(EipTGpdbRecordFile.EIP_TGPDB_RECORD_PROPERTY,
            record.getGpdbRecordId()));
    List<EipTGpdbRecordFile> existsFiles = dbquery.fetchList();
    List<EipTGpdbRecordFile> delFiles = new ArrayList<EipTGpdbRecordFile>();
    for (EipTGpdbRecordFile file : existsFiles) {
        if (!hadfileids.contains(file.getFileId())) {
            delFiles.add(file);
        }
    }

    // ??????
    if (delFiles.size() > 0) {
        int delsize = delFiles.size();
        for (int i = 0; i < delsize; i++) {
            ALStorageService
                    .deleteFile(getSaveDirPath(delFiles.get(i).getOwnerId()) + (delFiles.get(i)).getFilePath());
        }
        // ??
        Database.deleteAll(delFiles);
    }

    // ?
    try {
        for (FileuploadLiteBean filebean : fileuploadList) {
            if (!filebean.isNewFile()) {
                continue;
            }

            // ??
            String[] acceptExts = ImageIO.getWriterFormatNames();
            ShrinkImageSet shrinkImageSet = FileuploadUtils.getBytesShrinkFilebean(orgId, folderName, uid,
                    filebean, acceptExts, FileuploadUtils.DEF_THUMBNAIL_WIDTH,
                    FileuploadUtils.DEF_THUMBNAIL_HEIGHT, msgList, true);

            String filename = "0_" + String.valueOf(System.nanoTime());

            // ?
            EipTGpdbRecordFile file = Database.create(EipTGpdbRecordFile.class);
            // 
            file.setOwnerId(Integer.valueOf(uid));
            // ID
            file.setEipTGpdbRecord(record);
            // ??
            file.setFileName(filebean.getFileName());
            // 
            file.setFilePath(getRelativePath(filename));
            // ??
            if (shrinkImageSet != null && shrinkImageSet.getShrinkImage() != null) {
                file.setFileThumbnail(shrinkImageSet.getShrinkImage());
            }
            // ?
            file.setCreateDate(Calendar.getInstance().getTime());
            // 
            file.setUpdateDate(Calendar.getInstance().getTime());

            if (shrinkImageSet != null && shrinkImageSet.getFixImage() != null) {
                // ??
                ALStorageService.createNewFile(new ByteArrayInputStream(shrinkImageSet.getFixImage()),
                        FOLDER_FILEDIR_GPDB + ALStorageService.separator() + Database.getDomainName()
                                + ALStorageService.separator() + CATEGORY_KEY + ALStorageService.separator()
                                + uid + ALStorageService.separator() + filename);
            } else {
                // ?
                ALStorageService.copyTmpFile(uid, folderName, String.valueOf(filebean.getFileId()),
                        FOLDER_FILEDIR_GPDB, CATEGORY_KEY + ALStorageService.separator() + uid, filename);
            }
        }

        // ??
        if (folderName != null && !"".equals(folderName.trim())) {
            ALStorageService.deleteTmpFolder(uid, folderName);
        }
    } catch (Exception e) {
        Database.rollback();
        logger.error("Exception", e);
        return false;
    }
    return true;
}

From source file:com.aimluck.eip.schedule.util.ScheduleUtils.java

public static boolean insertFileDataDelegate(RunData rundata, Context context, EipTSchedule schedule,
        List<FileuploadLiteBean> fileuploadList, String folderName, List<String> msgList) {
    if (fileuploadList == null || fileuploadList.size() <= 0) {
        fileuploadList = new ArrayList<FileuploadLiteBean>();
    }/* ww w  . j av  a  2 s .  co m*/

    int uid = ALEipUtils.getUserId(rundata);
    String orgId = Database.getDomainName();

    List<Integer> hadfileids = new ArrayList<Integer>();
    for (FileuploadLiteBean file : fileuploadList) {
        if (!file.isNewFile()) {
            hadfileids.add(file.getFileId());
        }
    }

    SelectQuery<EipTScheduleFile> dbquery = Database.query(EipTScheduleFile.class);
    dbquery.andQualifier(
            ExpressionFactory.matchDbExp(EipTScheduleFile.EIP_TSCHEDULE_PROPERTY, schedule.getScheduleId()));
    List<EipTScheduleFile> existsFiles = dbquery.fetchList();
    List<EipTScheduleFile> delFiles = new ArrayList<EipTScheduleFile>();
    for (EipTScheduleFile file : existsFiles) {
        if (!hadfileids.contains(file.getFileId())) {
            delFiles.add(file);
        }
    }

    // ??????
    if (delFiles.size() > 0) {
        try {
            ALDeleteFileUtil.deleteFiles(ScheduleUtils.FOLDER_FILEDIR_SCHEDULE, ScheduleUtils.CATEGORY_KEY,
                    delFiles);
        } catch (ALFileNotRemovedException e) {
            Database.rollback();
            logger.error("schedule", e);
            return false;
        }
    }

    // ?
    try {
        for (FileuploadLiteBean filebean : fileuploadList) {
            if (!filebean.isNewFile()) {
                continue;
            }

            // ??
            String[] acceptExts = ImageIO.getWriterFormatNames();
            ShrinkImageSet shrinkImageSet = FileuploadUtils.getBytesShrinkFilebean(orgId, folderName, uid,
                    filebean, acceptExts, FileuploadUtils.DEF_THUMBNAIL_WIDTH,
                    FileuploadUtils.DEF_THUMBNAIL_HEIGHT, msgList, true);

            String filename = "0_" + String.valueOf(System.nanoTime());

            // ?
            EipTScheduleFile file = Database.create(EipTScheduleFile.class);
            // 
            file.setOwnerId(Integer.valueOf(uid));
            // ID
            file.setEipTSchedule(schedule);
            // ??
            file.setFileName(filebean.getFileName());
            // 
            file.setFilePath(ScheduleUtils.getRelativePath(filename));
            // ??
            if (shrinkImageSet != null && shrinkImageSet.getShrinkImage() != null) {
                file.setFileThumbnail(shrinkImageSet.getShrinkImage());
            }
            // ?
            file.setCreateDate(Calendar.getInstance().getTime());
            // 
            file.setUpdateDate(Calendar.getInstance().getTime());

            if (shrinkImageSet != null && shrinkImageSet.getFixImage() != null) {
                // ??
                ALStorageService.createNewFile(new ByteArrayInputStream(shrinkImageSet.getFixImage()),
                        FOLDER_FILEDIR_SCHEDULE + ALStorageService.separator() + Database.getDomainName()
                                + ALStorageService.separator() + CATEGORY_KEY + ALStorageService.separator()
                                + uid + ALStorageService.separator() + filename);
            } else {
                // ?
                ALStorageService.copyTmpFile(uid, folderName, String.valueOf(filebean.getFileId()),
                        FOLDER_FILEDIR_SCHEDULE, CATEGORY_KEY + ALStorageService.separator() + uid, filename);
            }
        }

        ALStorageService.deleteTmpFolder(uid, folderName);

    } catch (Exception e) {
        Database.rollback();
        logger.error("schedule", e);
        return false;
    }
    return true;
}

From source file:org.broad.igv.hic.MainWindow.java

private JMenuBar createMenuBar(final JPanel hiCPanel) {

    JMenuBar menuBar = new JMenuBar();

    //======== fileMenu ========
    JMenu fileMenu = new JMenu("File");

    //---- loadMenuItem ----
    JMenuItem loadMenuItem = new JMenuItem();
    loadMenuItem.setText("Load...");
    loadMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            loadMenuItemActionPerformed(e);
        }/*from w w  w .j a va  2 s.co  m*/
    });
    fileMenu.add(loadMenuItem);

    //---- loadFromURL ----
    JMenuItem loadFromURL = new JMenuItem();
    JMenuItem getEigenvector = new JMenuItem();
    final JCheckBoxMenuItem viewDNAseI;

    loadFromURL.setText("Load from URL ...");
    loadFromURL.setName("loadFromURL");
    loadFromURL.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            loadFromURLActionPerformed(e);
        }
    });
    fileMenu.add(loadFromURL);
    fileMenu.addSeparator();

    // Pre-defined datasets.  TODO -- generate from a file
    addPredefinedLoadItems(fileMenu);

    JMenuItem saveToImage = new JMenuItem();
    saveToImage.setText("Save to image");
    saveToImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            BufferedImage image = (BufferedImage) createImage(1000, 1000);
            Graphics g = image.createGraphics();
            hiCPanel.paint(g);

            JFileChooser fc = new JFileChooser();
            fc.setSelectedFile(new File("image.png"));
            int actionDialog = fc.showSaveDialog(null);
            if (actionDialog == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                if (file.exists()) {
                    actionDialog = JOptionPane.showConfirmDialog(null, "Replace existing file?");
                    if (actionDialog == JOptionPane.NO_OPTION || actionDialog == JOptionPane.CANCEL_OPTION)
                        return;
                }
                try {
                    // default if they give no format or invalid format
                    String fmt = "jpg";
                    int ind = file.getName().indexOf(".");
                    if (ind != -1) {
                        String ext = file.getName().substring(ind + 1);
                        String[] strs = ImageIO.getWriterFormatNames();
                        for (String aStr : strs)
                            if (ext.equals(aStr))
                                fmt = ext;
                    }
                    ImageIO.write(image.getSubimage(0, 0, 600, 600), fmt, file);
                } catch (IOException ie) {
                    System.err.println("Unable to write " + file + ": " + ie);
                }
            }
        }
    });
    fileMenu.add(saveToImage);
    getEigenvector = new JMenuItem("Get principal eigenvector");
    getEigenvector.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getEigenvectorActionPerformed(e);
        }
    });
    fileMenu.add(getEigenvector);
    //---- exit ----
    JMenuItem exit = new JMenuItem();
    exit.setText("Exit");
    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            exitActionPerformed(e);
        }
    });
    fileMenu.add(exit);

    menuBar.add(fileMenu);

    //======== Tracks menu ========

    JMenu tracksMenu = new JMenu("Tracks");

    viewEigenvector = new JCheckBoxMenuItem("View Eigenvector...");
    viewEigenvector.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (viewEigenvector.isSelected()) {
                if (eigenvectorTrack == null) {
                    eigenvectorTrack = new EigenvectorTrack("eigen", "Eigenvectors");
                }
                updateEigenvectorTrack();
            } else {
                trackPanel.setEigenvectorTrack(null);
                if (HiCTrackManager.getLoadedTracks().isEmpty()) {
                    trackPanel.setVisible(false);
                }
            }
        }
    });
    viewEigenvector.setEnabled(false);
    tracksMenu.add(viewEigenvector);

    JMenuItem loadItem = new JMenuItem("Load...");
    loadItem.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            HiCTrackManager.loadHostedTrack(MainWindow.this);
        }

    });
    tracksMenu.add(loadItem);

    JMenuItem loadFromFileItem = new JMenuItem("Load from file...");
    loadFromFileItem.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            HiCTrackManager.loadTrackFromFile(MainWindow.this);
        }

    });
    tracksMenu.add(loadFromFileItem);

    menuBar.add(tracksMenu);

    //======== Extras menu ========
    JMenu extrasMenu = new JMenu("Extras");

    JMenuItem dumpPearsons = new JMenuItem("Dump pearsons matrix ...");
    dumpPearsons.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            BasicMatrix pearsons = hic.zd.getPearsons();
            try {
                String chr1 = hic.getChromosomes()[hic.zd.getChr1()].getName();
                String chr2 = hic.getChromosomes()[hic.zd.getChr2()].getName();
                int binSize = hic.zd.getBinSize();
                File initFile = new File("pearsons_" + chr1 + "_" + "_" + chr2 + "_" + binSize + ".bin");
                File f = FileDialogUtils.chooseFile("Save pearsons", null, initFile, FileDialogUtils.SAVE);
                if (f != null) {
                    ScratchPad.dumpPearsonsBinary(pearsons, chr1, chr2, hic.zd.getBinSize(), f);
                }
            } catch (IOException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }
        }

    });

    JMenuItem dumpEigenvector = new JMenuItem("Dump eigenvector ...");
    dumpEigenvector.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                ScratchPad.dumpEigenvector(hic);
            } catch (IOException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }
        }

    });
    extrasMenu.add(dumpEigenvector);

    JMenuItem readPearsons = new JMenuItem("Read pearsons...");
    readPearsons.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                File f = FileDialogUtils.chooseFile("Pearsons file (Yunfan format)");
                if (f != null) {
                    BasicMatrix bm = ScratchPad.readPearsons(f.getAbsolutePath());

                    hic.zd.setPearsons(bm);
                }
            } catch (IOException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }
        }

    });
    extrasMenu.add(readPearsons);

    extrasMenu.add(dumpPearsons);
    menuBar.add(extrasMenu);

    return menuBar;
}

From source file:org.dcm4che.tool.dcm2jpg.Dcm2Jpg.java

public static void listSupportedFormats() {
    System.out.println(//www.j a v a  2s.co m
            MessageFormat.format(rb.getString("formats"), Arrays.toString(ImageIO.getWriterFormatNames())));
}

From source file:org.openmrs.obs.handler.ImageHandler.java

/**
 * Constructor initializes formats for alternative file names to protect from unintentionally
 * overwriting existing files./*  ww  w. jav a 2s .  c  o m*/
 */
public ImageHandler() {
    super();

    // Create a HashSet to quickly check for supported extensions.
    extensions = new HashSet<String>();
    for (String mt : ImageIO.getWriterFormatNames()) {
        extensions.add(mt);
    }
}