Example usage for javax.swing JFileChooser FILES_AND_DIRECTORIES

List of usage examples for javax.swing JFileChooser FILES_AND_DIRECTORIES

Introduction

In this page you can find the example usage for javax.swing JFileChooser FILES_AND_DIRECTORIES.

Prototype

int FILES_AND_DIRECTORIES

To view the source code for javax.swing JFileChooser FILES_AND_DIRECTORIES.

Click Source Link

Document

Instruction to display both files and directories.

Usage

From source file:nitf.imagej.NITF_Reader.java

public NITF_Reader() {
    super("NITF Reader");
    Java2.setSystemLookAndFeel();/*w w w  . ja v  a 2  s  .  c  om*/
    fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Open NITF Image(s)...");
    String dir;
    if ((dir = Prefs.get(NITF_READER_DIR, null)) != null)
        fileChooser.setCurrentDirectory(new File(dir));
    fileChooser.setMultiSelectionEnabled(true);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setAcceptAllFileFilterUsed(true);
    fileFilter = new FileFilter() {
        public boolean accept(File f) {
            String name = f.getName().toLowerCase().trim();
            return f.isDirectory()
                    || ((name.endsWith("ntf") || name.endsWith("nitf") || name.endsWith("nsf")) && f.canRead());
        }

        public String getDescription() {
            return "NITF Images (*.nitf,*.ntf, *.nsif)";
        }
    };
    fileChooser.setFileFilter(fileFilter);
}

From source file:nz.co.fortytwo.freeboard.installer.InstalManager.java

private void addWidgets() {

    JTabbedPane tabPane = new JTabbedPane();
    this.add(tabPane, BorderLayout.CENTER);
    // upload to arduinos
    JPanel uploadPanel = new JPanel();
    uploadPanel.setLayout(new BorderLayout());
    uploadPanel.add(uploadingPanel, BorderLayout.CENTER);
    final JPanel westUploadPanel = new JPanel(new MigLayout());

    String info = "\nUse this panel to upload compiled code to the arduino devices.\n\n"
            + "NOTE: directories with spaces will probably not work!\n\n"
            + "First select the base directory of your Arduino IDE installation, eg C:/devtools/arduino-1.5.2\n\n"
            + "Then select target files to upload, these are ended in '.hex'\n"
            + "\nand can be downloaded from github (https://github.com/rob42),\n"
            + " see the 'Release*' sub-directories\n\n"
            + "Output of the process will display in the right-side window\n\n";
    JTextArea jTextInfo = new JTextArea(info);
    jTextInfo.setEditable(false);/*from w ww.  ja  va 2  s  .  co  m*/
    westUploadPanel.add(jTextInfo, "span,wrap");

    westUploadPanel.add(new JLabel("Select Arduino IDE directory:"), "wrap");
    arduinoDirTextField.setEditable(false);
    westUploadPanel.add(arduinoDirTextField, "span 2");
    arduinoIdeChooser.setApproveButtonText("Select");
    arduinoIdeChooser.setAcceptAllFileFilterUsed(false);
    arduinoIdeChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    arduinoIdeChooser.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (JFileChooser.APPROVE_SELECTION.equals(evt.getActionCommand())) {

                toolsDir = new File(arduinoIdeChooser.getSelectedFile(),
                        File.separator + "hardware" + File.separator + "tools" + File.separator);
                if (!toolsDir.exists()) {
                    toolsDir = null;
                    JOptionPane.showMessageDialog(westUploadPanel, "Not a valid Arduino IDE directory");
                    return;
                }
                arduinoDirTextField.setText(arduinoIdeChooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    JButton arduinoDirButton = new JButton("Select");
    arduinoDirButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            arduinoIdeChooser.showDialog(westUploadPanel, "Select");

        }
    });
    westUploadPanel.add(arduinoDirButton, "wrap");

    westUploadPanel.add(new JLabel("Select comm port:"));
    westUploadPanel.add(portComboBox, "wrap");

    westUploadPanel.add(new JLabel("Select device:"), "gap unrelated");
    westUploadPanel.add(deviceComboBox, "wrap");

    hexFileChooser.setApproveButtonText("Upload");
    hexFileChooser.setAcceptAllFileFilterUsed(false);
    hexFileChooser.addChoosableFileFilter(new FileFilter() {
        @Override
        public String getDescription() {
            return "*.hex - Hex file";
        }

        @Override
        public boolean accept(File f) {
            if (f.isDirectory()) {
                return true;
            }
            if (f.getName().toUpperCase().endsWith(".HEX")) {
                return true;
            }
            return false;
        }
    });
    westUploadPanel.add(hexFileChooser, "span, wrap");

    uploadPanel.add(westUploadPanel, BorderLayout.WEST);
    tabPane.addTab("Upload", uploadPanel);

    // charts
    JPanel chartPanel = new JPanel();
    chartPanel.setLayout(new BorderLayout());
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Charts", "tiff", "kap", "KAP", "TIFF", "tif",
            "TIF");
    chartFileChooser.setFileFilter(filter);
    chartFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    chartFileChooser.setMultiSelectionEnabled(true);
    final JPanel chartWestPanel = new JPanel(new MigLayout());
    String info2 = "\nUse this panel to convert charts into the correct format for FreeBoard.\n"
            + "\nYou need to select the charts or directories containing charts, then click 'Process'.\n "
            + "\nThe results will be in a directory with the same name as the chart, and the chart "
            + "\ndirectory will also be compressed into a zip file ready to transfer to your FreeBoard "
            + "\nserver\n" + "\nOutput of the process will display in the right-side window\n\n";
    JTextArea jTextInfo2 = new JTextArea(info2);
    jTextInfo2.setEditable(false);
    chartWestPanel.add(jTextInfo2, "wrap");

    chartFileChooser.setApproveButtonText("Process");
    chartWestPanel.add(chartFileChooser, "span,wrap");

    final JPanel loggingPanel = new JPanel(new MigLayout());
    loggingGroup.add(infoButton);
    loggingGroup.add(debugButton);
    debugButton.setSelected(logger.isDebugEnabled());
    infoButton.setSelected(!logger.isDebugEnabled());
    infoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (infoButton.isSelected()) {
                LogManager.getRootLogger().setLevel(Level.INFO);
            }
        }
    });
    debugButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (debugButton.isSelected()) {
                LogManager.getRootLogger().setLevel(Level.DEBUG);
            }
        }
    });

    loggingPanel.add(new JLabel("Logging Level"));
    loggingPanel.add(infoButton);
    loggingPanel.add(debugButton);
    chartWestPanel.add(loggingPanel, "span,wrap");

    final JPanel transparentPanel = new JPanel(new MigLayout());
    charsetGroup.add(utf8Button);
    charsetGroup.add(iso8859Button);
    iso8859Button.setSelected(logger.isDebugEnabled());
    utf8Button.setSelected(!logger.isDebugEnabled());
    utf8Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (utf8Button.isSelected()) {
                charset = "UTF-8";
            }
        }
    });
    iso8859Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (iso8859Button.isSelected()) {
                charset = "ISO-8859-1";
            }
        }
    });

    transparentPanel.add(new JLabel("KAP Character set:"));
    transparentPanel.add(utf8Button);
    transparentPanel.add(iso8859Button);
    chartWestPanel.add(transparentPanel);

    chartPanel.add(chartWestPanel, BorderLayout.WEST);
    chartPanel.add(processingPanel, BorderLayout.CENTER);
    tabPane.addTab("Charts", chartPanel);

    // IMU calibration
    JPanel calPanel = new JPanel();
    calPanel.setLayout(new BorderLayout());
    JPanel westCalPanel = new JPanel(new MigLayout());
    String info3 = "\nUse this panel to calibrate your ArduIMU.\n"
            + "\nYou should do this as near to the final location as possible,\n"
            + "and like all compasses, as far from wires and magnetic materials \n" + "as possible.\n"
            + "\nSelect your comm port, then click 'Start'.\n "
            + "\nSmoothly and steadily rotate the ArduIMU around all 3 axes (x,y,z)\n"
            + "several times. Then press stop and the calibration will be performed and\n"
            + "uploaded to the ArduIMU\n\n" + "Output of the process will display in the right-side window\n\n";
    JTextArea jTextInfo3 = new JTextArea(info3);
    jTextInfo3.setEditable(false);
    westCalPanel.add(jTextInfo3, "span, wrap");
    westCalPanel.add(new JLabel("Select comm port:"));

    westCalPanel.add(portComboBox1, "wrap");
    JButton startCal = new JButton("Start");
    startCal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            calibrationPanel.process((String) portComboBox.getSelectedItem());
        }
    });
    westCalPanel.add(startCal);
    JButton stopCal = new JButton("Stop");
    stopCal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            calibrationPanel.stopProcess();
        }
    });
    westCalPanel.add(stopCal);

    calPanel.add(westCalPanel, BorderLayout.WEST);
    calPanel.add(calibrationPanel, BorderLayout.CENTER);

    tabPane.addTab("Calibration", calPanel);

}

From source file:ome.formats.importer.gui.FileQueueChooser.java

/**
 * File chooser on the file picker tab of the importer
 * /*www .  j av a2 s  .  c o m*/
 * @param config ImportConfig
 * @param scanReader OmeroWrapper
 */
FileQueueChooser(ImportConfig config, OMEROWrapper scanReader) {

    try {
        JPanel fp = null;
        JToolBar tb = null;

        String refreshIcon = "gfx/recycled12.png";
        refreshBtn = GuiCommonElements.addBasicButton("Refresh ", refreshIcon, null);
        refreshBtn.setActionCommand(REFRESHED);
        refreshBtn.addActionListener(this);
        JPanel panel = new JPanel();

        // Set up the main panel for tPane, quit, and send buttons
        double mainTable[][] = { { 10, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL, 10 }, // columns
                { TableLayout.PREFERRED } }; // rows

        TableLayout tl = new TableLayout(mainTable);
        panel.setLayout(tl);

        // Here's a nice little pieces of test code to find all components
        if (DEBUG) {
            try {
                Component[] components = this.getComponents();
                Component component = null;
                System.err.println("Components: " + components.length);
                for (int i = 0; i < components.length; i++) {
                    component = components[i];
                    System.err.println("Component " + i + " = " + component.getClass());
                }
            } catch (Exception e) {
                log.info("component exception ignore");
            }
        }

        if (laf.contains("AquaLookAndFeel")) {
            //Do Aqua implimentation
            fp = (JPanel) this.getComponent(1);
            fp.setLayout(new BoxLayout(fp, BoxLayout.X_AXIS));
            fp.add(refreshBtn);
        } else if (laf.contains("QuaquaLookAndFeel")) {
            //do Quaqua implimentation
            fp = (JPanel) this.getComponent(1);
            panel.add(refreshBtn, "1,0,C,C");
            panel.add(fp.getComponent(0), "2,0,C,C");
            fp.add(panel, BorderLayout.NORTH);
        } else if (laf.contains("Windows")) {
            try {
                //Do windows implimentation
                tb = (JToolBar) this.getComponent(1);
                refreshBtn.setToolTipText("Refresh");
                refreshBtn.setText(null);
                tb.add(refreshBtn, 8);
            } catch (Exception e) {
                log.info("Exception ignored.");
            }
        }
        /* Disabled temporarily */
        else if (laf.contains("MetalLookAndFeel")) {
            //Do Metal implimentation
            JPanel prefp = (JPanel) this.getComponent(0);
            fp = (JPanel) prefp.getComponent(0);
            refreshBtn.setToolTipText("Refresh");
            refreshBtn.setText(null);
            Dimension size = new Dimension(24, 24);
            refreshBtn.setMaximumSize(size);
            refreshBtn.setPreferredSize(size);
            refreshBtn.setMinimumSize(size);
            refreshBtn.setSize(size);
            fp.add(Box.createRigidArea(new Dimension(5, 0)));
            fp.add(refreshBtn);
        }

        else if (laf.contains("GTKLookAndFeel")) {
            //do GTK implimentation
            fp = (JPanel) this.getComponent(0);
            refreshBtn.setIcon(null);
            fp.add(refreshBtn);
        } else if (laf.contains("MotifLookAndFeel")) {
            //do Motif implimentation
            fp = (JPanel) this.getComponent(0);
            fp.add(refreshBtn);
        }

        if (fp != null && DEBUG == true) {
            fp.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                    fp.getBorder()));
            System.err.println(fp.getLayout());
        }

        if (tb != null && DEBUG == true) {
            tb.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                    tb.getBorder()));
            System.err.println(tb.getLayout());
        }
    } catch (ArrayIndexOutOfBoundsException e) {
    }

    File dir = null;
    if (config != null)
        dir = config.savedDirectory.get();

    if (dir != null) {
        this.setCurrentDirectory(dir);
    } else {
        this.setCurrentDirectory(this.getFileSystemView().getHomeDirectory());
    }

    this.setControlButtonsAreShown(false);
    this.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    this.setMultiSelectionEnabled(true);
    this.setDragEnabled(true);

    setAcceptAllFileFilterUsed(false);

    FileFilter[] originalFF = null;
    int readerFFSize = 0;
    if (scanReader != null) {
        originalFF = loci.formats.gui.GUITools.buildFileFilters(scanReader.getImageReader());
        FileFilter filter;
        List<FileFilter> extensionFilters = new ArrayList<FileFilter>();
        for (int i = 0; i < originalFF.length; i++) {
            filter = originalFF[i];
            if (filter instanceof ComboFileFilter) {
                ComboFileFilter cff = (ComboFileFilter) filter;
                extensionFilters.add(cff);
                extensionFilters.addAll(Arrays.asList(cff.getFilters()));
                break;
            }
        }
        if (extensionFilters != null) {
            originalFF = extensionFilters.toArray(new FileFilter[extensionFilters.size()]);
        }
        readerFFSize = originalFF.length;
    }

    FileFilter[] ff = new FileFilter[readerFFSize + 7];
    ff[0] = new DashFileFilter();
    ff[readerFFSize + 1] = new DashFileFilter();
    ff[readerFFSize + 2] = new R3DNewFileFilter();
    ff[readerFFSize + 3] = new R3DOldFileFilter();
    ff[readerFFSize + 4] = new D3DNewFileFilter();
    ff[readerFFSize + 5] = new D3DOldFileFilter();
    ff[readerFFSize + 6] = new D3DNPrjFileFilter();

    if (originalFF != null)
        System.arraycopy(originalFF, 0, ff, 1, originalFF.length);

    //this.addChoosableFileFilter(new DashFileFilter());

    //FileFilter combo = null;
    for (int i = 0; i < ff.length; i++)
        this.addChoosableFileFilter(ff[i]);
    this.setFileFilter(ff[1]);

    //Retrieve all JLists and JTables from the fileChooser
    fileListObjects = getFileListObjects(this);

    //For now, assume the first list/table found is the correct one
    //(this will need to be adjusted if LAF bugs crop up)
    //Shouldn't break anything since dblclick will just stop working if
    //this changes for some reason
    if (fileListObjects.length > 0 && !laf.contains("Windows")) {
        fileList = fileListObjects[0];
        MouseCommand mc = new MouseCommand();
        fileList.addMouseListener(mc);
    }
}

From source file:org.apache.cayenne.modeler.action.ProjectOpener.java

File newProjectDir(Frame f, String location, FileFilter filter) {
    // configure dialog
    setDialogTitle("Select Project Directory");
    setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    setCurrentDirectory(getDefaultStartDir());

    // preselect current directory
    if (getCurrentDirectory() != null) {
        setSelectedFile(getCurrentDirectory());
    }// w w  w . j a  v a 2 s  . c o m

    // configure filters
    resetChoosableFileFilters();
    // allow users to see directories with cayenne.xml files
    addChoosableFileFilter(filter);

    File selectedDir;

    while (true) {
        int status = showDialog(f, "Select");
        selectedDir = getSelectedFile();
        if (status != JFileChooser.APPROVE_OPTION || selectedDir == null) {
            logObj.info("Save canceled.");
            return null;
        }

        // normalize selection
        logObj.info("Selected: " + selectedDir);
        if (!selectedDir.isDirectory()) {
            selectedDir = getSelectedFile().getParentFile();
        }

        // check for overwrite
        File projectFile = new File(selectedDir, location);
        if (projectFile.exists()) {
            OverwriteDialog dialog = new OverwriteDialog(projectFile, f);
            dialog.show();

            if (dialog.shouldOverwrite()) {
                break;
            } else if (dialog.shouldSelectAnother()) {
                continue;
            } else {
                // canceled
                return null;
            }
        } else {
            break;
        }
    }

    return selectedDir;
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java

/**
 * Event handler for this application, handles all menu items.
 *//*from  ww w  .j  a v  a 2s. co  m*/
public void actionPerformed(ActionEvent event) {
    // Service Menu Events
    if ("LoginEvent".equals(event.getActionCommand())) {
        loginEvent(null);
    } else if ("LogoutEvent".equals(event.getActionCommand())) {
        logoutEvent();
    } else if (event.getActionCommand() != null && event.getActionCommand().startsWith("LoginSwitch")) {
        String loginName = event.getActionCommand().substring("LoginSwitch:".length());
        AWSCredentials awsCredentials = (AWSCredentials) loginAwsCredentialsMap.get(loginName);
        loginEvent(awsCredentials);
    } else if ("QuitEvent".equals(event.getActionCommand())) {
        System.exit(0);
    }

    // Bucket Events.
    else if ("ViewBucketProperties".equals(event.getActionCommand())) {
        listBucketProperties();
    } else if ("RefreshBuckets".equals(event.getActionCommand())) {
        listAllBuckets();
    } else if ("CreateBucket".equals(event.getActionCommand())) {
        createBucketAction();
    } else if ("DeleteBucket".equals(event.getActionCommand())) {
        deleteSelectedBucket();
    } else if ("ManageDistributions".equals(event.getActionCommand())) {
        S3Bucket[] buckets = bucketTableModel.getBuckets();
        String[] bucketNames = new String[buckets.length];
        for (int i = 0; i < buckets.length; i++) {
            bucketNames[i] = buckets[i].getName();
        }
        ManageDistributionsDialog.showDialog(ownerFrame, cloudFrontService, bucketNames, this);
    } else if ("AddThirdPartyBucket".equals(event.getActionCommand())) {
        addThirdPartyBucket();
    } else if ("UpdateBucketACL".equals(event.getActionCommand())) {
        updateBucketAccessControlList();
    } else if ("UpdateBucketRequesterPaysStatus".equals(event.getActionCommand())) {
        updateBucketRequesterPaysSetting();
    }

    // Object Events
    else if ("ViewOrModifyObjectAttributes".equals(event.getActionCommand())) {
        displayObjectsAttributesDialog();
    } else if ("CopyObjects".equals(event.getActionCommand())) {
        copyObjects();
    } else if ("RefreshObjects".equals(event.getActionCommand())) {
        listObjects();
    } else if ("UpdateObjectACL".equals(event.getActionCommand())) {
        displayAclModificationDialog();
    } else if ("GeneratePublicGetURLs".equals(event.getActionCommand())) {
        generatePublicGetUrls();
    } else if ("GenerateTorrentURL".equals(event.getActionCommand())) {
        generateTorrentUrl();
    } else if ("DeleteObjects".equals(event.getActionCommand())) {
        deleteSelectedObjects();
    } else if ("DownloadObjects".equals(event.getActionCommand())) {
        downloadSelectedObjects();
    } else if ("UploadFiles".equals(event.getActionCommand())) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setMultiSelectionEnabled(true);
        fileChooser.setDialogTitle("Choose files to upload");
        fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        fileChooser.setApproveButtonText("Upload files");
        fileChooser.setCurrentDirectory(fileChoosersLastUploadDirectory);

        int returnVal = fileChooser.showOpenDialog(ownerFrame);
        if (returnVal != JFileChooser.APPROVE_OPTION) {
            return;
        }

        final File[] uploadFiles = fileChooser.getSelectedFiles();
        if (uploadFiles.length == 0) {
            return;
        }

        // Save the chosen directory location for next time.
        fileChoosersLastUploadDirectory = uploadFiles[0].getParentFile();

        uploadFiles(uploadFiles);
    } else if (event.getSource().equals(filterObjectsCheckBox)) {
        if (filterObjectsCheckBox.isSelected()) {
            filterObjectsPanel.setVisible(true);
        } else {
            filterObjectsPanel.setVisible(false);
            filterObjectsPrefix.setText("");
            if (filterObjectsDelimiter.getSelectedIndex() != 0) {
                filterObjectsDelimiter.setSelectedIndex(0);
            }
        }
    }

    // Tools events
    else if ("BucketLogging".equals(event.getActionCommand())) {
        S3Bucket[] buckets = bucketTableModel.getBuckets();
        BucketLoggingDialog.showDialog(ownerFrame, s3ServiceMulti.getS3Service(), buckets, this);
    }

    // Preference Events
    else if ("PreferencesDialog".equals(event.getActionCommand())) {
        PreferencesDialog.showDialog(cockpitPreferences, ownerFrame, this);

        // Save a user's preferences if requested, otherwise wipe any existing preferences file.
        File cockpitPreferencesPropertiesFile = new File(cockpitHomeDirectory,
                Constants.COCKPIT_PROPERTIES_FILENAME);
        if (cockpitPreferences.isRememberPreferences()) {
            try {
                Properties properties = cockpitPreferences.toProperties();
                if (!cockpitHomeDirectory.exists()) {
                    cockpitHomeDirectory.mkdir();
                }
                properties.list(new PrintStream(new FileOutputStream(cockpitPreferencesPropertiesFile)));
            } catch (IOException e) {
                String message = "Unable to save your preferences";
                log.error(message, e);
                ErrorDialog.showDialog(ownerFrame, this, message, e);
            }
        } else if (cockpitPreferencesPropertiesFile.exists()) {
            // User elected not to store preferences, delete the existing preferences file.
            cockpitPreferencesPropertiesFile.delete();
        }

        if (cockpitPreferences.isEncryptionPasswordSet()) {
            try {
                encryptionUtil = new EncryptionUtil(cockpitPreferences.getEncryptionPassword(),
                        cockpitPreferences.getEncryptionAlgorithm(), EncryptionUtil.DEFAULT_VERSION);
            } catch (Exception e) {
                String message = "Unable to start encryption utility";
                log.error(message, e);
                ErrorDialog.showDialog(ownerFrame, this, message, e);
            }
        } else {
            encryptionUtil = null;
        }
    }

    // Ooops...
    else {
        log.debug("Unrecognised ActionEvent command '" + event.getActionCommand() + "' in " + event);
    }
}

From source file:org.fhaes.analysis.FHInterval.java

/**
 * Actually perform the analysis./*from   ww  w  . j  ava 2 s . c  o  m*/
 */
@SuppressWarnings("deprecation")
private void doAnalysis() {

    log.debug("INPUT PARAMETERS");
    log.debug("inputFileArray = " + inputFileArray);
    log.debug("analyissType = " + analysisType);
    log.debug("startYear = " + startYear);
    log.debug("endYear = " + endYear);
    log.debug("fireFilterType = " + fireFilterType);
    log.debug("filterValue = " + filterValue);
    log.debug("includeIncomplete = " + includeIncomplete);
    log.debug("alphaLevel = " + alphaLevel);

    boolean highway = true;

    ArrayList<FHX2FileReader> myReader = new ArrayList<FHX2FileReader>();
    Integer minFirstYear = new Integer(9999);
    Integer maxLastYear = new Integer(0);

    String savePath = new String();
    savePath = inputFileArray[0].getAbsolutePath();

    for (int i = 0; i < inputFileArray.length; i++) {
        myReader.add(new FHX2FileReader(inputFileArray[i]));

        /*
         * set the beginning year accounting for the filter
         */
        if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
            // myReader.get(i).makeClimate2d();
            if (startYear == 0 && highway) {
                if (myReader.get(i).getFirstFireYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstFireYear();
                }
            } else if (startYear != 0 && highway) {
                if (myReader.get(i).getFirstYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstYear();
                }
            }
            if (startYear != 0) {
                minFirstYear = startYear;
                // minFirstYear = minFirstYear+1;
            }
        } else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
            // myReader.get(i).makeClimate2dII();
            if (startYear == 0 && highway) {
                if (myReader.get(i).getFirstInjuryYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstInjuryYear();
                }
            } else if (startYear != 0 && highway) {
                if (myReader.get(i).getFirstYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstYear();
                }
            }
            if (startYear != 0) {
                minFirstYear = startYear;
                // minFirstYear = minFirstYear+1;
            }
        } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
            // myReader.get(i).makeClimate2dII();
            if (startYear == 0 && highway) {
                if (myReader.get(i).getFirstIndicatorYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstIndicatorYear();
                }
            } else if (startYear != 0 && highway) {
                if (myReader.get(i).getFirstYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstYear();
                }
            }
            if (startYear != 0) {
                minFirstYear = startYear;
                // minFirstYear = minFirstYear+1;
            }
        } else {
            log.error("Unsupported event type caught");
        }
        /*
         * Set the last year accounting for the filter
         */
        if (myReader.get(i).getLastYear() > maxLastYear) {
            maxLastYear = myReader.get(i).getLastYear();
        }
        if (endYear != 0) {
            maxLastYear = endYear;
        }
    } // end of i loop

    log.debug("the input filelength is " + inputFileArray.length);
    log.debug("The FIRST FIRE YEAR is " + minFirstYear);
    log.debug("The LAST YEAR is " + maxLastYear);
    log.debug("Minimum and Maximum years are " + minFirstYear + " " + maxLastYear);
    /*
     * set the format for the output of the numbers to 2 decimal formats
     */
    DecimalFormat twoPlace = new DecimalFormat("0.00");
    DecimalFormat threePlace = new DecimalFormat("0.000");

    /*
     * Calculate the listYears the common years where the files will be analyzed
     */
    ArrayList<Integer> listYears = new ArrayList<Integer>();
    for (int i = 0; i < maxLastYear - minFirstYear + 1; i++) {
        listYears.add(minFirstYear + i);
    }
    /*
     * create arraylist need for the Interval Analysis
     */

    ArrayList<ArrayList<Integer>> climateMatrixSite = new ArrayList<ArrayList<Integer>>();
    ArrayList<ArrayList<Double>> filterMatrix = new ArrayList<ArrayList<Double>>();
    ArrayList<Integer> climateVector = new ArrayList<Integer>();
    ArrayList<ArrayList<Double>> climateVectorFilter2 = new ArrayList<ArrayList<Double>>();
    // ArrayList<Double> fireintervalspersite = new ArrayList<Double>();
    ArrayList<Integer> climateVectorActualSite = null;
    ArrayList<Double> filterVectorActual = null;
    ArrayList<Integer> climateYear = new ArrayList<Integer>();
    ArrayList<Integer> minSampleFilter = null;
    ArrayList<Double> percentOfRecordingfilter = null;
    Double[] Dfireintervalspersite;
    double[] dfireintervalspersite;
    String[] statsparam = new String[22];
    if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
        statsparam[0] = "Total intervals";
        statsparam[1] = "Mean fire interval";
        statsparam[2] = "Median fire interval";
        statsparam[3] = "Standard deviation";
        statsparam[4] = "Fire frequency";
        statsparam[5] = "Coefficient of variation";
        statsparam[6] = "Skewness";
        statsparam[7] = "Kurtosis";
        statsparam[8] = "Minimum fire interval";
        statsparam[9] = "Maximum fire interval";
        statsparam[10] = "Weibull scale parameter";
        statsparam[11] = "Weibull shape parameter";
        statsparam[12] = "Weibull mean";
        statsparam[13] = "Weibull median";
        statsparam[14] = "Weibull mode";
        statsparam[15] = "Weibull standard deviation";
        statsparam[16] = "Weibull fire frequency";
        statsparam[17] = "Weibull skewness";
        statsparam[18] = "Lower exceedance interval";
        statsparam[19] = "Upper exceedance interval";
        statsparam[20] = "Significantly short interval upper bound";
        statsparam[21] = "Significantly long interval lower bound";
    } else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
        statsparam[0] = "Total intervals";
        statsparam[1] = "Mean indicator interval";
        statsparam[2] = "Median indicator interval";
        statsparam[3] = "Standard deviation";
        statsparam[4] = "Indicator frequency";
        statsparam[5] = "Coefficient of variation";
        statsparam[6] = "Skewness";
        statsparam[7] = "Kurtosis";
        statsparam[8] = "Minimum fire interval";
        statsparam[9] = "Maximum indicator interval";
        statsparam[10] = "Weibull scale parameter";
        statsparam[11] = "Weibull shape parameter";
        statsparam[12] = "Weibull mean";
        statsparam[13] = "Weibull median";
        statsparam[14] = "Weibull mode";
        statsparam[15] = "Weibull standard deviation";
        statsparam[16] = "Weibull indicator frequency";
        statsparam[17] = "Weibull skewness";
        statsparam[18] = "Lower exceedance interval";
        statsparam[19] = "Upper exceedance interval";
        statsparam[20] = "Significantly short interval upper bound";
        statsparam[21] = "Significantly long interval lower bound";
    } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
        statsparam[0] = "Total intervals";
        statsparam[1] = "Mean fire and other indicator interval";
        statsparam[2] = "Median fire and other indicator interval";
        statsparam[3] = "Standard deviation";
        statsparam[4] = "Fire and other indicator frequency";
        statsparam[5] = "Coefficient of variation";
        statsparam[6] = "Skewness";
        statsparam[7] = "Kurtosis";
        statsparam[8] = "Minimum fire and other indicator interval";
        statsparam[9] = "Maximum fire interval";
        statsparam[10] = "Weibull scale parameter";
        statsparam[11] = "Weibull shape parameter";
        statsparam[12] = "Weibull mean";
        statsparam[13] = "Weibull median";
        statsparam[14] = "Weibull mode";
        statsparam[15] = "Weibull standard deviation";
        statsparam[16] = "Weibull indicator frequency";
        statsparam[17] = "Weibull skewness";
        statsparam[18] = "Lower exceedance interval";
        statsparam[19] = "Upper exceedance interval";
        statsparam[20] = "Significantly short interval upper bound";
        statsparam[21] = "Significantly long interval lower bound";
    } else {

        log.error("Unsupported event type caught");
    }

    double[] fixvalt = { 0.999, 0.99, 0.975, 0.95, 0.9, 0.875, 0.8, 0.75, 0.7, 0.667, 0.5, 0.333, 0.3, 0.25,
            0.2, 0.125, 0.1, 0.05, 0.025, 0.01, 0.001 };

    double[][] ExceeProbcomp = new double[fixvalt.length][myReader.size()];
    double[][] ExceeProbsample = new double[fixvalt.length][myReader.size()];
    // log.debug("the size of statsparam is " +
    // statsparam.length);
    double[][] summaryComp = new double[statsparam.length][myReader.size()];
    double[] numberOfintervalscomp = new double[myReader.size()];
    // ArrayList<ArrayList<Integer>>();
    // ArrayList<ArrayList<Integer>> FIyearperSample = new
    // ArrayList<ArrayList<Integer>>();
    ArrayList<Integer> FyearperSampletemp;
    ArrayList<Integer> FIyearperSampletemp;
    // ArrayList<Double> fireintervalspersample = new
    double[] numberOfintervalssamp = new double[myReader.size()];
    double[][] summarySample = new double[statsparam.length][myReader.size()];
    Double[] Dfireintervalspersample;
    double[] dfireintervalspersample;
    /*
     * Set up either of the two filters two create the binary matrix on the case of composite analysis there are two possible filters:
     * Number of fires and percentage of scarred trees.
     */
    Integer firesFilter1 = new Integer(0);
    Double firesFilter2 = new Double(0);
    if (fireFilterType.equals(FireFilterType.NUMBER_OF_EVENTS)) {
        if (filterValue != 1)
            firesFilter1 = filterValue.intValue();
        // log.debug("number of fires is selected is: "+
        // firesFilter1);
    } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_ALL_TREES)) {
        if (filterValue != 1)
            firesFilter2 = filterValue / 100.0;
        // log.debug("percentage of fires is selected is: "+
        // firesFilter2);
    } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_RECORDING)) {
        if (filterValue != 1)
            firesFilter2 = filterValue / 100.0;
        // TODO ELENA TO CHECK
    } else {
        log.error("Unknown FireFilterType");
        return;
    }

    boolean[] enoughIntComp = new boolean[myReader.size()];
    boolean[] enoughIntSamp = new boolean[myReader.size()];
    // NEW FOR ELENA
    log.debug("Sample depth filter type = " + sampleDepthFilterType);
    log.debug("Sample depth value = " + sampleDepthFilterValue);

    // if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_SAMPLES))
    // {
    // // TODO ELENA
    // }
    // else if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_RECORDER_SAMPLES))
    // {
    // // TODO ELENA
    // }
    /*
     * start processing each file individually: The analysis can be done by either tree (by sample/non-binary) or by site
     * (composite/binary). by tree the box selected is: jCheckTree. by site the box selected is:
     */
    for (int i = 0; i < myReader.size(); i++) {
        log.debug("  Starting to Process file : " + myReader.get(i).getName());

        /*
         * get the vector Year containing the vector of year of a given fhx file load it into the array list climateYear.
         */

        climateYear = myReader.get(i).getYearArray();

        // new stuff
        // Create filter based on min number of samples/recorder samples
        int[] depths = null;
        if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_SAMPLES)) {
            depths = myReader.get(i).getSampleDepths();
            log.debug("MIN_NUM_SAMPLES ");
        } else if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_RECORDER_SAMPLES)) {
            depths = myReader.get(i).getRecordingDepths(eventTypeToProcess);
            log.debug(" MIN_NUM_RECORDER_SAMPLES");
        } else {
            log.error("Unknown sample depth filter type.");
            return;
        }
        minSampleFilter = new ArrayList<Integer>();
        for (int ij = 0; ij < listYears.size(); ij++) {
            if (climateYear.indexOf(listYears.get(ij)) == -1) {
                minSampleFilter.add(-1);
            } else {
                // log.debug("the sample depth is "
                // + myReader.get(i).getSampleDepths()[climateYear.indexOf(listYearsComp.get(ij))]);
                minSampleFilter.add(new Integer(depths[climateYear.indexOf(listYears.get(ij))]));
            }
            // log.debug(" " + minSampleFilter.get(ij));
        }

        // end new stuff

        /*
         * get filter matrix for each file.
         * 
         * filters2d matrix composed of the 3 filters number of fires (total capital letter per row) total number of tree (total lower
         * case letter plus bars counting only after a fire) percent of scared trees total fires/total trees
         */

        // climateVectorFilter2 = myReader.get(i).getFilterArrays(eventTypeToProcess);
        /*
         * More new stuff
         */
        if (filterValue != 1) {
            /*
             * get both matrices:
             * 
             * 2. filters2d matrix composed of the 3 filters number of fires (total capital letter per row) total number of tree (total
             * lower case letter plus bars counting only after a fire) percent of scared trees total fires/total trees
             */

            climateVectorFilter2 = myReader.get(i).getFilterArrays(eventTypeToProcess);

            /*
             * if by tree analysis is selected create two matrices (array list) 1. filterMatrix containing the three filter vectors only
             * in between common years (so using the listYearComp array list subset of the years vector) 2. climateMatrix 2 dimensional
             * array list containing binary matrices restricted to the listYear list.
             */
            if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_RECORDING)) {
                percentOfRecordingfilter = new ArrayList<Double>();

                for (int ij = 0; ij < listYears.size(); ij++) {

                    if (climateYear.indexOf(listYears.get(ij)) == -1) {
                        percentOfRecordingfilter.add(-1.0);
                    } else {
                        if (myReader.get(i).getRecordingDepths(eventTypeToProcess)[climateYear
                                .indexOf(listYears.get(ij))] != 0) {
                            percentOfRecordingfilter.add(new Double(
                                    climateVectorFilter2.get(0).get(climateYear.indexOf(listYears.get(ij)))
                                            / myReader.get(i).getRecordingDepths(eventTypeToProcess)[climateYear
                                                    .indexOf(listYears.get(ij))]));
                        } else {
                            percentOfRecordingfilter.add(-99.0);
                        }
                    }
                    log.debug("PERCENTAGE_OF_RECORDING is: " + percentOfRecordingfilter.get(ij));
                }
            } else {
                for (int ik = 0; ik < 3; ik++) {
                    log.debug("filter number is: " + ik);
                    filterVectorActual = new ArrayList<Double>();
                    for (int ij = 0; ij < listYears.size(); ij++) { // log.debug(" climateYear.indexOf(listYearsComp.get(j))" +
                                                                    // climateYear.indexOf(listYearsComp.get(ij)));
                                                                    // if(ik==0){log.debug("number of fires
                                                                    // "+climateVectorFilter2.get(0).get(climateYear.indexOf(listYears.get(ij)))+" year
                                                                    // "+listYearsComp.get(ij));}
                        if (climateYear.indexOf(listYears.get(ij)) == -1) {
                            filterVectorActual.add(-1.0);
                        } else {
                            filterVectorActual.add(new Double(
                                    climateVectorFilter2.get(ik).get(climateYear.indexOf(listYears.get(ij)))));
                        }
                        if (ik == 2) {
                            log.debug("filteperc  " + filterVectorActual.get(ij));
                        }
                    }
                    // log.debug("size of filterVectorActual is : "+filterVectorActual.size());
                    filterMatrix.add(filterVectorActual);
                    // if(ik==0){log.debug("filters is: "+filter);
                }
            } // end of if-else percentageofrecording
              // log.debug("size of the FilterMatrix is" + filterMatrix.size());

        } // end of if filters not equal to 1
        /*
         * end of more new stuff
         */
        /*
         * 
         * 1. Create the filterMatrix containing the tree filter vectors only in between common years (so using the listYearComp array
         * list subset of the years vector)
         */
        // for (int ik = 0; ik < 3; ik++)
        // {
        // filterVectorActual = new ArrayList<Double>();
        // for (int ij = 0; ij < listYears.size(); ij++)
        // {
        // if (climateYear.indexOf(listYears.get(ij)) == -1)
        // {
        // filterVectorActual.add(-1.0);
        // }
        // else
        // {
        // filterVectorActual.add(new Double(climateVectorFilter2.get(ik).get(climateYear.indexOf(listYears.get(ij)))));
        // }

        // }
        /*
         * ArrayList filterMatrix containes the filter matrix for each of the files
         */
        // filterMatrix.add(filterVectorActual);
        // }//end of creating the filter matrix.

        /*
         * get matrix climate binary matrix by site (binary analysis) if Composite is selected.
         */
        // if ((doComposite)&&(!jTextOfFires.getText().equals("1"))){
        if (analysisType.equals(AnalysisType.COMPOSITE)) {
            log.debug("inside the comp");
            // System.out.println("inside the comp " + " working on file "+ myReader.get(i).getName() );

            if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
                climateVector = myReader.get(i).getFireEventsArray();
            } else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
                climateVector = myReader.get(i).getOtherInjuriesArray();
            } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
                climateVector = myReader.get(i).getFiresAndInjuriesArray();
            } else {

                log.error("Unsupported event type caught");
            }

            climateVectorActualSite = new ArrayList<Integer>();

            for (int j = 0; j < listYears.size(); j++) {

                if (climateYear.indexOf(listYears.get(j)) == -1) {
                    climateVectorActualSite.add(-1);
                } else {
                    if (minSampleFilter.get(j).intValue() >= sampleDepthFilterValue.intValue()) {
                        if (filterValue != 1) {
                            if (fireFilterType.equals(FireFilterType.NUMBER_OF_EVENTS)) {
                                // log.debug("fire filter: "+firesFilter1+" year is: "+listYears.get(j)
                                // +" fires: "+filterMatrix.get(3*i).get(j)+" climatevector:
                                // "+climateVector.get(climateYear.indexOf(listYears.get(j))));
                                if ((filterMatrix.get(3 * i).get(j) < firesFilter1)
                                        && (climateVector.get(climateYear.indexOf(listYears.get(j)))) != -1.0) {
                                    climateVectorActualSite.add(0);
                                } else {
                                    climateVectorActualSite
                                            .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                                }
                            } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_ALL_TREES)) {
                                // log.debug("percent of fires is selected is: "+
                                // firesFilter2+" "+climateVector.get(climateYear.indexOf(listYearsComp.get(j))));
                                // log.debug("the filter percent of fires is"+filterMatrix.get((3*i+2)).get(j));
                                if ((filterMatrix.get(3 * i + 2).get(j) == -99)) {
                                    climateVectorActualSite.add(-1);
                                } else {
                                    if ((filterMatrix.get(3 * i + 2).get(j) < firesFilter2) && ((climateVector
                                            .get(climateYear.indexOf(listYears.get(j)))) != -1.0)) {
                                        climateVectorActualSite.add(0);
                                    } else {
                                        climateVectorActualSite
                                                .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                                    }
                                }
                            } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_RECORDING)) {

                                // TODO
                                // ELENA TO IMPLEMENT
                                if (percentOfRecordingfilter.get(j) == -99) {
                                    climateVectorActualSite.add(-1);
                                } else {
                                    if ((percentOfRecordingfilter.get(j) < firesFilter2) && ((climateVector
                                            .get(climateYear.indexOf(listYears.get(j)))) != -1.0)) {
                                        climateVectorActualSite.add(0);
                                    } else {
                                        climateVectorActualSite
                                                .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                                    }
                                }

                            } else {
                                log.error("Unknown FireFilterType");
                                return;
                            }

                        } // end of if filter not equal to 1
                        else {
                            climateVectorActualSite
                                    .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                        } // end of else of if filter not equal to 1
                    } // end of if the filter minsampedepth
                    else {
                        // log.debug("j is " + j + "minSampleFilter is " + minSampleFilter.get(j));
                        climateVectorActualSite.add(-1);

                    }
                } // end else 645 to 721
            } // end of j loop listyears (420-459)
            /*
             * climateMatrixSite has the composite information taking in consideration both the filters and common years
             */
            climateMatrixSite.add(climateVectorActualSite);

            /*
             * Must get the years with Fires from the climateMatrixSite which has been filter already
             */
            ArrayList<Double> fireintervalspersite = new ArrayList<Double>();
            ArrayList<Integer> yearsWithFires = new ArrayList<Integer>();
            for (int ij = 0; ij < listYears.size(); ij++) {
                if (climateMatrixSite.get(i).get(ij) == 1) {
                    yearsWithFires.add(listYears.get(ij));
                    log.debug("year with fires " + listYears.get(ij));
                }
            }

            /*
             * check that the number of years with fires is bigger of equal than 3 if so make the fire intervals else the test can not
             * be run and report NA
             */
            // new swich
            if (yearsWithFires.size() != 0) {
                if (includeIncomplete) {
                    if (maxLastYear.compareTo(yearsWithFires.get(yearsWithFires.size() - 1)) != 0) {
                        log.debug("here");
                        numberOfintervalscomp[i] = yearsWithFires.size();
                    } else {
                        numberOfintervalscomp[i] = yearsWithFires.size() - 1;
                    }
                } else {
                    numberOfintervalscomp[i] = yearsWithFires.size() - 1;
                }
            }
            log.debug("number of invervlas in comp is: " + numberOfintervalscomp[i]);
            // end of new switch
            if (numberOfintervalscomp[i] >= 3) {
                enoughIntComp[i] = true;
                ArrayList<Integer> fireIntervals = generateFireIntervals(yearsWithFires);
                for (int ij = 0; ij < fireIntervals.size(); ij++) {
                    // log.debug("fire intervals are: "+
                    // test1.getFireIntervals().get(ij));
                    fireintervalspersite.add(fireIntervals.get(ij) * 1.0);
                }

                /*
                 * Add extra interval if include incomplete is selected. the interval goes from the last fire scar year to the last year
                 * of the fire history.
                 */
                if (includeIncomplete) {
                    double includeinterval = maxLastYear - yearsWithFires.get(yearsWithFires.size() - 1);
                    if (includeinterval > 0) {
                        fireintervalspersite.add(includeinterval);
                        System.out.println("the last year is " + maxLastYear + "the last year with fire is "
                                + yearsWithFires.get(yearsWithFires.size() - 1));
                        log.debug("the included interval is " + includeinterval);
                    }
                }
                log.debug("FireintervalsPerSite =" + fireintervalspersite);
                /*
                 * Get the normal statistics for the fire intervals add the values to the stats and then call them for the stats
                 */
                DescriptiveStatistics stats = new DescriptiveStatistics();
                Dfireintervalspersite = new Double[fireintervalspersite.size()];
                Dfireintervalspersite = fireintervalspersite.toArray(Dfireintervalspersite);
                dfireintervalspersite = new double[fireintervalspersite.size()];
                // summaryComp = new
                // double[statsparam.length][myReader.size()];
                for (int ik = 0; ik < fireintervalspersite.size(); ik++) {
                    stats.addValue(Dfireintervalspersite[ik].doubleValue());
                    dfireintervalspersite[ik] = Dfireintervalspersite[ik].doubleValue();
                }
                /*
                 * load the Summary Analysis for the Composite fire intervals
                 */
                summaryComp[0][i] = fireintervalspersite.size();
                // double mean = stats.getMean();
                summaryComp[1][i] = stats.getMean();
                // double median =
                // StatUtils.percentile(dfireintervalspersite, 50);
                summaryComp[2][i] = StatUtils.percentile(dfireintervalspersite, 50);
                // double std = stats.getStandardDeviation();
                summaryComp[3][i] = stats.getStandardDeviation();
                // double skew = stats.getSkewness();
                summaryComp[4][i] = 1.0 / summaryComp[1][i];
                summaryComp[5][i] = summaryComp[3][i] / summaryComp[1][i];
                summaryComp[6][i] = stats.getSkewness();
                // double kurt = stats.getKurtosis();
                if (numberOfintervalscomp[i] == 3) {
                    summaryComp[7][i] = -99;
                } else {
                    summaryComp[7][i] = stats.getKurtosis();
                }
                // log.debug("nomean \t\t nostd \t\t nokurt \t noskew \t\t nomedian");
                // log.debug(twoPlace.format(mean)+"\t\t"+twoPlace.format(std)+"\t\t"+twoPlace.format(kurt)+"\t\t"+twoPlace.format(skew)+"\t\t"+twoPlace.format(median));

                Weibull weibull = new Weibull(fireintervalspersite);

                ArrayList<Double> weibullProb = weibull.getWeibullProbability(fireintervalspersite);
                ArrayList<Double> siglonglowbound = new ArrayList<Double>();
                ArrayList<Double> sigshortupbound = new ArrayList<Double>();
                log.debug("the weibull probability of first element is " + weibullProb.get(0));
                log.debug("the index  the size of the interval is " + weibullProb.indexOf(weibullProb.get(0)));
                for (int ij = 0; ij < weibullProb.size() - 1; ij++) {
                    if (weibullProb.get(ij) <= alphaLevel) {
                        siglonglowbound.add(fireintervalspersite.get(ij));

                    }
                    if (weibullProb.get(ij) >= (1 - alphaLevel)) {
                        sigshortupbound.add(fireintervalspersite.get(ij));

                    }

                }

                summaryComp[10][i] = weibull.getScale();
                summaryComp[11][i] = weibull.getShape();
                summaryComp[12][i] = weibull.getMean();
                summaryComp[13][i] = weibull.getMedian();
                summaryComp[14][i] = weibull.getMode();
                summaryComp[15][i] = weibull.getSigma();
                summaryComp[16][i] = 1.0 / summaryComp[13][i];
                summaryComp[17][i] = weibull.getSkew();
                summaryComp[18][i] = weibull.getExceedenceProbability2()[0];
                summaryComp[19][i] = weibull.getExceedenceProbability2()[1];
                Collections.sort(sigshortupbound);
                log.debug("siglonglowbound is " + siglonglowbound);
                try {
                    summaryComp[20][i] = sigshortupbound.get(sigshortupbound.size() - 1);
                } catch (Exception e) {
                    summaryComp[20][i] = Double.NaN;
                }
                Collections.sort(siglonglowbound);

                try {
                    summaryComp[21][i] = siglonglowbound.get(0);
                } catch (Exception e) {
                    summaryComp[21][i] = Double.NaN;
                }
                log.debug("sigshortupbound is " + sigshortupbound);
                Collections.sort(fireintervalspersite);
                summaryComp[8][i] = fireintervalspersite.get(0);
                summaryComp[9][i] = fireintervalspersite.get(fireintervalspersite.size() - 1);
                // log.debug("shape \t\t scale \t\t median ");
                // log.debug(twoPlace.format(test1.Weibull_Parameters(fireintervalspersite)[0])+"\t\t"+twoPlace.format(test1.Weibull_Parameters(fireintervalspersite)[1])+"\t\t"+twoPlace.format(test1.weibull_median(test1.Weibull_Parameters(fireintervalspersite))));
                // log.debug("mean \t\t sigma \t\t mode \t\t skewness");
                // log.debug(twoPlace.format(test1.weibull_mean(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_sigma(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_mode(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_skew(test1.Weibull_Parameters(fireintervalspersite))));
                // log.debug("maxhazard \t\t lei \t\t uei ");
                // log.debug(twoPlace.format(test1.maxhazard_int(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_lowuppexcint(test1.Weibull_Parameters(fireintervalspersite))[0])+"\t\t"+twoPlace.format(test1.weibull_lowuppexcint(test1.Weibull_Parameters(fireintervalspersite))[1]));
                // log.debug("the size of YearWith Fires is "+YearsWithFires.size());
                System.out.println("the size of the prb exdc is " + weibull.getExceedenceProbability().length);
                for (int kk = 0; kk < weibull.getExceedenceProbability().length; kk++) {
                    ExceeProbcomp[kk][i] = weibull.getExceedenceProbability()[kk];
                    // log.debug("file "+i+"Exce probability "+
                    // ExceeProbcomp[kk][i]);
                }
            } // end of if enoughIntComp
            else {
                enoughIntComp[i] = false;
            }
        } // end the if composite is selected
        /*
         * starting the process for the sample mode.
         */
        if (analysisType.equals(AnalysisType.SAMPLE)) {
            log.debug("I am in sample ");

            ArrayList<Double> fireintervalspersample = new ArrayList<Double>();
            FIyearperSampletemp = new ArrayList<Integer>();
            // FyearperSampletemp = new ArrayList<Integer>();
            for (int k = 0; k < myReader.get(i).getNumberOfSeries(); k++) {

                log.debug("Parsing file index " + i + ", series number " + (k + 1));
                FyearperSampletemp = new ArrayList<Integer>();
                // log.debug("the size of the years of the file is:"+
                // myReader.get(i).getYear().size());
                // log.debug("years with fires in sample "+k +
                // "years are ");
                // for (int j = 0; j < myReader.get(i).getYearArray().size(); j++)
                for (int j = 0; j < listYears.size(); j++) {
                    // log.debug("the size climate2d is "+myReader.get(i).getClimate2d().get(k).get(j));
                    if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
                        if (climateYear.indexOf(listYears.get(j)) != -1) {
                            if (myReader.get(i).getClimate2d().get(k)
                                    .get(climateYear.indexOf(listYears.get(j))) == 1) {
                                // FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                                FyearperSampletemp.add(listYears.get(j));
                            }
                        }

                    }
                    // {
                    // if ((myReader.get(i).getClimate2d().get(k).get(j) == 1))
                    // {
                    // / log.debug("I here inside ==1 "+
                    // / j+" "+myReader.get(i).getFirstYear());
                    // / int temp=j+myReader.get(i).getFirstYear();
                    // / log.debug((j+myReader.get(i).getFirstYear()));
                    // /// FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                    // }
                    // }
                    else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
                        if (climateYear.indexOf(listYears.get(j)) != -1) {
                            if (myReader.get(i).getClimate2dII().get(k)
                                    .get(climateYear.indexOf(listYears.get(j))) == 1) {
                                FyearperSampletemp.add(listYears.get(j));
                            }
                        }
                        // if ((myReader.get(i).getClimate2dII().get(k).get(j) == 1))
                        // {
                        // FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                        // }
                    } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
                        if (climateYear.indexOf(listYears.get(j)) != -1) {
                            if (myReader.get(i).getClimate2dIII().get(k)
                                    .get(climateYear.indexOf(listYears.get(j))) == 1) {
                                FyearperSampletemp.add(listYears.get(j));
                            }
                        }
                        // if ((myReader.get(i).getClimate2dIII().get(k).get(j) == 1))
                        // {
                        // FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                        // }
                    } else {

                        log.error("Unsupported event type caught");
                    }

                } // / end of the loop for listYears in common (finish loading the fire year per sample
                log.debug(
                        "series number " + (k + 1) + " FyearperSampletemp.size() " + FyearperSampletemp.size());
                if (FyearperSampletemp.size() != 0) {
                    if (includeIncomplete) {
                        if (maxLastYear.compareTo(FyearperSampletemp.get(FyearperSampletemp.size() - 1)) != 0) {
                            numberOfintervalssamp[i] = numberOfintervalssamp[i] + FyearperSampletemp.size();
                        }
                    } else {
                        numberOfintervalssamp[i] = numberOfintervalssamp[i] + (FyearperSampletemp.size() - 1);
                    }
                }
                log.debug("series number: " + (k + 1) + " number of intervals " + numberOfintervalssamp[i]);
                // new
                if ((FyearperSampletemp.size() == 1) && (includeIncomplete)) {
                    log.debug("last index per sample is " + myReader.get(i).getLastYearIndexPerSample()[k]);
                    log.debug("first year per sample is " + myReader.get(i).getFirstYear());
                    log.debug("maxLastyear is " + maxLastYear);
                    // if (maxLastYear != FyearperSampletemp.get(FyearperSampletemp.size() - 1))
                    if (maxLastYear.compareTo(FyearperSampletemp.get(FyearperSampletemp.size() - 1)) != 0) {
                        log.debug("I am in not equal ");
                        log.debug(
                                "last year in the sample  is " + (myReader.get(i).getLastYearIndexPerSample()[k]
                                        + myReader.get(i).getFirstYear()));
                        log.debug("maxLastyear is " + maxLastYear);
                        log.debug("the last fire year in the sample "
                                + FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                        if (maxLastYear <= (myReader.get(i).getLastYearIndexPerSample()[k]
                                + myReader.get(i).getFirstYear())) {
                            Integer temp = ((maxLastYear)
                                    - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            // int temp1 = maxLastYear.intValue() - FyearperSampletemp.get(FyearperSampletemp.size() - 1).intValue();
                            log.debug("in less than or equal to ");
                            // temp = (maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1);
                            log.debug("the resta temp is " + temp);
                            // FIyearperSampletemp.add(((maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1)));
                            if ((maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1) > 0) {
                                FIyearperSampletemp.add(
                                        (maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                                log.debug("the fire intervals for sample " + k + " is "
                                        + FIyearperSampletemp.get(0));
                            }
                            // FIyearperSampletemp.add(temp);
                            // log.debug("the fire intervals for sample " + k + " is " + FIyearperSampletemp.get(0));
                        } else {
                            log.debug("in else ");
                            FIyearperSampletemp.add((myReader.get(i).getLastYearIndexPerSample()[k]
                                    + myReader.get(i).getFirstYear())
                                    - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            log.debug("fire intervals for sample " + k + " is " + FIyearperSampletemp.get(0));
                        }
                        // FIyearperSampletemp.add((myReader.get(i).getFirstYear() + myReader.get(i).getLastYearIndexPerSample()[k])
                        // - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                    }
                    // log.debug("fire intervals for sample " + k + " is " + FIyearperSampletemp.get(0));
                } // end of if one fire year and includelastyear so we have at least one interval in a given series.
                  // endofnew
                if ((FyearperSampletemp.size() >= 2)) {
                    log.debug("Series number is " + (k + 1));
                    for (int jk = 0; jk < FyearperSampletemp.size() - 1; jk++) {
                        // FIyearperSampletemp.add(FyearperSample.get(k).get(jk+1)
                        // - FyearperSample.get(k).get(jk));
                        log.debug("FyearperSampletemp is " + FyearperSampletemp.get(jk));
                        if ((FyearperSampletemp.get(jk + 1) - FyearperSampletemp.get(jk)) > 0) {
                            FIyearperSampletemp
                                    .add(FyearperSampletemp.get(jk + 1) - FyearperSampletemp.get(jk));
                        }
                        // FIyearperSampletemp.add(FyearperSampletemp.get(jk+1)
                        // - FyearperSampletemp.get(jk));
                        log.debug("fire intervals for sample " + k + " is " + FIyearperSampletemp.get(jk));
                        // fisumtemp= fisumtemp +
                        // FIyearperSampletemp.get(jk).intValue();
                    }
                    if (includeIncomplete) {
                        // if (maxLastYear != FyearperSampletemp.get(FyearperSampletemp.size() - 1))
                        if (maxLastYear.compareTo(FyearperSampletemp.get(FyearperSampletemp.size() - 1)) != 0)
                        // if ((myReader.get(i).getLastYearIndexPerSample()[k] + myReader.get(i).getFirstYear()) != FyearperSampletemp
                        // .get(FyearperSampletemp.size() - 1))
                        {
                            if (maxLastYear <= (myReader.get(i).getLastYearIndexPerSample()[k]
                                    + myReader.get(i).getFirstYear())) {
                                if (((maxLastYear)
                                        - FyearperSampletemp.get(FyearperSampletemp.size() - 1)) > 0) {
                                    FIyearperSampletemp.add(((maxLastYear)
                                            - FyearperSampletemp.get(FyearperSampletemp.size() - 1)));
                                }
                            } else {
                                FIyearperSampletemp.add((myReader.get(i).getLastYearIndexPerSample()[k]
                                        + myReader.get(i).getFirstYear())
                                        - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            }
                            // log.debug("the sample number is "+k+
                            // " the size of the fyearpersampletemp is "+
                            // FyearperSampletemp.size() );
                            // log.debug("the last year per sample is "
                            // + (myReader.get(i).getLastYearIndexPerSample()[k] + myReader.get(i).getFirstYear()));
                            // log.debug(" the last fire year per sample " + FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            // FIyearperSampletemp.add((maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            // log.debug("the last intrval in included is on is   "
                            // + FIyearperSampletemp.get(FIyearperSampletemp.size() - 1));
                        }
                    }
                } // end of if at least 2 fier years so we have at least one interval in a given series.
                log.debug("size of FIyearperSampletemp " + FIyearperSampletemp.size() + "  at series is :"
                        + (k + 1));
                // FIyearperSampletemp.size()+
                // " X "+FIyearperSampletemp.get(0).size());

            } // end of the loop for number of series.
              // log.debug("size of FIyearperSample "+
              // FIyearperSampletemp.size());
            for (int j = 0; j < FIyearperSampletemp.size(); j++) {
                fireintervalspersample.add(FIyearperSampletemp.get(j) * 1.0);
            }
            /*
             * Get the normal statistics for the fire intervals add the values to the stats and then call them for the stats
             */
            if (fireintervalspersample.size() >= 3) {
                enoughIntSamp[i] = true;
                DescriptiveStatistics stasample = new DescriptiveStatistics();
                Dfireintervalspersample = new Double[fireintervalspersample.size()];
                Dfireintervalspersample = fireintervalspersample.toArray(Dfireintervalspersample);
                dfireintervalspersample = new double[fireintervalspersample.size()];
                // summarySample = new
                // double[statsparam.length][myReader.size()];
                for (int ik = 0; ik < fireintervalspersample.size(); ik++) {
                    stasample.addValue(Dfireintervalspersample[ik].doubleValue());
                    dfireintervalspersample[ik] = Dfireintervalspersample[ik].doubleValue();
                    log.debug("the " + ik + " fire interval is " + dfireintervalspersample[ik]);
                }
                log.debug("the size for dfireintervalspersample is " + dfireintervalspersample.length);

                // ADDED BY PETE
                if (dfireintervalspersample.length == 0)
                    continue;

                /*
                 * load the Summary Analysis for the Sample fire intervals
                 */
                summarySample[0][i] = fireintervalspersample.size();
                // double mean = stats.getMean();
                summarySample[1][i] = stasample.getMean();
                log.debug("mean sample is " + stasample.getMean());
                // double median =
                // StatUtils.percentile(dfireintervalspersite, 50);
                summarySample[2][i] = StatUtils.percentile(dfireintervalspersample, 50);
                log.debug("summarySample[2][] " + i + " " + summarySample[2][i]);
                // double std = stats.getStandardDeviation();
                summarySample[3][i] = stasample.getStandardDeviation();
                log.debug("summarySample[3][] " + i + " " + summarySample[3][i]);
                // double skew = stats.getSkewness();
                summarySample[4][i] = 1.0 / summarySample[1][i];
                log.debug("summarySample[4][] " + i + " " + summarySample[4][i]);
                summarySample[5][i] = summarySample[3][i] / summarySample[1][i];
                log.debug("summarySample[5][] " + i + " " + summarySample[5][i]);
                summarySample[6][i] = stasample.getSkewness();
                log.debug("summarySample[6][] " + i + " " + summarySample[6][i]);
                // double kurt = stats.getKurtosis();
                if (numberOfintervalssamp[i] == 3) {
                    summarySample[7][i] = -99;
                } else {
                    summarySample[7][i] = stasample.getKurtosis();
                }
                // summarySample[7][i] = stasample.getKurtosis();
                log.debug("summarySample[7][] " + i + " " + summarySample[7][i]);
                // log.debug("nomean \t\t nostd \t\t nokurt \t noskew \t\t nomedian");
                // log.debug(twoPlace.format(mean)+"\t\t"+twoPlace.format(std)+"\t\t"+twoPlace.format(kurt)+"\t\t"+twoPlace.format(skew)+"\t\t"+twoPlace.format(median));

                Weibull weibull = new Weibull(fireintervalspersample);

                //
                ArrayList<Double> weibullProb = weibull.getWeibullProbability(fireintervalspersample);
                ArrayList<Double> siglonglowbound = new ArrayList<Double>();
                ArrayList<Double> sigshortupbound = new ArrayList<Double>();
                log.debug("the weibull probability of first element is " + weibullProb.get(0));
                log.debug("the index  the size of the interval is " + weibullProb.indexOf(weibullProb.get(0)));
                for (int ij = 0; ij < weibullProb.size() - 1; ij++) {
                    if (weibullProb.get(ij) <= alphaLevel) {
                        siglonglowbound.add(fireintervalspersample.get(ij));

                    }
                    if (weibullProb.get(ij) >= (1 - alphaLevel)) {
                        sigshortupbound.add(fireintervalspersample.get(ij));

                    }

                }

                //

                summarySample[10][i] = weibull.getScale();
                log.debug("summarySample[10][] " + i + " " + summarySample[10][i]);
                summarySample[11][i] = weibull.getShape();
                log.debug("summarySample[11][] " + i + " " + summarySample[11][i]);
                summarySample[12][i] = weibull.getMean();
                summarySample[13][i] = weibull.getMedian();
                summarySample[14][i] = weibull.getMode();
                summarySample[15][i] = weibull.getSigma();
                summarySample[16][i] = 1.0 / summarySample[13][i];
                summarySample[17][i] = weibull.getSkew();
                summarySample[18][i] = weibull.getExceedenceProbability2()[0];
                summarySample[19][i] = weibull.getExceedenceProbability2()[1];
                Collections.sort(sigshortupbound);
                log.debug("siglonglowbound is " + siglonglowbound);
                try {
                    summarySample[20][i] = sigshortupbound.get(sigshortupbound.size() - 1);
                } catch (Exception e) {
                    summarySample[20][i] = Double.NaN;
                }
                Collections.sort(siglonglowbound);

                try {
                    summarySample[21][i] = siglonglowbound.get(0);
                } catch (Exception e) {
                    summarySample[21][i] = Double.NaN;
                }
                log.debug("sigshortupbound is " + sigshortupbound);

                Collections.sort(fireintervalspersample);

                try {
                    summarySample[8][i] = fireintervalspersample.get(0);
                } catch (Exception ex) {
                    log.error("Index out of bounds exception caught: ");
                    log.error("    summarySample[8][i] = fireintervalspersample.get(0)");
                    ex.printStackTrace();
                }
                summarySample[9][i] = fireintervalspersample.get(fireintervalspersample.size() - 1);
                // log.debug("shape \t\t scale \t\t median ");
                // log.debug(twoPlace.format(test2.Weibull_Parameters(fireintervalspersample)[0])+"\t\t"+twoPlace.format(test2.Weibull_Parameters(fireintervalspersample)[1])+"\t\t"+twoPlace.format(test2.weibull_median(test1.Weibull_Parameters(fireintervalspersample))));
                // log.debug("mean \t\t sigma \t\t mode \t\t skewness");
                // log.debug(twoPlace.format(test1.weibull_mean(test2.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test1.weibull_sigma(test2.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test2.weibull_mode(test1.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test1.weibull_skew(test2.Weibull_Parameters(fireintervalspersample))));
                // log.debug("maxhazard \t\t lei \t\t uei ");
                // log.debug(twoPlace.format(test2.maxhazard_int(test2.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test2.weibull_lowuppexcint(test2.Weibull_Parameters(fireintervalspersample))[0])+"\t\t"+twoPlace.format(test2.weibull_lowuppexcint(test2.Weibull_Parameters(fireintervalspersample))[1]));
                // log.debug("the size of YearWith Fires is "+YearsWithFires.size());
                // log.debug("the size of the prb exdc is
                // "+test2.weibull_Exprob(test2.Weibull_Parameters(fireintervalspersample)).length);
                System.out.println(
                        "the size of the prb exdc sample  is " + weibull.getExceedenceProbability().length);
                for (int kk = 0; kk < weibull.getExceedenceProbability().length; kk++) {
                    ExceeProbsample[kk][i] = weibull.getExceedenceProbability()[kk];
                    log.debug("file " + i + " Exce probability " + ExceeProbsample[kk][i]);
                    // log.debug("the size is "+ExceeProbsample.length);
                }
            } // end of if at least 4 fireintervals
            else {
                enoughIntSamp[i] = false;
            }
        } // end of if jRadioSample selected.
          // log.debug("the size of exceeprobsample is "ExceeProbsample.length+" X "+ExceeProbsample[0].length);
    } // end of i readering each file loop do loop (354-1185)
    /*
     * 
     */
    // log.debug("size of the climateMatrixSite is "+climateMatrixSite.size()+" X "+climateMatrixSite.get(0).size());
    // for (int j = 0; j < listYears.size(); j++){
    // log.debug(climateMatrixSite.get(0).get(j) + " " +
    // listYears.get(j));
    // }
    // setCursor(Cursor.getDefaultCursor());
    /*
     * create JFileChooser object to generate a browsing capabilities
     */
    JFileChooser fileBrowse = new JFileChooser();

    fileBrowse = new JFileChooser(savePath.substring(0, savePath.lastIndexOf(File.separator)));
    /*
     * set multiselect on (even though we don't need it)
     */
    fileBrowse.setMultiSelectionEnabled(true);
    /*
     * set file and folder directive
     */
    fileBrowse.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    /*
     * set file type: coma delimited file csv
     */
    //
    FileFilter filter1 = new CSVFileFilter();
    fileBrowse.setFileFilter(filter1);
    /*
     * set dialog text: select the name and location of the matrix files
     */
    fileBrowse.setDialogTitle("Select the name and location of the Stats Summary file:");

    /*
     * create the writer object for each of the files to be created
     */
    Writer wr;
    Writer wrWDE;
    Writer wrSample;
    Writer wrWDESample;
    /*
     * set delimiter in this case we are using comas ","
     */
    String delim = ",";

    /*
     * Start writing information into the files
     */
    try {
        if (analysisType.equals(AnalysisType.COMPOSITE)) {
            wr = new BufferedWriter(new FileWriter(summaryFile));
            wrWDE = new BufferedWriter(new FileWriter(exceedenceFile));
            /*
             * write the heading to the files
             */
            String buffer = "";

            buffer = buffer + "Composite Parameters" + delim;
            for (int i = 0; i < inputFileArray.length; i++) {
                buffer = buffer + inputFileArray[i].getLabel() + delim;
            }
            ;
            wr.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));

            buffer = "";
            for (int j = 0; j < statsparam.length; j++) {
                buffer = buffer + statsparam[j] + delim;

                for (int k = 0; k < inputFileArray.length; k++) {
                    if (j == 0) {
                        if (numberOfintervalscomp[k] < 3) {
                            buffer = buffer + twoPlace.format(numberOfintervalscomp[k]) + delim;
                        } else {
                            buffer = buffer + twoPlace.format(summaryComp[0][k]) + delim;
                        }

                    } else {
                        if (enoughIntComp[k]) {
                            if (summaryComp[j][k] == -99) {
                                buffer = buffer + "" + delim;
                            } else {
                                buffer = buffer + twoPlace.format(summaryComp[j][k]) + delim;
                            }
                        } else {
                            buffer = buffer + "" + delim;
                        }
                    }
                } // end of k loop filearray

                wr.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));
                buffer = "";
            } // end of j loop Stats
              // wr.close();
              //
              //
              // wrWDE = new BufferedWriter(new
              // FileWriter(outputWDExceeTable));
              /*
               * write the heading to the files
               */

            buffer = "";
            wrWDE.write("Exceedence Prob" + delim);
            for (int i = 0; i < inputFileArray.length; i++) {
                buffer = buffer + inputFileArray[i].getLabel() + delim;
            }
            wrWDE.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));
            buffer = "";

            for (int j = 0; j < fixvalt.length; j++) {
                buffer = buffer + threePlace.format(fixvalt[j]) + delim;

                for (int k = 0; k < inputFileArray.length; k++) {
                    if (enoughIntComp[k]) {
                        buffer = buffer + twoPlace.format(ExceeProbcomp[j][k]) + delim;
                    } else {
                        buffer = buffer + "" + delim;
                    }
                }
                wrWDE.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));
                buffer = "";
            }

            wr.close();
            wrWDE.close();

        } // end of if jRadioComp is selecte
        if (analysisType.equals(AnalysisType.SAMPLE)) {
            wrSample = new BufferedWriter(new FileWriter(summaryFile));
            wrWDESample = new BufferedWriter(new FileWriter(exceedenceFile));
            /*
             * write the heading to the files
             */
            wrSample.write("Sample Parameters" + delim);
            for (int i = 0; i < inputFileArray.length; i++) {
                wrSample.write(inputFileArray[i].getLabel() + delim);
            }
            wrSample.write(System.getProperty("line.separator"));
            for (int j = 0; j < statsparam.length; j++) {
                wrSample.write(statsparam[j] + delim);
                for (int k = 0; k < inputFileArray.length; k++) {
                    if (j == 0) {
                        if (numberOfintervalssamp[k] < 3) {
                            wrSample.write(twoPlace.format(numberOfintervalssamp[k]) + delim);
                        } else {
                            wrSample.write(twoPlace.format(summarySample[0][k]) + delim);
                        }

                    } else {
                        if (enoughIntSamp[k]) {
                            if (summarySample[j][k] == -99) {
                                wrSample.write("" + delim);
                            } else {
                                wrSample.write(twoPlace.format(summarySample[j][k]) + delim);
                            }
                        } else {
                            wrSample.write("" + delim);
                        }
                    }
                } // end of k loop file array
                wrSample.write(System.getProperty("line.separator"));
            } // end of loop j loop stats
              // wrSample.close();
              //
              //
              // log.debug("the size is "+fixvalt.length+" X "+inputFile.length);
              // wrWDESample = new BufferedWriter(new
              // FileWriter(outputWDExceeTablesample));
              /*
               * write the heading to the files
               */
            wrWDESample.write("Exceedence Prob" + delim);
            for (int i = 0; i < inputFileArray.length; i++) {
                wrWDESample.write(inputFileArray[i].getLabel() + delim);
            }
            wrWDESample.write(System.getProperty("line.separator"));
            for (int j = 0; j < fixvalt.length; j++) {
                wrWDESample.write(threePlace.format(fixvalt[j]) + delim);
                for (int k = 0; k < inputFileArray.length; k++) {
                    // System.out.print(ExceeProbcomp[j][k]+delim);
                    if (enoughIntSamp[k]) {
                        wrWDESample.write(twoPlace.format(ExceeProbsample[j][k]) + delim);
                    } else {
                        wrWDESample.write("" + delim);
                    }

                }
                // System.out.print(System.getProperty("line.separator"));
                wrWDESample.write(System.getProperty("line.separator"));
            }
            wrSample.close();
            wrWDESample.close();
        } // end of jradiosample

    } // end of Try
    catch (IOException ex) {
        ex.printStackTrace();
    } finally {

    }

}

From source file:org.formic.wizard.form.gui.component.FileChooser.java

/**
 * Creates a new instance.
 */
public FileChooser() {
    this(JFileChooser.FILES_AND_DIRECTORIES, null);
}

From source file:org.jas.controller.MetadataController.java

@ActionMethod(Actions.GET_METADATA)
public void getMetadata() {
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    int selection = fileChooser.showOpenDialog(null);
    if (selection == JFileChooser.APPROVE_OPTION) {
        File root = fileChooser.getSelectedFile();
        log.info("\nDIRECTORY to SCAN: " + root);
        if (root.exists()) {
            configurator.getControlEngine().fireEvent(Events.DIRECTORY_SELECTED,
                    new ValueEvent<String>(root.getAbsolutePath()));
            try {
                metadataList = metadataExtractor.extractMetadata(root);
                if (metadataList.isEmpty()) {
                    configurator.getControlEngine().fireEvent(Events.DIRECTORY_EMPTY);
                } else {
                    Collections.sort(metadataList);
                    sendLoadedEvent(metadataList);
                }//from  ww w.j av  a2s . c om
            } catch (IOException e) {
                handleException(e);
            } catch (TagException e) {
                handleException(e);
            } catch (ReadOnlyFileException e) {
                handleException(e);
            } catch (InvalidAudioFrameException e) {
                handleException(e);
            } catch (InvalidId3VersionException e) {
                handleException(e);
            } catch (InterruptedException e) {
                handleException(e);
            } catch (CannotReadException e) {
                handleException(e);
            } catch (MetadataException e) {
                handleException(e);
            } catch (IllegalArgumentException e) {
                sendLoadedEvent(metadataList);
                handleException(e);
            }
        } else {
            configurator.getControlEngine().fireEvent(Events.DIRECTORY_NOT_EXIST,
                    new ValueEvent<String>(root.toString()));
        }
    } else {
        configurator.getControlEngine().fireEvent(Events.DIRECTORY_SELECTED_CANCEL);
    }
}

From source file:org.javaswift.cloudie.CloudiePanel.java

protected void onDownloadStoredObject() {
    Container container = getSelectedContainer();
    List<StoredObject> obj = getSelectedStoredObjects();
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(lastFolder);
    if (obj.size() == 1) {
        chooser.setSelectedFile(new File(obj.get(0).getName()));
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    } else {/* ww  w  . ja  v a  2s.co  m*/
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    }
    if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
        File selected = chooser.getSelectedFile();
        for (StoredObject so : obj) {
            File target = selected;
            if (target.isDirectory()) {
                target = new File(selected, so.getName());
            }
            if (target.exists()) {
                if (confirm("File '" + target.getName() + "' already exists. Overwrite?")) {
                    doSaveStoredObject(target, container, so);
                }
            } else {
                doSaveStoredObject(target, container, so);
            }
        }
        lastFolder = selected.isFile() ? selected.getParentFile() : selected;
    }

}

From source file:org.jets3t.apps.cockpitlite.CockpitLite.java

/**
 * Event handler for this application, handles all menu items.
 *//*from   ww  w. j av  a2 s .c  om*/
public void actionPerformed(ActionEvent event) {
    if (event.getSource().equals(loginButton)) {
        new Thread() {
            @Override
            public void run() {
                listObjects();
            }
        }.start();
    }

    // Object Events
    else if ("ViewObjectProperties".equals(event.getActionCommand())) {
        listObjectProperties();
    } else if ("RefreshObjects".equals(event.getActionCommand())) {
        new Thread() {
            @Override
            public void run() {
                listObjects();
            }
        }.start();
    } else if ("TogglePublicPrivate".equals(event.getActionCommand())) {
        new Thread() {
            @Override
            public void run() {
                S3Object object = getSelectedObjects()[0];
                String aclStatus = objectTableModel.getObjectAclStatus(object);
                boolean originalAclWasPublic = ACL_PUBLIC_DESCRIPTION.equals(aclStatus);

                ToggleAclDialog dialog = new ToggleAclDialog(ownerFrame, originalAclWasPublic, null,
                        cockpitLiteProperties.getProperties());
                dialog.setVisible(true);

                // Update ACL setting.
                S3Object minimalObject = new S3Object(object.getKey());

                AccessControlList newAcl = (dialog.isPublicAclSet() ? AccessControlList.REST_CANNED_PUBLIC_READ
                        : AccessControlList.REST_CANNED_PRIVATE);

                if (newAcl != null) {
                    if (AccessControlList.REST_CANNED_PRIVATE.equals(newAcl)) {
                        minimalObject.addMetadata(Constants.REST_HEADER_PREFIX + "acl", "private");
                    } else if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(newAcl)) {
                        minimalObject.addMetadata(Constants.REST_HEADER_PREFIX + "acl", "public-read");
                    }
                }

                updateObjectsAccessControlLists(new S3Object[] { minimalObject }, newAcl);

                dialog.dispose();
            }
        }.start();
    } else if ("GeneratePublicGetURL".equals(event.getActionCommand())) {
        generatePublicGetUrl();
    } else if ("DeleteObjects".equals(event.getActionCommand())) {
        deleteSelectedObjects();
    } else if ("DownloadObjects".equals(event.getActionCommand())) {
        try {
            downloadSelectedObjects();
        } catch (Exception ex) {
            String message = "Unable to download objects from S3";
            log.error(message, ex);
            ErrorDialog.showDialog(ownerFrame, this, cockpitLiteProperties.getProperties(), message, ex);
        }
    } else if ("UploadFiles".equals(event.getActionCommand())) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setMultiSelectionEnabled(true);
        fileChooser.setDialogTitle("Choose file(s) to upload");
        fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        fileChooser.setApproveButtonText("Upload files");
        fileChooser.setCurrentDirectory(fileChoosersLastUploadDirectory);

        int returnVal = fileChooser.showOpenDialog(ownerFrame);
        if (returnVal != JFileChooser.APPROVE_OPTION) {
            return;
        }

        final File[] uploadFiles = fileChooser.getSelectedFiles();
        if (uploadFiles.length == 0) {
            return;
        }

        // Save the chosen directory location for next time.
        fileChoosersLastUploadDirectory = uploadFiles[0].getParentFile();

        new Thread() {
            @Override
            public void run() {
                prepareForFilesUpload(uploadFiles);
            }
        }.start();
    } else if (event.getSource().equals(filterObjectsCheckBox)) {
        if (filterObjectsCheckBox.isSelected()) {
            filterObjectsPanel.setVisible(true);
        } else {
            filterObjectsPanel.setVisible(false);
            filterObjectsPrefix.setText("");
        }
    }

    // Ooops...
    else {
        log.warn("Unrecognised ActionEvent command '" + event.getActionCommand() + "' in " + event);
    }
}