Example usage for javax.swing JCheckBox JCheckBox

List of usage examples for javax.swing JCheckBox JCheckBox

Introduction

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

Prototype

public JCheckBox(Action a) 

Source Link

Document

Creates a check box where properties are taken from the Action supplied.

Usage

From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java

private JCheckBox getAllSolenoidValveCheckBox() {
    if (allSolenoidValvesCheckbox == null) {
        allSolenoidValvesCheckbox = new JCheckBox(Messages.getString("OptionsDialog.6")); //$NON-NLS-1$

        allSolenoidValvesCheckbox.addActionListener(new ActionListener() {

            @Override//from www. ja va  2s.  co  m
            public void actionPerformed(ActionEvent e) {
                selectAllCheckBox();
            }
        });
    }
    return allSolenoidValvesCheckbox;
}

From source file:TexBug.java

JPanel texture2DPanel() {

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 0)); // horizontal

    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new GridLayout(0, 1)); // vertical
    panel.add(leftPanel);//from w ww .j  ava2  s. co m

    JPanel rightPanel = new JPanel();
    rightPanel.setLayout(new GridLayout(0, 1)); // vertical
    panel.add(rightPanel);

    texEnableCheckBox = new JCheckBox(texEnableString);

    // set up the action commands
    texEnableCheckBox.setActionCommand(texEnableString);

    // register the applet as the listener for the buttons
    texEnableCheckBox.addActionListener(this);

    // set the initial value
    texEnableCheckBox.setSelected(texEnable);

    // add the checkbox to the panel
    leftPanel.add(texEnableCheckBox);

    // texture boundary S
    leftPanel.add(new JLabel("Boundary S Mode:"));

    // create the buttons
    JRadioButton texBoundarySWrapButton = new JRadioButton(wrapString);
    JRadioButton texBoundarySClampButton = new JRadioButton(clampString);

    // set up the action commands
    texBoundarySWrapButton.setActionCommand(texBoundarySWrapString);
    texBoundarySClampButton.setActionCommand(texBoundarySClampString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup boundSButtonGroup = new ButtonGroup();
    boundSButtonGroup.add(texBoundarySWrapButton);
    boundSButtonGroup.add(texBoundarySClampButton);

    // register the applet as the listener for the buttons
    texBoundarySWrapButton.addActionListener(this);
    texBoundarySClampButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texBoundarySWrapButton);
    leftPanel.add(texBoundarySClampButton);

    // set the default
    texBoundarySWrapButton.setSelected(true);

    // texture boundary T
    leftPanel.add(new JLabel("Boundary T Mode:"));

    // create the buttons
    JRadioButton texBoundaryTWrapButton = new JRadioButton(wrapString);
    JRadioButton texBoundaryTClampButton = new JRadioButton(clampString);

    // set up the action commands
    texBoundaryTWrapButton.setActionCommand(texBoundaryTWrapString);
    texBoundaryTClampButton.setActionCommand(texBoundaryTClampString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup boundTButtonGroup = new ButtonGroup();
    boundTButtonGroup.add(texBoundaryTWrapButton);
    boundTButtonGroup.add(texBoundaryTClampButton);

    // register the applet as the listener for the buttons
    texBoundaryTWrapButton.addActionListener(this);
    texBoundaryTClampButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texBoundaryTWrapButton);
    leftPanel.add(texBoundaryTClampButton);

    // set the default
    texBoundaryTWrapButton.setSelected(true);

    // texture min filter
    rightPanel.add(new JLabel("Min Filter:"));

    // create the buttons
    JRadioButton texMinFilterBasePointButton = new JRadioButton(texFilterBasePointString);
    JRadioButton texMinFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString);
    JRadioButton texMinFilterMultiPointButton = new JRadioButton(texFilterMultiPointString);
    JRadioButton texMinFilterMultiLinearButton = new JRadioButton(texFilterMultiLinearString);
    JRadioButton texMinFilterNicestButton = new JRadioButton(nicestString);
    JRadioButton texMinFilterFastestButton = new JRadioButton(fastestString);

    // set up the action commands
    texMinFilterBasePointButton.setActionCommand(texMinFilterBasePointString);
    texMinFilterBaseLinearButton.setActionCommand(texMinFilterBaseLinearString);
    texMinFilterMultiPointButton.setActionCommand(texMinFilterMultiPointString);
    texMinFilterMultiLinearButton.setActionCommand(texMinFilterMultiLinearString);
    texMinFilterNicestButton.setActionCommand(texMinFilterNicestString);
    texMinFilterFastestButton.setActionCommand(texMinFilterFastestString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup minFilterButtonGroup = new ButtonGroup();
    minFilterButtonGroup.add(texMinFilterBasePointButton);
    minFilterButtonGroup.add(texMinFilterBaseLinearButton);
    minFilterButtonGroup.add(texMinFilterMultiPointButton);
    minFilterButtonGroup.add(texMinFilterMultiLinearButton);
    minFilterButtonGroup.add(texMinFilterNicestButton);
    minFilterButtonGroup.add(texMinFilterFastestButton);

    // register the applet as the listener for the buttons
    texMinFilterBasePointButton.addActionListener(this);
    texMinFilterBaseLinearButton.addActionListener(this);
    texMinFilterMultiPointButton.addActionListener(this);
    texMinFilterMultiLinearButton.addActionListener(this);
    texMinFilterNicestButton.addActionListener(this);
    texMinFilterFastestButton.addActionListener(this);

    // add the buttons to the panel
    rightPanel.add(texMinFilterBasePointButton);
    rightPanel.add(texMinFilterBaseLinearButton);
    rightPanel.add(texMinFilterMultiPointButton);
    rightPanel.add(texMinFilterMultiLinearButton);
    rightPanel.add(texMinFilterNicestButton);
    rightPanel.add(texMinFilterFastestButton);

    // set the default
    texMinFilterBasePointButton.setSelected(true);

    // texture max filter
    rightPanel.add(new JLabel("Mag Filter:"));

    // create the buttons
    JRadioButton texMagFilterBasePointButton = new JRadioButton(texFilterBasePointString);
    JRadioButton texMagFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString);
    JRadioButton texMagFilterNicestButton = new JRadioButton(nicestString);
    JRadioButton texMagFilterFastestButton = new JRadioButton(fastestString);

    // set up the action commands
    texMagFilterBasePointButton.setActionCommand(texMagFilterBasePointString);
    texMagFilterBaseLinearButton.setActionCommand(texMagFilterBaseLinearString);
    texMagFilterNicestButton.setActionCommand(texMagFilterNicestString);
    texMagFilterFastestButton.setActionCommand(texMagFilterFastestString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup magFilterButtonGroup = new ButtonGroup();
    magFilterButtonGroup.add(texMagFilterBasePointButton);
    magFilterButtonGroup.add(texMagFilterBaseLinearButton);
    magFilterButtonGroup.add(texMagFilterNicestButton);
    magFilterButtonGroup.add(texMagFilterFastestButton);

    // register the applet as the listener for the buttons
    texMagFilterBasePointButton.addActionListener(this);
    texMagFilterBaseLinearButton.addActionListener(this);
    texMagFilterNicestButton.addActionListener(this);
    texMagFilterFastestButton.addActionListener(this);

    // add the buttons to the panel
    rightPanel.add(texMagFilterBasePointButton);
    rightPanel.add(texMagFilterBaseLinearButton);
    rightPanel.add(texMagFilterNicestButton);
    rightPanel.add(texMagFilterFastestButton);

    // set the default
    texMagFilterBasePointButton.setSelected(true);

    // MipMap Mode
    leftPanel.add(new JLabel("MipMap Mode:"));

    // create the buttons
    JRadioButton texMipMapBaseButton = new JRadioButton(texMipMapBaseString);
    JRadioButton texMipMapMultiButton = new JRadioButton(texMipMapMultiString);

    // set up the action commands
    texMipMapBaseButton.setActionCommand(texMipMapBaseString);
    texMipMapMultiButton.setActionCommand(texMipMapMultiString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup texMipMapButtonGroup = new ButtonGroup();
    texMipMapButtonGroup.add(texMipMapBaseButton);
    texMipMapButtonGroup.add(texMipMapMultiButton);

    // register the applet as the listener for the buttons
    texMipMapBaseButton.addActionListener(this);
    texMipMapMultiButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texMipMapBaseButton);
    leftPanel.add(texMipMapMultiButton);

    // set the default
    texMipMapBaseButton.setSelected(true);

    return panel;

}

From source file:net.sf.taverna.t2.activities.wsdlsir.views.WSDLActivityConfigurationView.java

private void initComponents() {

    this.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);

    int gridy = 0;

    // title panel
    JPanel titlePanel = new JPanel(new BorderLayout());
    titlePanel.setBackground(Color.WHITE);
    JLabel titleLabel = new JLabel("Security configuration");
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
    titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
    DialogTextArea titleMessage = new DialogTextArea("Select a security profile for the service");
    titleMessage.setMargin(new Insets(5, 20, 10, 10));
    titleMessage.setFont(titleMessage.getFont().deriveFont(11f));
    titleMessage.setEditable(false);/* w  w  w. j av  a 2  s. com*/
    titleMessage.setFocusable(false);
    titlePanel.setBorder(new EmptyBorder(10, 10, 0, 10));
    titlePanel.add(titleLabel, BorderLayout.NORTH);
    titlePanel.add(titleMessage, BorderLayout.CENTER);
    addDivider(titlePanel, SwingConstants.BOTTOM, true);

    // Main panel
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));

    //Create the radio buttons
    noSecurityRadioButton = new JRadioButton("None");
    noSecurityRadioButton.addItemListener(this);

    wsSecurityAuthNRadioButton = new JRadioButton("WS-Security username and password authentication");
    wsSecurityAuthNRadioButton.addItemListener(this);

    httpSecurityAuthNRadioButton = new JRadioButton("HTTP username and password authentication");
    httpSecurityAuthNRadioButton.addItemListener(this);

    SAMLSecurityAuthNRadioButton = new JRadioButton("SAML WEB SSO profile authentication");
    SAMLSecurityAuthNRadioButton.addItemListener(this);

    //Group the radio buttons
    buttonGroup = new ButtonGroup();
    buttonGroup.add(noSecurityRadioButton);
    buttonGroup.add(wsSecurityAuthNRadioButton);
    buttonGroup.add(httpSecurityAuthNRadioButton);
    buttonGroup.add(SAMLSecurityAuthNRadioButton);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(noSecurityRadioButton, gbc);

    noSecurityLabel = new JLabel("Service requires no security");
    noSecurityLabel.setFont(noSecurityLabel.getFont().deriveFont(11f));
    //      addDivider(noSecurityLabel, SwingConstants.BOTTOM, false);
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(noSecurityLabel, gbc);

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(httpSecurityAuthNRadioButton, gbc);

    ActionListener usernamePasswordListener = new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            // Get Credential Manager UI to get the username and password for the service
            CredentialManagerUI credManagerUI = CredentialManagerUI.getInstance();
            if (credManagerUI != null)
                credManagerUI.newPasswordForService(oldBean.getWsdl());
        }
    };

    httpSecurityAuthNLabel = new JLabel(
            "Service requires HTTP username and password in order to authenticate the user");
    httpSecurityAuthNLabel.setFont(httpSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(httpSecurityAuthNLabel, gbc);

    // Set username and password button;
    setHttpUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setHttpUsernamePasswordButton, gbc);
    setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener);

    /////SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(SAMLSecurityAuthNRadioButton, gbc);

    ActionListener getCookieListener = new ActionListener() {

        /**
         * This listener will use the CallPreparator to obtain the cookies (included shibsession_XXX cookie) and 
         * save it in the Credential Manager (as the password for user "nomatter")
         */
        public void actionPerformed(ActionEvent e) {
            try {
                WSDLParser parser = new WSDLParser(newBean.getWsdl());
                List<String> endpoints = parser.getOperationEndpointLocations(newBean.getOperation());
                for (String endpoint : endpoints) //Actually i am only expecting one endpoint
                {
                    if (debug)
                        System.out
                                .println("Obtaining a SAML cookies to save in credential manager:" + endpoint);

                    Cookie[] cookies = CallPreparator.createCookieForCallToEndpoint(endpoint);

                    // Uncomment for just the shibsession cookie
                    //                  Cookie[] cookiessession = new Cookie[1];
                    //                  for (Cookie cook : cookies)
                    //                     if (cook.getName().contains("shibsession"))
                    //                        cookiessession[0]=cook;
                    //                  cookies=cookiessession;

                    CredentialManager credman = CredentialManager.getInstance();
                    credman.saveUsernameAndPasswordForService(
                            new UsernamePassword("nomatter", serializetoString(cookies)), new URI(endpoint));
                }
            } catch (WSDLException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (ParserConfigurationException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (Exception ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            }
        }
    };

    SAMLSecurityAuthNLabel = new JLabel("<html>"
            + "Service requires SAML Web SSO profile to be perfomed in order to authenticate the user. "
            + "A cookie will be saved in your Credential Manger. "
            + "In the case that it stops working, please delete the entry in your Credential Manager or re-authenticate"
            + "</html>");
    SAMLSecurityAuthNLabel.setFont(SAMLSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(3, 40, 10, 10);
    mainPanel.add(SAMLSecurityAuthNLabel, gbc);

    // Set username and password button;
    setSAMLGETCookieButton = new JButton("Authenticate and save Authentication data in Credential Manger");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setSAMLGETCookieButton, gbc);
    setSAMLGETCookieButton.addActionListener(getCookieListener);

    //END SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(wsSecurityAuthNRadioButton, gbc);

    wsSecurityAuthNLabel = new JLabel(
            "Service requires WS-Security username and password in order to authenticate the user");
    wsSecurityAuthNLabel.setFont(wsSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 0, 0);
    mainPanel.add(wsSecurityAuthNLabel, gbc);

    // Password type list
    passwordTypeComboBox = new JComboBox(passwordTypes);
    passwordTypeComboBox.setRenderer(new ComboBoxTooltipRenderer());
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(10, 40, 0, 0);
    mainPanel.add(passwordTypeComboBox, gbc);

    // 'Add timestamp' checkbox
    addTimestampCheckBox = new JCheckBox("Add a timestamp to SOAP message");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 40, 10, 10);
    mainPanel.add(addTimestampCheckBox, gbc);

    // Set username and password button;
    setWsdlUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setWsdlUsernamePasswordButton, gbc);
    setWsdlUsernamePasswordButton.addActionListener(usernamePasswordListener);

    addDivider(mainPanel, SwingConstants.BOTTOM, true);

    // OK/Cancel button panel
    JPanel okCancelPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cancelPressed();
        }
    });
    okCancelPanel.add(cancelButton);
    okCancelPanel.add(okButton);

    // Enable/disable controls based on what is the current security profiles
    String securityProfile = oldBean.getSecurityProfile();
    if (securityProfile == null) {
        noSecurityRadioButton.setSelected(true);
    } else {
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            wsSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.HTTP_BASIC_AUTHN)
                || securityProfile.equals(SecurityProfiles.HTTP_DIGEST_AUTHN)) {
            httpSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.SAMLWEBSSOAUTH)) {
            SAMLSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(PLAINTEXT_PASSWORD);
        } else if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(DIGEST_PASSWORD);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            addTimestampCheckBox.setSelected(true);
        } else {
            addTimestampCheckBox.setSelected(false);
        }
    }

    // Put everything together
    JPanel layoutPanel = new JPanel(new BorderLayout());
    layoutPanel.add(titlePanel, BorderLayout.NORTH);
    layoutPanel.add(mainPanel, BorderLayout.CENTER);
    layoutPanel.add(okCancelPanel, BorderLayout.SOUTH);
    layoutPanel.setPreferredSize(new Dimension(550, 490));

    this.getContentPane().add(layoutPanel);
    this.pack();
}

From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java

private JCheckBox getSolenoidValveZeroCheckBox() {
    if (solenoidValveZeroCheckbox == null) {
        solenoidValveZeroCheckbox = new JCheckBox("0.0");

        solenoidValveZeroCheckbox.addActionListener(new ActionListener() {

            @Override/*from  ww w .ja va  2  s. c o  m*/
            public void actionPerformed(ActionEvent e) {
                if (solenoidValveZeroCheckbox.isSelected())
                    solenoidValvesOfInterest.add(Double.valueOf(0.0));
                else
                    solenoidValvesOfInterest.remove(Double.valueOf(0.0));
            }
        });

    }
    return solenoidValveZeroCheckbox;
}

From source file:cellularAutomata.analysis.PricingDistributionAnalysis.java

/**
 * Create the panel used to display the pricing statistics.
 *//*from   w  ww  .  j a  v  a 2 s  .  com*/
private void createDisplayPanel() {
    int displayWidth = CAFrame.tabbedPaneDimension.width;
    int displayHeight = 600 + (100 * numberOfStates);

    // create the display panel
    if (displayPanel == null) {
        displayPanel = new JPanel(new GridBagLayout());
        displayPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        displayPanel.setPreferredSize(new Dimension(displayWidth, displayHeight));
    } else {
        displayPanel.removeAll();
    }

    if (isCompatibleRule && (numberOfStates <= MAX_NUMBER_OF_STATES)) {
        // create a panel that displays messages
        JPanel messagePanel = createMessagePanel();

        // create the labels for the display
        createDataDisplayLabels();
        JLabel generationLabel = new JLabel("Generation:   ");
        JLabel stateLabel = new JLabel("State:");
        JLabel numStateLabel = new JLabel("Number:");
        JLabel percentOccupiedLabel = new JLabel("Kurtosis:");

        // create boxes for each column of the display (a Box uses the
        // BoxLayout, so it is handy for laying out components)
        Box boxOfStateLabels = Box.createVerticalBox();
        Box boxOfNumberLabels = Box.createVerticalBox();
        Box boxOfPercentLabels = Box.createVerticalBox();

        // the amount of vertical space to put between components
        int verticalSpace = 5;

        // add the states to the first vertical box
        boxOfStateLabels.add(stateLabel);
        boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int state = 0; state < numberOfStates; state++) {
            boxOfStateLabels.add(new JLabel("" + state));
            boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // add the numbers (in each state) to the second vertical box
        boxOfNumberLabels.add(numStateLabel);
        boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int i = 0; i < numberOfStates; i++) {
            boxOfNumberLabels.add(numberOccupiedByStateDataLabel[i]);
            boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // add the percents (in each state) to the third vertical box
        boxOfPercentLabels.add(percentOccupiedLabel);
        boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int i = 0; i < numberOfStates; i++) {
            boxOfPercentLabels.add(percentOccupiedByStateDataLabel[i]);
            boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // create another box that holds all of the label boxes
        Box boxOfLabels = Box.createHorizontalBox();
        boxOfLabels.add(boxOfStateLabels);
        boxOfLabels.add(boxOfNumberLabels);
        boxOfLabels.add(boxOfPercentLabels);
        boxOfLabels.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));

        // put the boxOfLabels in a scrollPane -- with many states, will get
        // very large
        JScrollPane stateScroller = new JScrollPane(boxOfLabels);
        int scrollPaneWidth = (int) (displayWidth * 0.8);
        int scrollPaneHeight = displayHeight / 4;
        stateScroller.setPreferredSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setMinimumSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setMaximumSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        // create a "plot zero state" check box
        plotZeroStateCheckBox = new JCheckBox(PLOT_ZERO_STATE);
        plotZeroStateCheckBox.setSelected(true);
        plotZeroStateCheckBox.setToolTipText(PLOT_ZERO_STATE_TOOLTIP);
        plotZeroStateCheckBox.setActionCommand(PLOT_ZERO_STATE);
        plotZeroStateCheckBox.addActionListener(this);
        JPanel plotZeroStatePanel = new JPanel(new BorderLayout());
        plotZeroStatePanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
        plotZeroStatePanel.add(BorderLayout.CENTER, plotZeroStateCheckBox);

        // create a "save data" check box
        saveDataCheckBox = new JCheckBox(SAVE_DATA);
        saveDataCheckBox.setToolTipText(SAVE_DATA_TOOLTIP);
        saveDataCheckBox.setActionCommand(SAVE_DATA);
        saveDataCheckBox.addActionListener(this);
        JPanel saveDataPanel = new JPanel(new BorderLayout());
        saveDataPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
        saveDataPanel.add(BorderLayout.CENTER, saveDataCheckBox);

        // create a panel that plots the data
        plot = new SimplePlot();

        // add all the components to the panel
        int row = 0;
        displayPanel.add(messagePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(plot, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(10.0, 10.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        for (int i = 0; i < numberOfStates; i++) {
            timeSeriesPlot[i] = new SimplePlot();
            displayPanel.add(timeSeriesPlot[i], new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH)
                    .setWeight(10.0, 10.0).setAnchor(GBC.WEST).setInsets(1));

            row++;
        }
        displayPanel.add(plotZeroStatePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.CENTER).setInsets(1));

        row++;
        displayPanel.add(generationLabel, new GBC(1, row).setSpan(1, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.EAST).setInsets(1));
        displayPanel.add(generationDataLabel, new GBC(2, row).setSpan(1, 1).setFill(GBC.NONE)
                .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(stateScroller, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(saveDataPanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.CENTER).setInsets(1));

    } else {
        int row = 0;
        displayPanel.add(createWarningMessagePanel(), new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH)
                .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1));
    }

}

From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java

private void createOptionPanel() {
    labels = dataPreparationToolGUI.getLabels();
    JPanel creativeCommonsPanel = new CreativeCommonsPanel();
    JPanel europeanaRightsPanel = new EuropeanaRightsPanel();
    JPanel emptyPanel = new JPanel();

    JPanel formPanel = new JPanel(new GridLayout(14, 1));

    JPanel extraLicenseCardLayoutPanel = new JPanel(new CardLayout());
    extraLicenseCardLayoutPanel.add(creativeCommonsPanel, CREATIVE_COMMONS);
    extraLicenseCardLayoutPanel.add(europeanaRightsPanel, EUROPEANA_RIGHTS_STATEMENTS);
    extraLicenseCardLayoutPanel.add(emptyPanel, EMPTY_PANEL);
    CardLayout cardLayout = (CardLayout) extraLicenseCardLayoutPanel.getLayout();
    cardLayout.show(extraLicenseCardLayoutPanel, EMPTY_PANEL);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    conversionModeGroup = new ButtonGroup();
    JRadioButton radioButton;//  ww w.  j a v a 2 s .c  o m

    panel.add(new Label(this.labels.getString("edm.panel.label.choose.mode")));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.minimal"));
    radioButton.setActionCommand(MINIMAL);
    radioButton.setSelected(true);
    radioButton.addActionListener(new ConversionModeListener());
    conversionModeGroup.add(radioButton);
    panel.add(radioButton);
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.full"));
    radioButton.setActionCommand(FULL);
    radioButton.addActionListener(new ConversionModeListener());
    conversionModeGroup.add(radioButton);
    panel.add(radioButton);

    formPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    cLevelIdSourceButtonGroup = new ButtonGroup();

    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.identifierSource.header")));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.unitid"));
    radioButton.setActionCommand(UNITID);
    if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) {
        radioButton.setSelected(true);
    }
    cLevelIdSourceButtonGroup.add(radioButton);
    panel.add(radioButton);
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.cid"));
    radioButton.setActionCommand(CID);
    if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) {
        radioButton.setSelected(true);
    }
    cLevelIdSourceButtonGroup.add(radioButton);
    panel.add(radioButton);

    formPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    sourceOfFondsTitleGroup = new ButtonGroup();

    determineDaoInformation();
    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle")));
    if (!this.batch && StringUtils.isBlank(ead2EdmInformation.getArchdescUnittitle())
            && StringUtils.isBlank(ead2EdmInformation.getTitlestmtTitleproper())) {
        panel.add(new Label(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.noSourceAvailable")));
    } else {
        radioButton = new JRadioButton(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.archdescUnittitle"));
        radioButton.setActionCommand(ARCHDESC_UNITTITLE);
        radioButton.setSelected(true);
        radioButton.addActionListener(new ConversionModeListener());
        sourceOfFondsTitleGroup.add(radioButton);
        panel.add(radioButton);
        radioButton = new JRadioButton(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.titlestmtTitleproper"));
        radioButton.setActionCommand(TITLESTMT_TITLEPROPER);
        radioButton.addActionListener(new ConversionModeListener());
        sourceOfFondsTitleGroup.add(radioButton);
        panel.add(radioButton);
    }
    formPanel.add(panel);

    panel = new JPanel(new GridLayout(2, 2));
    landingPageButtonGroup = new ButtonGroup();

    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.landingPages.header")));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.ape"));
    radioButton.setActionCommand(APE);
    if (retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) {
        radioButton.setSelected(true);
    }
    landingPageButtonGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new Label());
    JPanel otherPanel = new JPanel(new GridLayout(1, 2));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.other"));
    radioButton.setActionCommand(OTHER);
    landingPageButtonGroup.add(radioButton);
    otherPanel.add(radioButton);
    landingPageTextArea = new JTextArea();
    landingPageTextArea.setLineWrap(true);
    landingPageTextArea.setWrapStyleWord(true);
    if (!retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) {
        radioButton.setSelected(true);
        landingPageTextArea.setText(retrieveFromDb.retrieveLandingPageBase());
    }
    JScrollPane lptaScrollPane = new JScrollPane(landingPageTextArea);
    lptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    otherPanel.add(lptaScrollPane);
    panel.add(otherPanel);

    formPanel.add(panel);

    panel = new JPanel(new GridLayout(1, 1));
    panel.add(new Label(labels.getString("ese.mandatoryFieldsInfo")));
    panel.add(new Label(""));
    panel.setBorder(BLACK_LINE);
    formPanel.add(panel);

    panel = new JPanel(new GridLayout(1, 3));
    panel.add(new Label(labels.getString("ese.dataProvider") + ":" + "*"));
    dataProviderTextArea = new JTextArea();
    dataProviderTextArea.setLineWrap(true);
    dataProviderTextArea.setWrapStyleWord(true);
    JScrollPane dptaScrollPane = new JScrollPane(dataProviderTextArea);
    dptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    panel.add(dptaScrollPane);
    useExistingRepoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileRepository"));
    useExistingRepoCheckbox.setSelected(true);
    useExistingRepoCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            //empty method on purpose
        }
    });
    JPanel panel2 = new JPanel(new GridLayout(1, 1));
    panel2.add(useExistingRepoCheckbox);
    if (!batch) {
        String repository = ead2EdmInformation.getRepository();
        if (repository != null && !repository.equals("")) {
            dataProviderTextArea.setText(repository);
        } else {
            if (archdescRepository != null) {
                dataProviderTextArea.setText(archdescRepository);
            } else {
                useExistingRepoCheckbox.setSelected(false);
            }
        }
    }
    panel.add(panel2);
    panel.setBorder(BLACK_LINE);
    formPanel.add(panel);

    /*        panel = new JPanel(new GridLayout(1, 3));
     panel.add(new Label(labels.getString("ese.provider") + ":" + "*"));
     providerTextArea = new JTextArea();
     providerTextArea.setLineWrap(true);
     providerTextArea.setWrapStyleWord(true);
     JScrollPane ptaScrollPane = new JScrollPane(providerTextArea);
     ptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
     panel.add(ptaScrollPane);
     panel.add(new Label(""));
     panel.setBorder(BLACK_LINE);
     formPanel.add(panel);
     */
    panel = new JPanel(new GridLayout(5, 3));
    typeGroup = new ButtonGroup();

    panel.add(new Label(labels.getString("ese.type") + ":" + "*"));
    String currentRoleType;
    if (batch) {
        currentRoleType = "";
    } else {
        currentRoleType = ead2EdmInformation.getRoleType();
    }
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.text"));
    if (currentRoleType.equals(EdmOptionsPanel.TEXT)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(TEXT);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.image"));
    if (currentRoleType.equals(EdmOptionsPanel.IMAGE)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(IMAGE);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.video"));
    if (currentRoleType.equals(EdmOptionsPanel.VIDEO)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(VIDEO);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);

    useExistingDaoRoleCheckbox = new JCheckBox(labels.getString("ese.takeFromFileDaoRole"));
    useExistingDaoRoleCheckbox.setSelected(true);
    useExistingDaoRoleCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
        }
    });
    panel.add(useExistingDaoRoleCheckbox);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.sound"));
    if (currentRoleType.equals(EdmOptionsPanel.SOUND)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(SOUND);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.threed"));
    if (currentRoleType.equals(EdmOptionsPanel.THREE_D)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(THREE_D);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.setBorder(GREY_LINE);
    formPanel.add(panel);

    if (this.batch) {
        panel = new JPanel(new GridLayout(1, 3));
        panel.add(new Label(labels.getString("ese.selectLanguage") + ":" + "*"));
        panel.add(languageBoxPanel);
        useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage"));
        useExistingLanguageCheckbox.setSelected(true);
        useExistingLanguageCheckbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                //empty method on purpose
            }
        });
        panel.add(useExistingLanguageCheckbox);
        panel.setBorder(BLACK_LINE);
        formPanel.add(panel);
    } else {
        inheritLanguagePanel = new JPanel(new GridLayout(1, 3));
        inheritLanguagePanel.add(new Label(labels.getString("ese.inheritLanguage") + ":" + "*"));

        JPanel rbPanel = new JPanel(new GridLayout(4, 1));
        inheritLanguageGroup = new ButtonGroup();
        inhLanYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
        inhLanYesRadioButton.setActionCommand(YES);
        inhLanYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanYesRadioButton);
        rbPanel.add(inhLanYesRadioButton);
        inhLanNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
        inhLanNoRadioButton.setActionCommand(NO);
        inhLanNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanNoRadioButton);
        rbPanel.add(inhLanNoRadioButton);
        inhLanProvideRadioButton = new JRadioButton(labels.getString("ese.provide"));
        inhLanProvideRadioButton.setActionCommand(PROVIDE);
        inhLanProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanProvideRadioButton);
        rbPanel.add(inhLanProvideRadioButton);
        useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage"));
        useExistingLanguageCheckbox.setSelected(true);
        useExistingLanguageCheckbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                //empty method on purpose
            }
        });
        rbPanel.add(useExistingLanguageCheckbox);
        inheritLanguagePanel.add(rbPanel, BorderLayout.WEST);

        languageBoxPanel.setVisible(true);
        inheritLanguagePanel.add(languageBoxPanel, BorderLayout.EAST);
        inheritLanguagePanel.setBorder(BLACK_LINE);
        inheritLanguagePanel.setVisible(true);
        formPanel.add(inheritLanguagePanel);
    }

    //        if (this.batch) {
    panel = new JPanel(new GridLayout(1, 3));
    panel.add(new JLabel(labels.getString("edm.panel.license.inheritLicense") + ":" + "*"));
    useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense"));
    useExistingRightsInfoCheckbox.setSelected(true);
    useExistingRightsInfoCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            //empty method on purpose
        }
    });
    panel.add(useExistingRightsInfoCheckbox);
    panel.add(new JLabel());
    panel.setBorder(BLACK_LINE);
    panel.setVisible(true);
    formPanel.add(panel);
    //        } else {
    //            panel = new JPanel(new GridLayout(3, 3));
    //            inheritLicenseGroup = new ButtonGroup();
    //
    //            panel.add(new Label(labels.getString("edm.panel.license.inheritLicense") + ":" + "*"));
    //            inhLicYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    //            inhLicYesRadioButton.setActionCommand(YES);
    ////        inhLicYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicYesRadioButton);
    //            panel.add(inhLicYesRadioButton);
    //            panel.add(new JLabel());
    //
    //            panel.add(new JLabel());
    //            inhLicNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    //            inhLicNoRadioButton.setActionCommand(NO);
    ////        inhLicNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicNoRadioButton);
    //            panel.add(inhLicNoRadioButton);
    //            useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense"));
    //            useExistingRightsInfoCheckbox.setSelected(true);
    //            useExistingRightsInfoCheckbox.addItemListener(new ItemListener() {
    //                @Override
    //                public void itemStateChanged(ItemEvent e) {
    //                    //empty method on purpose
    //                }
    //            });
    //
    //            panel.add(useExistingRightsInfoCheckbox);
    //
    //            panel.add(new JLabel());
    //            inhLicProvideRadioButton = new JRadioButton(labels.getString("ese.provide"));
    //            inhLicProvideRadioButton.setActionCommand(PROVIDE);
    ////        inhLicProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicProvideRadioButton);
    //            panel.add(inhLicProvideRadioButton);
    //            panel.add(new JLabel());
    //
    //            panel.setBorder(BLACK_LINE);
    //            panel.setVisible(true);
    //            formPanel.add(panel);
    //        }

    JPanel mainLicensePanel = new JPanel(new BorderLayout());
    panel = new JPanel(new GridLayout(5, 2));
    licenseGroup = new ButtonGroup();
    //        String currentRightsInformation;
    //        if (batch) {
    //            currentRightsInformation = "";
    //        } else {
    //            currentRightsInformation = ead2EdmInformation.getArchdescLicenceType();
    //        }

    panel.add(new Label(labels.getString("ese.specifyLicense") + ":" + "*"));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.zero"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_CC0)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS_CC0);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.public"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.europeana.rights"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(EUROPEANA_RIGHTS_STATEMENTS);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.out.copyright"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.OUT_OF_COPYRIGHT)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(EdmOptionsPanel.OUT_OF_COPYRIGHT);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);
    mainLicensePanel.add(panel, BorderLayout.WEST);

    mainLicensePanel.add(extraLicenseCardLayoutPanel, BorderLayout.EAST);
    //        if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS) || currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //            cardLayout.show(extraLicenseCardLayoutPanel, currentRightsInformation);
    //            if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) {
    //                if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-f/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(0);
    //                } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("orphan-work-eu/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(1);
    //                } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-p/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(2);
    //                } else {
    //                    europeanaRightsComboBox.setSelectedIndex(3);
    //                }
    //            } else if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //                // get respective items from EAD2EDMInfo and set panel items appropriately
    //            }
    //        }
    mainLicensePanel.setBorder(BLACK_LINE);
    formPanel.add(mainLicensePanel);

    panel = new JPanel(new GridLayout(1, 1));
    panel.add(new Label(labels.getString("ese.specifyAdditionalRightsInfo") + ":"));
    additionalRightsTextArea = new JTextArea();
    additionalRightsTextArea.setLineWrap(true);
    additionalRightsTextArea.setWrapStyleWord(true);
    JScrollPane artaScrollPane = new JScrollPane(additionalRightsTextArea);
    artaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    panel.add(artaScrollPane);
    panel.setBorder(GREY_LINE);
    formPanel.add(panel);

    inheritParentPanel = new JPanel(new GridLayout(2, 3));
    inheritParentCheckbox = new JCheckBox(labels.getString("ese.inheritParent") + ":" + "*");
    inheritParentCheckbox.setSelected(true);
    inheritParentCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhParYesRadioButton.setEnabled(true);
                inhParNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhParYesRadioButton.setEnabled(false);
                inhParNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritParentPanel.add(inheritParentCheckbox);
    inheritParentGroup = new ButtonGroup();
    inhParYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhParYesRadioButton.setActionCommand(YES);
    inheritParentGroup.add(inhParYesRadioButton);
    inheritParentPanel.add(inhParYesRadioButton);
    inheritParentPanel.add(new JLabel(""));
    inhParNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhParNoRadioButton.setActionCommand(NO);
    inheritParentGroup.add(inhParNoRadioButton);
    inheritParentPanel.add(inhParNoRadioButton);
    inheritParentPanel.setBorder(GREY_LINE);
    inheritParentPanel.setVisible(false);
    formPanel.add(inheritParentPanel);

    inheritOriginationPanel = new JPanel(new GridLayout(2, 3));
    inheritOriginationCheckbox = new JCheckBox(labels.getString("ese.inheritOrigination") + ":" + "*");
    inheritOriginationCheckbox.setSelected(true);
    inheritOriginationCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhOriYesRadioButton.setEnabled(true);
                inhOriNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhOriYesRadioButton.setEnabled(false);
                inhOriNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritOriginationPanel.add(inheritOriginationCheckbox);
    inheritOriginationGroup = new ButtonGroup();
    inhOriYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhOriYesRadioButton.setActionCommand(YES);
    inheritOriginationGroup.add(inhOriYesRadioButton);
    inheritOriginationPanel.add(inhOriYesRadioButton);
    inheritOriginationPanel.add(new JLabel(""));
    inhOriNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhOriNoRadioButton.setActionCommand(NO);
    inheritOriginationGroup.add(inhOriNoRadioButton);
    inheritOriginationPanel.add(inhOriNoRadioButton);
    inheritOriginationPanel.setBorder(BLACK_LINE);
    inheritOriginationPanel.setVisible(false);
    formPanel.add(inheritOriginationPanel);

    inheritUnittitlePanel = new JPanel(new GridLayout(2, 3));
    inheritUnittitleCheckbox = new JCheckBox(labels.getString("ese.inheritUnittitle") + ":" + "*");
    inheritUnittitleCheckbox.setSelected(true);
    inheritUnittitleCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhTitleYesRadioButton.setEnabled(true);
                inhTitleNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhTitleYesRadioButton.setEnabled(false);
                inhTitleNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritUnittitlePanel.add(inheritUnittitleCheckbox);
    inheritUnittitleGroup = new ButtonGroup();
    inhTitleYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhTitleYesRadioButton.setActionCommand(YES);
    inheritUnittitleGroup.add(inhTitleYesRadioButton);
    inheritUnittitlePanel.add(inhTitleYesRadioButton);
    inheritUnittitlePanel.add(new JLabel(""));
    inhTitleNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhTitleNoRadioButton.setActionCommand(NO);
    inheritUnittitleGroup.add(inhTitleNoRadioButton);
    inheritUnittitlePanel.add(inhTitleNoRadioButton);
    inheritUnittitlePanel.setBorder(BLACK_LINE);
    inheritUnittitlePanel.setVisible(false);
    formPanel.add(inheritUnittitlePanel);

    JButton createEdmBtn = new JButton(labels.getString("ese.createEseBtn"));
    JButton cancelBtn = new JButton(labels.getString("ese.cancelBtn"));

    createEdmBtn.addActionListener(new CreateEdmActionListener());
    cancelBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (Map.Entry<String, FileInstance> entry : fileInstances.entrySet()) {
                FileInstance fileInstance = entry.getValue();
                fileInstance.setEdm(false);
            }
            dataPreparationToolGUI.enableEdmConversionBtn();
            if (batch) {
                dataPreparationToolGUI.enableAllBatchBtns();
            }
            dataPreparationToolGUI.enableRadioButtons();
            close();
        }
    });

    JPanel buttonPanel = new JPanel(new GridLayout(1, 5));

    buttonPanel.add(new JLabel(""));
    buttonPanel.add(cancelBtn);
    buttonPanel.add(new JLabel(""));
    buttonPanel.add(createEdmBtn);
    buttonPanel.add(new JLabel(""));

    add(formPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

private JPanel getMatcherPanel() {
    if (matcherPanel == null) {
        matcherPanel = new JPanel();
        matcherPanel.setLayout(new GridBagLayout());
        Color bgColor = matcherPanel.getBackground();
        matcherPanel.setBorder(new RoundedBorderPanel(bgColor));

        GridBagConstraints constraint = new GridBagConstraints();
        constraint.gridx = 0;/*from   ww w. j av  a2  s .  c o m*/
        constraint.gridy = 0;
        constraint.insets = new Insets(0, 0, 0, 0);
        constraint.anchor = GridBagConstraints.FIRST_LINE_START;
        constraint.weightx = 0.5;

        ignore = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.ignore"));
        match = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.match"));

        ButtonGroup groupBtn = new ButtonGroup();
        groupBtn.add(ignore);
        groupBtn.add(match);

        keep = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.keep"));
        alpha = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.alpha"));
        characters = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.characters"));
        charField = new JTextField(20);

        numeric = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.numeric"));
        lengthMin = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.min.length"));
        lengthMax = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.max.length"));
        lengthMinField = new JTextField(10);
        lengthMaxField = new JTextField(10);

        matcherPanel.add(ignore, constraint);

        constraint.gridy = 1;
        constraint.anchor = GridBagConstraints.WEST;
        matcherPanel.add(match, constraint);

        constraint.anchor = GridBagConstraints.EAST;

        enterBtn = new JButton(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.setName(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.addActionListener(this);
        matcherPanel.add(enterBtn, constraint);

        constraint.anchor = GridBagConstraints.WEST;
        constraint.gridy = 2;
        matcherPanel.add(keep, constraint);

        constraint.gridy = 3;
        matcherPanel.add(alpha, constraint);

        constraint.gridy = 4;
        JPanel panelChar = new JPanel(new FlowLayout());
        panelChar.add(characters);
        panelChar.add(charField);
        matcherPanel.add(panelChar, constraint);

        constraint.gridy = 5;
        matcherPanel.add(numeric, constraint);

        constraint.gridy = 6;
        JPanel panelNumericLength = new JPanel();
        panelNumericLength.setLayout(new BoxLayout(panelNumericLength, BoxLayout.Y_AXIS));
        JPanel panelMinLength = new JPanel(new FlowLayout());
        panelMinLength.add(lengthMin);
        panelMinLength.add(lengthMinField);
        panelNumericLength.add(panelMinLength);
        JPanel panelMaxLength = new JPanel(new FlowLayout());
        panelMaxLength.add(lengthMax);
        panelMaxLength.add(lengthMaxField);
        panelNumericLength.add(panelMaxLength);
        matcherPanel.add(panelNumericLength, constraint);

        constraint.weighty = 1;

        matcherPanel.add(new JPanel(), constraint);
    }
    return matcherPanel;
}

From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java

private JCheckBox getSolenoidValveOneCheckBox() {
    if (solenoidValveOneCheckBox == null) {
        solenoidValveOneCheckBox = new JCheckBox("1.0"); //$NON-NLS-1$

        solenoidValveOneCheckBox.addActionListener(new ActionListener() {

            @Override//ww w. ja  va  2  s.c  om
            public void actionPerformed(ActionEvent e) {
                if (solenoidValveOneCheckBox.isSelected())
                    solenoidValvesOfInterest.add(Double.valueOf(1.0));
                else
                    solenoidValvesOfInterest.remove(Double.valueOf(1.0));
            }
        });
    }
    return solenoidValveOneCheckBox;
}

From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java

/**
 * Initialize GUI components./*ww  w.  jav a  2 s  . co m*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void initGUI() {

    App.init();

    // setBounds(100, 100, 972, 439);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setIconImage(Builder.getApplicationIcon());
    setTitle("Sample Size Analysis");
    getContentPane().setLayout(new MigLayout("", "[1136px,grow,fill]", "[30px][405px,grow]"));

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    getContentPane().add(toolBar, "cell 0 0,growx,aligny top");

    JToolBarButton btnOpen = new JToolBarButton(actionBrowse);
    btnOpen.setIcon(Builder.getImageIcon("fileopen.png"));
    toolBar.add(btnOpen);

    JToolBarButton btnSave = new JToolBarButton(actionSaveTable);
    btnSave.setIcon(Builder.getImageIcon("save.png"));
    toolBar.add(btnSave);

    JToolBarButton btnExportPDF = new JToolBarButton(actionExportPDF);
    btnExportPDF.setIcon(Builder.getImageIcon("pdf.png"));
    toolBar.add(btnExportPDF);

    JToolBarButton btnExportPNG = new JToolBarButton(actionExportPNG);
    btnExportPNG.setIcon(Builder.getImageIcon("formatpng.png"));
    toolBar.add(btnExportPNG);

    toolBar.addSeparator();

    JToolBarButton btnRun = new JToolBarButton(actionRun);
    btnRun.setIcon(Builder.getImageIcon("run.png"));
    toolBar.add(btnRun);

    JPanel panelMain = new JPanel();
    getContentPane().add(panelMain, "cell 0 1,grow");
    panelMain.setLayout(new BorderLayout(0, 0));

    JSplitPane splitPaneMain = new JSplitPane();
    splitPaneMain.setOneTouchExpandable(true);
    panelMain.add(splitPaneMain);

    JPanel panelParameters = new JPanel();
    splitPaneMain.setLeftComponent(panelParameters);
    panelParameters.setLayout(new MigLayout("", "[grow,right]", "[][][][193.00,grow,fill][]"));

    JPanel panelInput = new JPanel();
    panelInput.setBorder(new TitledBorder(null, "Input", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelInput, "cell 0 0,grow");
    panelInput.setLayout(new MigLayout("", "[100px:100px:180px,right][grow,fill][]", "[]"));

    JLabel lblInputFile = new JLabel("Input file:");
    panelInput.add(lblInputFile, "cell 0 0");

    txtInputFile = new JTextField();
    panelInput.add(txtInputFile, "cell 1 0,growx");
    txtInputFile.setActionCommand("NewFileTyped");
    txtInputFile.addActionListener(this);
    txtInputFile.setColumns(10);

    JButton btnBrowse = new JButton("");
    panelInput.add(btnBrowse, "cell 2 0");
    btnBrowse.setAction(actionBrowse);
    btnBrowse.setText("");
    btnBrowse.setIcon(Builder.getImageIcon("fileopen16.png"));
    btnBrowse.setPreferredSize(new Dimension(25, 25));
    btnBrowse.setMaximumSize(new Dimension(25, 25));
    btnBrowse.putClientProperty("JButton.buttonType", "segmentedTextured");
    btnBrowse.putClientProperty("JButton.segmentPosition", "middle");

    JPanel panelAnalysisOptions = new JPanel();
    panelAnalysisOptions.setBorder(new TitledBorder(null, "Analysis and filtering options",
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelAnalysisOptions, "cell 0 1,grow");
    panelAnalysisOptions.setLayout(new MigLayout("", "[100px:100px:180px,right][grow][][]", "[][][][][]"));

    JLabel lblEventTypes = new JLabel("Event type:");
    panelAnalysisOptions.add(lblEventTypes, "cell 0 0");

    cboEventType = new JComboBox();
    panelAnalysisOptions.add(cboEventType, "cell 1 0 3 1");
    cboEventType.setModel(new DefaultComboBoxModel(EventTypeToProcess.values()));
    new EventTypeWrapper(cboEventType, PrefKey.EVENT_TYPE_TO_PROCESS, EventTypeToProcess.FIRE_EVENT);

    chkCommonYears = new JCheckBox("<html>Only analyze years all series have in common");
    chkCommonYears.setEnabled(false);
    new CheckBoxWrapper(chkCommonYears, PrefKey.SSIZ_CHK_COMMON_YEARS, false);
    panelAnalysisOptions.add(chkCommonYears, "cell 1 1 3 1");

    chkExcludeSeriesWithNoEvents = new JCheckBox("<html>Exclude series/segments with no events");
    chkExcludeSeriesWithNoEvents.setEnabled(false);
    new CheckBoxWrapper(chkExcludeSeriesWithNoEvents, PrefKey.SSIZ_CHK_EXCLUDE_SERIES_WITH_NO_EVENTS, false);
    panelAnalysisOptions.add(chkExcludeSeriesWithNoEvents, "cell 1 2 3 1");

    JLabel lblThresholdType = new JLabel("Threshold:");
    panelAnalysisOptions.add(lblThresholdType, "cell 0 3");

    cboThresholdType = new JComboBox();
    panelAnalysisOptions.add(cboThresholdType, "cell 1 3");
    cboThresholdType.setModel(new DefaultComboBoxModel(FireFilterType.values()));
    new FireFilterTypeWrapper(cboThresholdType, PrefKey.COMPOSITE_FILTER_TYPE_WITH_ALL_TREES,
            FireFilterType.NUMBER_OF_EVENTS);

    JLabel label = new JLabel(">=");
    panelAnalysisOptions.add(label, "flowx,cell 2 3");

    spnThresholdValueGT = new JSpinner();
    panelAnalysisOptions.add(spnThresholdValueGT, "cell 3 3");
    spnThresholdValueGT.setModel(new SpinnerNumberModel(1, 1, 999, 1));
    new SpinnerWrapper(spnThresholdValueGT, PrefKey.COMPOSITE_FILTER_VALUE, 1);

    chkEnableLessThan = new JCheckBox("");
    chkEnableLessThan.setActionCommand("LessThanThresholdStatus");
    chkEnableLessThan.addActionListener(this);
    panelAnalysisOptions.add(chkEnableLessThan, "flowx,cell 1 4,alignx right");

    lblLessThan = new JLabel("<=");
    lblLessThan.setEnabled(false);
    panelAnalysisOptions.add(lblLessThan, "cell 2 4");

    spnThresholdValueLT = new JSpinner();
    spnThresholdValueLT.setEnabled(false);
    spnThresholdValueLT.setModel(new SpinnerNumberModel(1, 1, 999, 1));
    panelAnalysisOptions.add(spnThresholdValueLT, "cell 3 4");

    lblAnd = new JLabel("and");
    panelAnalysisOptions.add(lblAnd, "cell 1 4");

    JPanel panelSimulations = new JPanel();
    panelSimulations.setBorder(
            new TitledBorder(null, "Simulations", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelSimulations, "cell 0 2,grow");
    panelSimulations.setLayout(new MigLayout("", "[100px:100px:180px,right][fill]", "[][][]"));

    JLabel lblSimulations = new JLabel("Simulations:");
    panelSimulations.add(lblSimulations, "cell 0 0");

    spnSimulations = new JSpinner();
    panelSimulations.add(spnSimulations, "cell 1 0");
    spnSimulations.setModel(new SpinnerNumberModel(new Integer(1000), new Integer(1), null, new Integer(1)));
    new SpinnerWrapper(spnSimulations, PrefKey.SSIZ_SIMULATION_COUNT, 1000);

    JLabel lblSeedNumber = new JLabel("Seed number:");
    panelSimulations.add(lblSeedNumber, "cell 0 1");

    spnSeed = new JSpinner();
    panelSimulations.add(spnSeed, "cell 1 1");
    spnSeed.setModel(new SpinnerNumberModel(new Integer(30188), null, null, new Integer(1)));
    new SpinnerWrapper(spnSeed, PrefKey.SSIZ_SEED_NUMBER, 30188);

    JLabel lblResampling = new JLabel("Resampling:");
    panelSimulations.add(lblResampling, "cell 0 2");

    cboResampling = new JComboBox();
    panelSimulations.add(cboResampling, "cell 1 2");
    cboResampling
            .setModel(new DefaultComboBoxModel(new String[] { "With replacement", "Without replacement" }));
    new ResamplingTypeWrapper(cboResampling, PrefKey.SSIZ_RESAMPLING_TYPE, ResamplingType.WITH_REPLACEMENT);

    segmentationPanel = new SegmentationPanel();
    segmentationPanel.chkSegmentation.setText("Process subset or segments of dataset?");
    segmentationPanel.chkSegmentation.setEnabled(false);
    panelParameters.add(segmentationPanel, "cell 0 3,growx");

    JPanel panel_3 = new JPanel();
    panelParameters.add(panel_3, "cell 0 4,grow");
    panel_3.setLayout(new MigLayout("", "[left][grow][right]", "[]"));

    JButton btnReset = new JButton("Reset");
    btnReset.setActionCommand("Reset");
    btnReset.addActionListener(this);
    panel_3.add(btnReset, "cell 0 0,grow");

    JButton btnRunAnalysis = new JButton("Run Analysis");
    btnRunAnalysis.setAction(actionRun);
    panel_3.add(btnRunAnalysis, "cell 2 0,grow");

    JPanel panelResults = new JPanel();
    splitPaneMain.setRightComponent(panelResults);
    panelResults.setLayout(new BorderLayout(0, 0));

    splitPaneResults = new JSplitPane();
    splitPaneResults.setResizeWeight(0.5);
    splitPaneResults.setOneTouchExpandable(true);
    splitPaneResults.setDividerLocation(0.5d);
    panelResults.add(splitPaneResults, BorderLayout.CENTER);
    splitPaneResults.setOrientation(JSplitPane.VERTICAL_SPLIT);

    JPanel panelResultsTop = new JPanel();
    splitPaneResults.setLeftComponent(panelResultsTop);
    panelResultsTop.setLayout(new BorderLayout(0, 0));

    JPanel panelChartOptions = new JPanel();
    panelChartOptions.setBackground(Color.WHITE);
    panelResultsTop.add(panelChartOptions, BorderLayout.SOUTH);
    panelChartOptions.setLayout(new MigLayout("", "[][][][][][grow][grow]", "[15px,center]"));

    JLabel lblNewLabel = new JLabel("Plot:");
    panelChartOptions.add(lblNewLabel, "cell 0 0,alignx trailing,aligny center");

    cboChartMetric = new JComboBox();
    cboChartMetric.setEnabled(false);
    cboChartMetric.setModel(new DefaultComboBoxModel(MiddleMetric.values()));
    panelChartOptions.add(cboChartMetric, "cell 1 0,growx");
    cboChartMetric.setBackground(Color.WHITE);

    JLabel lblOfSegment = new JLabel("of segment:");
    panelChartOptions.add(lblOfSegment, "cell 2 0,alignx trailing");

    cboSegment = new JComboBox();
    cboSegment.setBackground(Color.WHITE);
    cboSegment.setActionCommand("UpdateChart");
    cboSegment.addActionListener(this);

    panelChartOptions.add(cboSegment, "cell 3 0,growx");
    cboChartMetric.setActionCommand("UpdateChart");

    JLabel lblWithAsymptoteType = new JLabel("with asymptote type:");
    panelChartOptions.add(lblWithAsymptoteType, "cell 4 0,alignx trailing");

    JComboBox comboBox = new JComboBox();
    comboBox.setEnabled(false);
    comboBox.setModel(new DefaultComboBoxModel(new String[] { "none", "Weibull", "Michaelis-Menten",
            "Modified Michaelis-Menten", "Logistic", "Modified exponential" }));
    comboBox.setBackground(Color.WHITE);
    panelChartOptions.add(comboBox, "cell 5 0,growx");
    cboChartMetric.addActionListener(this);

    panelChart = new JPanel();
    panelChart.setMinimumSize(new Dimension(200, 200));
    panelResultsTop.add(panelChart, BorderLayout.CENTER);
    panelChart.setLayout(new BorderLayout(0, 0));
    panelChart.setBackground(Color.WHITE);

    JTabbedPane panelResultsBottom = new JTabbedPane(JTabbedPane.BOTTOM);
    splitPaneResults.setRightComponent(panelResultsBottom);

    simulationsTable = new SSIZResultsTable();
    simulationsTable.setEnabled(false);
    simulationsTable.addMouseListener(new TablePopClickListener());
    simulationsTable.setVisibleRowCount(10);

    adapter = new JTableSpreadsheetByRowAdapter(simulationsTable);

    scrollPaneSimulations = new JScrollPane();
    panelResultsBottom.addTab("Simulations", null, scrollPaneSimulations, null);
    scrollPaneSimulations.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPaneSimulations.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPaneSimulations.setViewportView(simulationsTable);

    JPanel panelAsymptote = new JPanel();

    asymptoteTable = new AsymptoteTable();
    asymptoteTable.setEnabled(false);
    // asymptoteTable.addMouseListener(new TablePopClickListener());
    asymptoteTable.setVisibleRowCount(10);

    scrollPaneAsymptote = new JScrollPane();

    scrollPaneAsymptote.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPaneAsymptote.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPaneAsymptote.setViewportView(asymptoteTable);
    panelAsymptote.setLayout(new BorderLayout());
    panelAsymptote.add(scrollPaneAsymptote, BorderLayout.CENTER);
    panelResultsBottom.addTab("Asymptote", null, panelAsymptote, null);

    // Disable asymptote tab until it is implemented
    panelResultsBottom.setEnabledAt(1, false);

    panelProgressBar = new JPanel();
    panelProgressBar.setLayout(new BorderLayout());

    btnCancelAnalysis = new JButton("Cancel");
    btnCancelAnalysis.setIcon(Builder.getImageIcon("delete.png"));
    btnCancelAnalysis.setVisible(false);
    btnCancelAnalysis.setActionCommand("CancelAnalysis");
    btnCancelAnalysis.addActionListener(this);

    progressBar = new JProgressBar();
    panelProgressBar.add(progressBar, BorderLayout.CENTER);
    panelProgressBar.add(btnCancelAnalysis, BorderLayout.EAST);
    progressBar.setStringPainted(true);

    fileDialogWasUsed = false;
    mouseListenersActive = false;

    this.setGUIForFHFileReader();
    this.setGUIForThresholdStatus();

    pack();
    this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    setVisible(true);
}

From source file:MiGA.StatsSelection.java

public StatsSelection(final String[] organisms, final boolean flag) {

    setTitle("MiGA");
    setSize(800, 600);//from  w  w w  . j  a  v  a 2 s. c o m
    setLocationRelativeTo(null);
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Image im = Toolkit.getDefaultToolkit().getImage("ssr.png");
    this.setIconImage(im);

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }

    countmono = new ArrayList<Integer>();
    countdi = new ArrayList<Integer>();
    counttri = new ArrayList<Integer>();
    counttetra = new ArrayList<Integer>();
    countpenta = new ArrayList<Integer>();
    counthexa = new ArrayList<Integer>();
    countmonore = new ArrayList<Integer>();
    countdire = new ArrayList<Integer>();
    counttrire = new ArrayList<Integer>();
    counttetrare = new ArrayList<Integer>();
    countpentare = new ArrayList<Integer>();
    counthexare = new ArrayList<Integer>();
    Amono = new ArrayList<Integer>();
    Tmono = new ArrayList<Integer>();
    Gmono = new ArrayList<Integer>();
    Cmono = new ArrayList<Integer>();
    Adi = new ArrayList<Integer>();
    Tdi = new ArrayList<Integer>();
    Gdi = new ArrayList<Integer>();
    Cdi = new ArrayList<Integer>();
    Atri = new ArrayList<Integer>();
    Ttri = new ArrayList<Integer>();
    Gtri = new ArrayList<Integer>();
    Ctri = new ArrayList<Integer>();
    Atetra = new ArrayList<Integer>();
    Ttetra = new ArrayList<Integer>();
    Gtetra = new ArrayList<Integer>();
    Ctetra = new ArrayList<Integer>();
    Apenta = new ArrayList<Integer>();
    Tpenta = new ArrayList<Integer>();
    Gpenta = new ArrayList<Integer>();
    Cpenta = new ArrayList<Integer>();
    Ahexa = new ArrayList<Integer>();
    Thexa = new ArrayList<Integer>();
    Ghexa = new ArrayList<Integer>();
    Chexa = new ArrayList<Integer>();

    for (int i = 0; i < organisms.length; i++) {
        countmono.add(0);
        countdi.add(0);
        counttri.add(0);
        counttetra.add(0);
        countpenta.add(0);
        counthexa.add(0);
        countmonore.add(0);
        countdire.add(0);
        counttrire.add(0);
        counttetrare.add(0);
        countpentare.add(0);
        counthexare.add(0);
        Amono.add(0);
        Tmono.add(0);
        Gmono.add(0);
        Cmono.add(0);
        Adi.add(0);
        Tdi.add(0);
        Gdi.add(0);
        Cdi.add(0);
        Atri.add(0);
        Ttri.add(0);
        Gtri.add(0);
        Ctri.add(0);
        Atetra.add(0);
        Ttetra.add(0);
        Gtetra.add(0);
        Ctetra.add(0);
        Apenta.add(0);
        Tpenta.add(0);
        Gpenta.add(0);
        Cpenta.add(0);
        Ahexa.add(0);
        Thexa.add(0);
        Ghexa.add(0);
        Chexa.add(0);
    }

    lab = new JLabel(
            "<html><b><p>To retrieve the sequence you want</p><p>simply copy and paste in the fields below</p><p>the data you were given in your result's file</p></b></html>");

    startlab = new JLabel("Start:");
    endlab = new JLabel("End:");
    titlelab = new JLabel("Chromosome or field:");

    startnum = new JTextField();
    startnum.setColumns(5);
    endnum = new JTextField();
    endnum.setColumns(5);
    titlef = new JTextField();
    titlef.setColumns(30);

    flankst = new JLabel("Flanking region before: ");
    flankst.setEnabled(false);
    flankst.setVisible(false);
    flankend = new JLabel("Flanking region after: ");
    flankend.setEnabled(false);
    flankend.setVisible(false);

    flankstn = new JTextField();
    flankstn.setColumns(5);
    flankstn.setEnabled(false);
    flankstn.setVisible(false);

    flankendn = new JTextField();
    flankendn.setColumns(5);
    flankendn.setEnabled(false);
    flankendn.setVisible(false);

    result = new JTextArea("", 6, 90);
    result.setText(" ");
    result.setEditable(false);
    result.setLineWrap(true);
    result.setAutoscrolls(true);
    sbrText = new JScrollPane(result);
    sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    flk = new JCheckBox("Flanking Regions");
    flk.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (flk.isSelected()) {
                flankst.setEnabled(true);
                flankst.setVisible(true);
                flankend.setEnabled(true);
                flankend.setVisible(true);
                flankstn.setEnabled(true);
                flankstn.setVisible(true);
                flankendn.setEnabled(true);
                flankendn.setVisible(true);

            }
            if (!flk.isSelected()) {
                flankst.setEnabled(false);
                flankst.setVisible(false);
                flankend.setEnabled(false);
                flankend.setVisible(false);
                flankstn.setEnabled(false);
                flankstn.setVisible(false);
                flankendn.setEnabled(false);
                flankendn.setVisible(false);

            }
        }
    });

    retrieve = new JButton("Retrieve");
    retrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int start = 0;
            int end = 0;

            BufferedReader in = null;
            String location = "";
            String newlocation = "";
            String bufferpre = "";
            String bufferpost = "";
            String pre = "";
            String post = "";
            String mid = "";
            try {
                String[] locationarray = titlef.getText().split("data/");
                location = locationarray[0] + locationarray[1];
                newlocation = "";
                if (location.contains("local")) {
                    in = new BufferedReader(new FileReader(location + ".txt"));
                } else if (location.contains("organisms")) {
                    String[] loc = location.split("/");
                    try {
                        if (CheckForKaryotype(loc[1])) {
                            newlocation = loc[0] + "/" + loc[1] + "/chrom-" + loc[2] + "-slices.txt";
                        } else {
                            newlocation = loc[0] + "/" + loc[1] + "/slice-" + loc[2] + ".txt";
                        }
                    } catch (SQLException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (ClassNotFoundException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    in = new BufferedReader(new FileReader(newlocation));
                }
            } catch (FileNotFoundException ex) {
                msg.showMessageDialog(paneldown, "Wrong field", "Error", JOptionPane.ERROR_MESSAGE);
            }
            int rest = Integer.parseInt(startnum.getText()) % 20000;
            int lines = Integer.parseInt(startnum.getText()) / 20000;
            lines++;
            String buffer1 = "";

            for (int c = 0; c < lines; c++) {
                try {
                    buffer1 = in.readLine();
                } catch (IOException ex) {
                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            try {
                in.close();
            } catch (IOException ex) {
                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (flk.isSelected()) {
                boolean tfs = false, tfe = false;
                int fs = 0, fe = 0;
                try {
                    fs = Integer.parseInt(flankstn.getText());
                    tfs = true;
                } catch (NumberFormatException ex) {
                    tfs = false;
                }

                try {
                    fe = Integer.parseInt(flankendn.getText());
                    tfe = true;
                } catch (NumberFormatException ex) {
                    tfe = false;
                }
                if (tfs && tfe) {

                    start = rest - Integer.parseInt(flankstn.getText());
                    end = rest + Integer.parseInt(endnum.getText()) - Integer.parseInt(startnum.getText())
                            + Integer.parseInt(flankendn.getText());
                    try {
                        in = new BufferedReader(new FileReader(newlocation));
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    if (start < 0 && lines == 1) {
                        start = 0;
                    } else if (start < 0 && lines > 1) {
                        for (int j = 0; j < lines - 1; j++) {
                            try {
                                bufferpre = in.readLine();
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        pre = bufferpre.substring(20000 + start);
                        mid = buffer1.substring(0, end);
                        try {
                            in.close();
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                    int cl = 0;
                    try {
                        cl = countlines(newlocation);
                    } catch (IOException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    try {
                        in = new BufferedReader(new FileReader(newlocation));
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    if (end > 20000 && lines == cl - 1) {
                        if (end - 20000 >= rest) {
                            end = rest;
                            mid = buffer1.substring(start);
                            post = bufferpost;
                        } else {
                            for (int j = 0; j < lines - 1; j++) {
                                try {
                                    bufferpost = in.readLine();
                                } catch (IOException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                            }
                            mid = buffer1.substring(start);
                            post = bufferpre.substring(0, end - 20000);
                            try {
                                in.close();
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }

                    } else if (end > 20000 && lines < cl - 1) {
                        for (int j = 0; j < lines + 1; j++) {
                            try {
                                bufferpost = in.readLine();
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        mid = buffer1.substring(start);
                        post = bufferpost.substring(0, end - 20000);
                        try {
                            in.close();
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }

                    if (start >= 0 && (end <= 20000 || end <= rest)) {
                        mid = buffer1.substring(start, end);
                    }

                } else {
                    if (!tfs) {
                        msg.showMessageDialog(paneldown,
                                "Flanking region start is empty.\nFill in the gap or uncheck the\nflanking regions checkbox",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    if (!tfe) {
                        msg.showMessageDialog(paneldown,
                                "Flanking region end is empty.\nFill in the gap or uncheck the\nflanking regions checkbox",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                }
                //
            }
            if (!flk.isSelected()) {
                start = rest;
                end = rest + Integer.parseInt(endnum.getText()) - Integer.parseInt(startnum.getText());
                try {
                    in = new BufferedReader(new FileReader(newlocation));
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                }
                if (start < 0 && lines == 1) {
                    start = 0;
                } else if (start < 0 && lines > 1) {
                    for (int j = 0; j < lines - 1; j++) {
                        try {
                            bufferpre = in.readLine();
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                    pre = bufferpre.substring(start);
                    mid = buffer1.substring(0, end);
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                int cl = 0;
                try {
                    cl = countlines(newlocation);
                } catch (IOException ex) {
                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    in = new BufferedReader(new FileReader(newlocation));
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                }
                if (end > 20000 && lines == cl - 1) {
                    if (end - 20000 >= rest) {
                        end = rest;
                        mid = buffer1.substring(start);
                        post = bufferpost;
                    } else {
                        for (int j = 0; j < lines - 1; j++) {
                            try {
                                bufferpost = in.readLine();
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        mid = buffer1.substring(start);
                        post = bufferpre.substring(0, end - 20000);
                        try {
                            in.close();
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }

                } else if (end > 20000 && lines < cl - 1) {
                    for (int j = 0; j < lines + 1; j++) {
                        try {
                            bufferpost = in.readLine();
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                    mid = buffer1.substring(start);
                    post = bufferpost.substring(0, end - 20000);
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }

                if (start >= 0 && (end <= 20000 || end <= rest)) {
                    mid = buffer1.substring(start, end);
                }
            }

            result.setText(pre + mid + post);
        }
    });

    mono = new JCheckBox("Mononucleotide");
    di = new JCheckBox("Dinucleotide");
    tri = new JCheckBox("Trinucleotide");
    tetra = new JCheckBox("Tetranucleotide");
    penta = new JCheckBox("Pentanucleotide");
    hexa = new JCheckBox("Hexanucleotide");

    SSR = new ArrayList<String>();
    repeats = new ArrayList<Integer>();
    EndOfSsr = new ArrayList<Integer>();
    start = new ArrayList<Integer>();

    select = new JLabel("Select type: ");

    minimumssrlen = new JLabel("Minimum SSR length(bp)");
    minimumssrlen.setVisible(false);
    score = new JTextField();
    score.setColumns(5);
    score.setVisible(false);

    msg = new JOptionPane();

    gapmax = new JLabel("Maximum Mismatch length for Imperfect SSRs(bp)");
    gapmax.setVisible(false);
    max = new JTextField();
    max.setColumns(5);
    max.setVisible(false);

    minlenpregap = new JLabel("Minimum SSR length before given Mismatch length(bp)");
    minlenpregap.setVisible(false);
    minpregap = new JTextField();
    minpregap.setColumns(5);
    minpregap.setVisible(false);

    gapcomp = new JLabel("Maximum Inter-repeat R for Compound SSRs(bp)");
    gapcomp.setVisible(false);
    maxgapcomp = new JTextField();
    maxgapcomp.setColumns(5);
    maxgapcomp.setVisible(false);

    box1 = new JCheckBox("Perfect");
    box2 = new JCheckBox("Imperfect");
    box3 = new JCheckBox("Compound");
    com = new JCheckBox("Perfect Compound");
    incom = new JCheckBox("Imperfect Compound");

    box1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (box2.isSelected() || box3.isSelected()) {
                if (box1.isSelected()) {
                    std.setEnabled(true);
                    no_st.setEnabled(true);
                    part_st.setEnabled(true);
                    full_st.setEnabled(true);

                    if (!box3.isSelected()) {
                        minimumssrlen.setVisible(true);
                        score.setVisible(true);
                    }
                }
                if (!box1.isSelected()) {
                    std.setEnabled(false);
                    no_st.setEnabled(false);
                    part_st.setEnabled(false);
                    full_st.setEnabled(false);
                    if (!box3.isSelected()) {
                        minimumssrlen.setVisible(false);
                        score.setVisible(false);
                    }
                }
            } else {
                if (box1.isSelected()) {
                    std.setEnabled(true);
                    no_st.setEnabled(true);
                    part_st.setEnabled(true);
                    full_st.setEnabled(true);
                    panel2.setVisible(true);
                    minimumssrlen.setVisible(true);
                    score.setVisible(true);
                }
                if (!box1.isSelected()) {
                    std.setEnabled(false);
                    no_st.setEnabled(false);
                    part_st.setEnabled(false);
                    full_st.setEnabled(false);
                    panel2.setVisible(false);
                    minimumssrlen.setVisible(false);
                    score.setVisible(false);
                }

            }
        }
    });

    box2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (box1.isSelected() || box3.isSelected()) {
                if (box2.isSelected()) {
                    gapmax.setVisible(true);
                    max.setVisible(true);

                    minlenpregap.setVisible(true);
                    minpregap.setVisible(true);
                }
                if (!box2.isSelected()) {

                    gapmax.setVisible(false);
                    max.setVisible(false);

                    minlenpregap.setVisible(false);
                    minpregap.setVisible(false);

                }
            } else {
                if (box2.isSelected()) {
                    panel2.setVisible(true);
                    gapmax.setVisible(true);
                    max.setVisible(true);

                    minlenpregap.setVisible(true);
                    minpregap.setVisible(true);
                }
                if (!box2.isSelected()) {
                    panel2.setVisible(false);
                    gapmax.setVisible(false);
                    max.setVisible(false);

                    minlenpregap.setVisible(false);
                    minpregap.setVisible(false);
                }
            }
        }
    });

    box3.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (box1.isSelected() || box2.isSelected()) {
                if (box3.isSelected()) {
                    paneldownleft.setVisible(true);
                    if (!box1.isSelected()) {
                        minimumssrlen.setVisible(true);
                        score.setVisible(true);
                    }
                    gapcomp.setVisible(true);
                    maxgapcomp.setVisible(true);
                    com.setVisible(true);
                    incom.setVisible(true);

                }
                if (!box3.isSelected()) {
                    paneldownleft.setVisible(false);
                    gapcomp.setVisible(false);
                    maxgapcomp.setVisible(false);
                    if (!box1.isSelected()) {
                        minimumssrlen.setVisible(false);
                        score.setVisible(false);
                        com.setVisible(false);
                        incom.setVisible(false);
                    }
                }
            } else {
                if (box3.isSelected()) {
                    paneldownleft.setVisible(true);
                    panel2.setVisible(true);
                    minimumssrlen.setVisible(true);
                    score.setVisible(true);

                    gapcomp.setVisible(true);
                    maxgapcomp.setVisible(true);
                    com.setVisible(true);
                    incom.setVisible(true);
                }
                if (!box3.isSelected()) {
                    paneldownleft.setVisible(false);
                    panel2.setVisible(false);
                    minimumssrlen.setVisible(false);
                    score.setVisible(false);
                    gapcomp.setVisible(false);
                    maxgapcomp.setVisible(false);
                    com.setVisible(false);
                    incom.setVisible(false);
                }
            }
        }
    });
    /*
    incom.addActionListener(new ActionListener() {
            
    public void actionPerformed(ActionEvent e) {
    if (incom.isSelected()) {
    if (!box2.isSelected()) {
    gapmax.setVisible(true);
    max.setVisible(true);
            
    minlenpregap.setVisible(true);
    minpregap.setVisible(true);
    }
    }
    if (!incom.isSelected()) {
    if (!box2.isSelected()) {
    gapmax.setVisible(false);
    max.setVisible(false);
            
    minlenpregap.setVisible(false);
    minpregap.setVisible(false);
    }
    }
    }
    });*/

    std = new JPanel();
    no_st = new JRadioButton("Not Standardized");
    part_st = new JRadioButton("Partial Standardized");
    full_st = new JRadioButton("Full Standardized");
    no_st.setSelected(true);
    no_st.setEnabled(false);
    part_st.setEnabled(false);
    full_st.setEnabled(false);

    standard = new ButtonGroup();
    standard.add(no_st);
    standard.add(part_st);
    standard.add(full_st);

    show = new JButton("Run");
    show.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            if (!box1.isSelected() && !box2.isSelected() && !box3.isSelected()) {
                msg.showMessageDialog(paneldown, "Please select a type", "Error", JOptionPane.ERROR_MESSAGE);
            }
            for (int i = 0; i < organisms.length; i++) {
                File f = new File("organisms/" + organisms[i] + "/stats/");
                if (f.exists()) {
                    f.delete();
                }
            }

            calendar = Calendar.getInstance();
            now = calendar.getTime();
            if (box1.isSelected()) {
                if (!score.getText().isEmpty()) {
                    boolean isnumber = false;
                    int minlen = 0;
                    try {
                        minlen = Integer.parseInt(score.getText());
                        isnumber = true;
                    } catch (NumberFormatException ex) {
                        isnumber = false;
                    }
                    if (isnumber) {
                        try {
                            getPerfectSSRs(organisms, minlen, flag);

                            for (int i = 0; i < organisms.length; i++) {

                                map = new HashMap<String, motifStats>();

                                String location = "";
                                String location2 = "";
                                PrintWriter out = null;

                                // 18/11/2013 added starting here
                                String filetype = "";
                                String filepro = "";

                                if (flag) {
                                    filetype = "organisms";
                                    filepro = "organisms/" + organisms[i] + "/data/";
                                    int ret = getOrganismStatus(organisms[i]);
                                    if (ret == -1)
                                        indexer = new Indexer(chromosomelist);
                                    else
                                        indexer = new Indexer(ret);

                                } else {
                                    filetype = "local";
                                    filepro = "local/" + organisms[i] + "/data/";
                                    String indexfile = "local/" + organisms[i] + "/index.txt";
                                    indexer = new Indexer(indexfile);
                                }
                                //List<String> files = getFiles(organisms[i], minlen, flag);

                                // 18/11/2013 added ending here
                                PrintWriter stats = null;
                                PrintWriter html = null;
                                PrintWriter motifstats = null;
                                PrintWriter motifhtml = null;
                                DataOutputStream lt = null;
                                if (filetype.contains("organisms")) {

                                    File f = new File("organisms/" + organisms[i] + "/stats/");
                                    if (!f.exists()) {
                                        f.mkdir();
                                    }

                                    stats = new PrintWriter(new FileWriter("organisms/" + organisms[i]
                                            + "/stats/" + "summary_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt",
                                            true));
                                    motifstats = new PrintWriter(new FileWriter("organisms/" + organisms[i]
                                            + "/stats/" + "motif_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt",
                                            true));
                                    motifhtml = new PrintWriter(new FileWriter("organisms/" + organisms[i]
                                            + "/stats/" + "motif_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".html",
                                            true));

                                    html = new PrintWriter(new FileWriter("organisms/" + organisms[i]
                                            + "/stats/" + "summary_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".html",
                                            true));

                                    lt = new DataOutputStream(new BufferedOutputStream(
                                            new FileOutputStream("organisms/" + organisms[i] + "/data/"
                                                    + now.toString().replace(':', '_').replace(' ', '_')
                                                    + ".perf")));

                                    File fi = new File("organisms/" + organisms[i] + "/results/");
                                    if (!fi.exists()) {
                                        fi.mkdir();
                                    }
                                    String toopen = "organisms/" + organisms[i] + "/results/allPerfect_"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                                    location = toopen;
                                    location2 = "organisms/" + organisms[i] + "/stats/" + "motif_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                                    out = new PrintWriter(toopen);

                                    out.println("Results for organism: " + organisms[i]
                                            + "\t Search Parameters --> Minimum SSR Length (bp): " + minlen);
                                    out.println(
                                            "   SSR      repeats             start-end  length  Path(../organism/data/chromosome)");

                                } else if (filetype.contains("local")) {
                                    File f = new File("local/" + organisms[i] + "/stats/");
                                    if (!f.exists()) {
                                        f.mkdir();
                                    }

                                    stats = new PrintWriter(new FileWriter("local/" + organisms[i] + "/stats/"
                                            + "summary_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt",
                                            true));
                                    motifstats = new PrintWriter(new FileWriter("local/" + organisms[i]
                                            + "/stats/" + "motif_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt",
                                            true));
                                    motifhtml = new PrintWriter(new FileWriter("local/" + organisms[i]
                                            + "/stats/" + "motif_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".html",
                                            true));
                                    lt = new DataOutputStream(new BufferedOutputStream(
                                            new FileOutputStream("local/" + organisms[i] + "/data/"
                                                    + now.toString().replace(':', '_').replace(' ', '_')
                                                    + ".perf")));
                                    html = new PrintWriter(new FileWriter("local/" + organisms[i] + "/stats/"
                                            + "summary_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".html",
                                            true));

                                    File fi = new File("local/" + organisms[i] + "/results/");
                                    if (!fi.exists()) {
                                        fi.mkdir();
                                    }
                                    String toopen = "local/" + organisms[i] + "/results/allPerfect_"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                                    location = toopen;
                                    location2 = "local/" + organisms[i] + "/stats/" + "motif_statistics"
                                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                                    out = new PrintWriter(toopen);

                                    out.println("Results for project: " + organisms[i]
                                            + "\t Search Parameters --> Minimum SSR Length (bp): " + minlen);
                                    out.println(
                                            "   SSR      repeats             start-end  length  Path(../organism/data/chromosome)");
                                    out.println();
                                }

                                if (mono.isSelected()) {

                                    // 18/11/2013 added starting here

                                    if (flag) {
                                        filetype = "organisms";
                                        filepro = "organisms/" + organisms[i] + "/data/";
                                        int ret = getOrganismStatus(organisms[i]);
                                        if (ret == -1)
                                            indexer = new Indexer(chromosomelist);
                                        else
                                            indexer = new Indexer(ret);

                                    } else {
                                        filetype = "local";
                                        filepro = "local/" + organisms[i] + "/data/";
                                        String indexfile = "local/" + organisms[i] + "/index.txt";
                                        indexer = new Indexer(indexfile);
                                    }
                                    //List<String> files = getFiles(organisms[i], minlen, flag);
                                    //for (int j = 0; j < files.size(); j++) {
                                    while (indexer.hasNext()) {
                                        String files = filepro + indexer.getNextFileName();

                                        DataInputStream in = new DataInputStream(
                                                new BufferedInputStream(new FileInputStream(
                                                        files + "_" + minlen + "_monoPerfect.temp")));
                                        boolean eof = false;
                                        while (!eof) {
                                            try {

                                                String ssr = in.readUTF();
                                                int repeats = in.readInt();
                                                int end = in.readInt();
                                                out.println(cell(ssr, 6) + "  " + cell(repeats, 11) + "  "
                                                        + cell(Integer
                                                                .toString(end - repeats * ssr.length() + 1)
                                                                + "-" + Integer.toString(end + 1), 20)
                                                        + "  " + cell(repeats * ssr.length(), 6) + "  "
                                                        + files.substring(0, files.lastIndexOf('.')));

                                                // map for motifstats 
                                                if (!map.containsKey(ssr)) {
                                                    motifStats m = new motifStats(ssr, repeats);
                                                    map.put(ssr, m);
                                                } else {
                                                    map.get(ssr).update(repeats);
                                                }

                                            } catch (EOFException exc) {
                                                eof = true;
                                            }
                                        }
                                        in.close();
                                    }
                                }
                                if (di.isSelected()) {
                                    //for (int j = 0; j < files.size(); j++) {

                                    // 18/11/2013 added starting here

                                    if (flag) {
                                        filetype = "organisms";
                                        filepro = "organisms/" + organisms[i] + "/data/";
                                        int ret = getOrganismStatus(organisms[i]);
                                        if (ret == -1)
                                            indexer = new Indexer(chromosomelist);
                                        else
                                            indexer = new Indexer(ret);

                                    } else {
                                        filetype = "local";
                                        filepro = "local/" + organisms[i] + "/data/";
                                        String indexfile = "local/" + organisms[i] + "/index.txt";
                                        indexer = new Indexer(indexfile);
                                    }
                                    //List<String> files = getFiles(organisms[i], minlen, flag);
                                    while (indexer.hasNext()) {
                                        String files = filepro + indexer.getNextFileName();

                                        DataInputStream in = new DataInputStream(new BufferedInputStream(
                                                new FileInputStream(files + "_" + minlen + "_diPerfect.temp")));
                                        boolean eof = false;
                                        while (!eof) {
                                            try {
                                                String ssr = in.readUTF();
                                                int repeats = in.readInt();
                                                int end = in.readInt();
                                                //out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.')));
                                                out.println(cell(ssr, 6) + "  " + cell(repeats, 11) + "  "
                                                        + cell(Integer
                                                                .toString(end - repeats * ssr.length() + 1)
                                                                + "-" + Integer.toString(end + 1), 20)
                                                        + "  " + cell(repeats * ssr.length(), 6) + "  "
                                                        + files.substring(0, files.lastIndexOf('.')));

                                                if (!map.containsKey(ssr)) {
                                                    motifStats m = new motifStats(ssr, repeats);
                                                    map.put(ssr, m);
                                                } else {
                                                    map.get(ssr).update(repeats);
                                                }

                                            } catch (EOFException exc) {
                                                eof = true;
                                            }
                                        }
                                        in.close();
                                    }
                                }
                                if (tri.isSelected()) {
                                    // 18/11/2013 added starting here

                                    if (flag) {
                                        filetype = "organisms";
                                        filepro = "organisms/" + organisms[i] + "/data/";
                                        int ret = getOrganismStatus(organisms[i]);
                                        if (ret == -1)
                                            indexer = new Indexer(chromosomelist);
                                        else
                                            indexer = new Indexer(ret);

                                    } else {
                                        filetype = "local";
                                        filepro = "local/" + organisms[i] + "/data/";
                                        String indexfile = "local/" + organisms[i] + "/index.txt";
                                        indexer = new Indexer(indexfile);
                                    }
                                    //for (int j = 0; j < files.size(); j++) {
                                    while (indexer.hasNext()) {
                                        String files = filepro + indexer.getNextFileName();

                                        DataInputStream in = new DataInputStream(
                                                new BufferedInputStream(new FileInputStream(
                                                        files + "_" + minlen + "_triPerfect.temp")));
                                        boolean eof = false;
                                        while (!eof) {
                                            try {
                                                String ssr = in.readUTF();
                                                int repeats = in.readInt();
                                                int end = in.readInt();
                                                //out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.')));
                                                out.println(cell(ssr, 6) + "  " + cell(repeats, 11) + "  "
                                                        + cell(Integer
                                                                .toString(end - repeats * ssr.length() + 1)
                                                                + "-" + Integer.toString(end + 1), 20)
                                                        + "  " + cell(repeats * ssr.length(), 6) + "  "
                                                        + files.substring(0, files.lastIndexOf('.')));

                                                if (!map.containsKey(ssr)) {
                                                    motifStats m = new motifStats(ssr, repeats);
                                                    map.put(ssr, m);
                                                } else {
                                                    map.get(ssr).update(repeats);
                                                }

                                            } catch (EOFException exc) {
                                                eof = true;
                                            }
                                        }
                                        in.close();
                                    }
                                }
                                if (tetra.isSelected()) {
                                    // 18/11/2013 added starting here

                                    if (flag) {
                                        filetype = "organisms";
                                        filepro = "organisms/" + organisms[i] + "/data/";
                                        int ret = getOrganismStatus(organisms[i]);
                                        if (ret == -1)
                                            indexer = new Indexer(chromosomelist);
                                        else
                                            indexer = new Indexer(ret);

                                    } else {
                                        filetype = "local";
                                        filepro = "local/" + organisms[i] + "/data/";
                                        String indexfile = "local/" + organisms[i] + "/index.txt";
                                        indexer = new Indexer(indexfile);
                                    }
                                    while (indexer.hasNext()) {
                                        String files = filepro + indexer.getNextFileName();

                                        DataInputStream in = new DataInputStream(
                                                new BufferedInputStream(new FileInputStream(
                                                        files + "_" + minlen + "_tetraPerfect.temp")));
                                        boolean eof = false;
                                        while (!eof) {
                                            try {
                                                String ssr = in.readUTF();
                                                int repeats = in.readInt();
                                                int end = in.readInt();
                                                // out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.')));
                                                out.println(cell(ssr, 6) + "  " + cell(repeats, 11) + "  "
                                                        + cell(Integer
                                                                .toString(end - repeats * ssr.length() + 1)
                                                                + "-" + Integer.toString(end + 1), 20)
                                                        + "  " + cell(repeats * ssr.length(), 6) + "  "
                                                        + files.substring(0, files.lastIndexOf('.')));

                                                if (!map.containsKey(ssr)) {
                                                    motifStats m = new motifStats(ssr, repeats);
                                                    map.put(ssr, m);
                                                } else {
                                                    map.get(ssr).update(repeats);
                                                }

                                            } catch (EOFException exc) {
                                                eof = true;
                                            }
                                        }
                                        in.close();
                                    }
                                }
                                if (penta.isSelected()) {
                                    // 18/11/2013 added starting here

                                    if (flag) {
                                        filetype = "organisms";
                                        filepro = "organisms/" + organisms[i] + "/data/";
                                        int ret = getOrganismStatus(organisms[i]);
                                        if (ret == -1)
                                            indexer = new Indexer(chromosomelist);
                                        else
                                            indexer = new Indexer(ret);

                                    } else {
                                        filetype = "local";
                                        filepro = "local/" + organisms[i] + "/data/";
                                        String indexfile = "local/" + organisms[i] + "/index.txt";
                                        indexer = new Indexer(indexfile);
                                    }
                                    while (indexer.hasNext()) {
                                        String files = filepro + indexer.getNextFileName();

                                        DataInputStream in = new DataInputStream(
                                                new BufferedInputStream(new FileInputStream(
                                                        files + "_" + minlen + "_pentaPerfect.temp")));
                                        boolean eof = false;
                                        while (!eof) {
                                            try {
                                                String ssr = in.readUTF();
                                                int repeats = in.readInt();
                                                int end = in.readInt();
                                                //  out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.')));
                                                out.println(cell(ssr, 6) + "  " + cell(repeats, 11) + "  "
                                                        + cell(Integer
                                                                .toString(end - repeats * ssr.length() + 1)
                                                                + "-" + Integer.toString(end + 1), 20)
                                                        + "  " + cell(repeats * ssr.length(), 6) + "  "
                                                        + files.substring(0, files.lastIndexOf('.')));

                                                if (!map.containsKey(ssr)) {
                                                    motifStats m = new motifStats(ssr, repeats);
                                                    map.put(ssr, m);
                                                } else {
                                                    map.get(ssr).update(repeats);
                                                }

                                            } catch (EOFException exc) {
                                                eof = true;
                                            }
                                        }
                                        in.close();
                                    }
                                }
                                if (hexa.isSelected()) {
                                    // 18/11/2013 added starting here

                                    if (flag) {
                                        filetype = "organisms";
                                        filepro = "organisms/" + organisms[i] + "/data/";
                                        int ret = getOrganismStatus(organisms[i]);
                                        if (ret == -1)
                                            indexer = new Indexer(chromosomelist);
                                        else
                                            indexer = new Indexer(ret);

                                    } else {
                                        filetype = "local";
                                        filepro = "local/" + organisms[i] + "/data/";
                                        String indexfile = "local/" + organisms[i] + "/index.txt";
                                        indexer = new Indexer(indexfile);
                                    }
                                    while (indexer.hasNext()) {
                                        String files = filepro + indexer.getNextFileName();

                                        DataInputStream in = new DataInputStream(
                                                new BufferedInputStream(new FileInputStream(
                                                        files + "_" + minlen + "_hexaPerfect.temp")));
                                        boolean eof = false;
                                        while (!eof) {
                                            try {
                                                String ssr = in.readUTF();
                                                int repeats = in.readInt();
                                                int end = in.readInt();
                                                // out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.')));
                                                out.println(cell(ssr, 6) + "  " + cell(repeats, 11) + "  "
                                                        + cell(Integer
                                                                .toString(end - repeats * ssr.length() + 1)
                                                                + "-" + Integer.toString(end + 1), 20)
                                                        + "  " + cell(repeats * ssr.length(), 6) + "  "
                                                        + files.substring(0, files.lastIndexOf('.')));

                                                if (!map.containsKey(ssr)) {
                                                    motifStats m = new motifStats(ssr, repeats);
                                                    map.put(ssr, m);
                                                } else {
                                                    map.get(ssr).update(repeats);
                                                }

                                            } catch (EOFException exc) {
                                                eof = true;
                                            }
                                        }
                                        in.close();
                                    }
                                }

                                out.close();
                                Runtime.getRuntime().exec("notepad " + location);

                                DecimalFormat round = new DecimalFormat("#.###");

                                html.println("<html><h1>******* Perfect SSRs *******</h1>");
                                html.println("<h4>Results for project: " + organisms[i]
                                        + "</h4><h4>Search Parameters --> Minimum SSR Length (bp): " + minlen
                                        + "</h4>");
                                html.println(
                                        "<table border=\"1\"><tr><td><b>motif</b></td><td><b>count</b></td><td><b>bp</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td><td><b>Relative Frequency</b></td><td><b>Abundance</b></td><td><b>Relative Abundance</b></td></tr>");
                                stats.println("******* Perfect SSRs *******");
                                stats.println("Results for project: " + organisms[i]
                                        + "\n Search Parameters --> Minimum SSR Length (bp): " + minlen);

                                stats.println(
                                        " ____________________________________________________________________________________________________________ ");
                                stats.println(
                                        "|       |       |            |       |       |       |       |   Relative    |               |   Relative    |");
                                stats.println(
                                        "| motif | count |     bp     |   A%  |   T%  |   C%  |   G%  |   Frequency   |   Abundance   |   Abundance   |");
                                stats.println(
                                        "|=======|=======|============|=======|=======|=======|=======|===============|===============|===============|");
                                int totalcount = 0;
                                long bpcount = 0;
                                int Aperc = 0;
                                int Tperc = 0;
                                int Gperc = 0;
                                int Cperc = 0;
                                float relfreq = 0;
                                float abfreq = 0;
                                long seqcount = 0;
                                if (mono.isSelected()) {
                                    totalcount += countmono.get(i);
                                    bpcount += countmonore.get(i);
                                }
                                if (di.isSelected()) {
                                    totalcount += countdi.get(i);
                                    bpcount += countdire.get(i) * 2;
                                }
                                if (tri.isSelected()) {
                                    totalcount += counttri.get(i);
                                    bpcount += counttrire.get(i) * 3;
                                }
                                if (tetra.isSelected()) {
                                    totalcount += counttetra.get(i);
                                    bpcount += counttetrare.get(i) * 4;
                                }
                                if (penta.isSelected()) {
                                    totalcount += countpenta.get(i);
                                    bpcount += countpentare.get(i) * 5;
                                }
                                if (hexa.isSelected()) {
                                    totalcount += counthexa.get(i);
                                    bpcount += counthexare.get(i) * 6;
                                }
                                try {
                                    Class.forName("com.mysql.jdbc.Driver");
                                } catch (ClassNotFoundException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                                Connection con = null;
                                try {
                                    con = DriverManager.getConnection("jdbc:mysql://localhost:3306", "biouser",
                                            "thesis2012");
                                } catch (SQLException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                                Statement st = null;
                                try {
                                    st = con.createStatement();
                                } catch (SQLException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                                st.executeUpdate("use lobid");

                                seqcount = 0;

                                if (filetype.contains("organisms")) {
                                    ResultSet rs = st.executeQuery(
                                            "SELECT end FROM slices INNER JOIN organism WHERE slices.org_id=organism.org_id AND organism.name='"
                                                    + organisms[i] + "'");
                                    while (rs.next()) {
                                        seqcount += Long.parseLong(rs.getString(1));
                                    }
                                } else if (filetype.contains("local")) {
                                    BufferedReader in = new BufferedReader(
                                            new FileReader("local/" + organisms[i] + "/index.txt"));
                                    int count = countlines("local/" + organisms[i] + "/index.txt");
                                    for (int c = 0; c < count; c++) {
                                        String temp = in.readLine();
                                        BufferedReader tmp = new BufferedReader(
                                                new FileReader("local/" + organisms[i] + "/" + temp + ".txt"));

                                        boolean eof = false;
                                        while (!eof) {
                                            String s = tmp.readLine();
                                            if (s != null) {
                                                seqcount += s.length();
                                            } else {
                                                eof = true;
                                            }
                                        }
                                        tmp.close();
                                    }
                                }

                                if (mono.isSelected()) {
                                    Aperc += Amono.get(i);
                                    Tperc += Tmono.get(i);
                                    Gperc += Gmono.get(i);
                                    Cperc += Cmono.get(i);
                                    //lt.writeInt(countmono);lt.writeInt(countmonore);lt.writeFloat((float)Amono*100/countmonore);lt.writeFloat((float)Tmono*100/countmonore);lt.writeFloat((float)Gmono*100/countmonore);lt.writeFloat((float)Cmono*100/countmonore);lt.writeFloat((float) countmono / totalcount);lt.writeFloat((float) countmonore / seqcount);lt.writeFloat((float) countmonore / bpcount);
                                    stats.printf("|mono   |" + cell(Integer.toString(countmono.get(i)), 7) + "|"
                                            + cell(Integer.toString(1 * countmonore.get(i)), 12)
                                            + "|%s|%s|%s|%s|" + cell((float) countmono.get(i) / totalcount, 15)
                                            + "|" + cell((float) countmonore.get(i) / seqcount, 15) + "|"
                                            + cell((float) countmonore.get(i) / bpcount, 15) + "|\n",
                                            cell((float) (Amono.get(i) * 100) / (countmonore.get(i)), 7),
                                            cell((float) (Tmono.get(i) * 100) / (countmonore.get(i)), 7),
                                            cell((float) (Cmono.get(i) * 100) / (countmonore.get(i)), 7),
                                            cell((float) (Gmono.get(i) * 100) / (countmonore.get(i)), 7));
                                    stats.println(
                                            "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                    html.println("<tr><td><b>mono</b></td><td>" + countmono.get(i) + "</td><td>"
                                            + (1 * countmonore.get(i)) + "</td><td>"
                                            + round.format((float) (Amono.get(i) * 100) / (countmonore.get(i)))
                                            + "</td><td>"
                                            + round.format((float) (Tmono.get(i) * 100) / (countmonore.get(i)))
                                            + "</td><td>"
                                            + round.format((float) (Cmono.get(i) * 100) / (countmonore.get(i)))
                                            + "</td><td>"
                                            + round.format((float) (Gmono.get(i) * 100) / (countmonore.get(i)))
                                            + "</td><td>" + round.format((float) countmono.get(i) / totalcount)
                                            + "</td><td>" + round.format((float) countmonore.get(i) / seqcount)
                                            + "</td><td>" + round.format((float) countmonore.get(i) / bpcount)
                                            + "</td></tr>");
                                }
                                if (di.isSelected()) {
                                    Aperc += Adi.get(i);
                                    Tperc += Tdi.get(i);
                                    Gperc += Gdi.get(i);
                                    Cperc += Cdi.get(i);

                                    //lt.writeInt(countdi);lt.writeInt(countdire*2);lt.writeFloat((float)Adi*100/countdire*2);lt.writeFloat((float)Tdi*100/countdire*2);lt.writeFloat((float)Gdi*100/countdire*2);lt.writeFloat((float)Cdi*100/countdire*2);lt.writeFloat((float) countdi / totalcount);lt.writeFloat((float) countdire*2 / seqcount);lt.writeFloat((float) countdire*2 / bpcount);
                                    stats.printf("|di     |" + cell(Integer.toString(countdi.get(i)), 7) + "|"
                                            + cell(Integer.toString(countdire.get(i) * 2), 12) + "|%s|%s|%s|%s|"
                                            + cell((float) countdi.get(i) / totalcount, 15) + "|"
                                            + cell((float) countdire.get(i) * 2 / seqcount, 15) + "|"
                                            + cell((float) countdire.get(i) * 2 / bpcount, 15) + "|\n",
                                            cell((float) (Adi.get(i) * 100) / (countdire.get(i) * 2), 7),
                                            cell((float) (Tdi.get(i) * 100) / (countdire.get(i) * 2), 7),
                                            cell((float) (Cdi.get(i) * 100) / (countdire.get(i) * 2), 7),
                                            cell((float) (Gdi.get(i) * 100) / (countdire.get(i) * 2), 7));
                                    stats.println(
                                            "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                    html.println("<tr><td><b>di</b></td><td>" + countdi.get(i) + "</td><td>"
                                            + (2 * countdire.get(i)) + "</td><td>"
                                            + round.format((float) (Adi.get(i) * 100) / (2 * countdire.get(i)))
                                            + "</td><td>"
                                            + round.format((float) (Tdi.get(i) * 100) / (2 * countdire.get(i)))
                                            + "</td><td>"
                                            + round.format((float) (Cdi.get(i) * 100) / (2 * countdire.get(i)))
                                            + "</td><td>"
                                            + round.format((float) (Gdi.get(i) * 100) / (2 * countdire.get(i)))
                                            + "</td><td>" + round.format((float) countdi.get(i) / totalcount)
                                            + "</td><td>"
                                            + round.format((float) 2 * countdire.get(i) / seqcount)
                                            + "</td><td>" + round.format((float) 2 * countdire.get(i) / bpcount)
                                            + "</td></tr>");
                                }
                                if (tri.isSelected()) {
                                    Aperc += Atri.get(i);
                                    Tperc += Ttri.get(i);
                                    Gperc += Gtri.get(i);
                                    Cperc += Ctri.get(i);
                                    //lt.writeInt(counttri);lt.writeInt(counttrire*3);lt.writeFloat((float)Atri*100/counttrire*3);lt.writeFloat((float)Ttri*100/counttrire*3);lt.writeFloat((float)Gtri*100/counttrire*3);lt.writeFloat((float)Ctri*100/counttrire*3);lt.writeFloat((float) counttri / totalcount);lt.writeFloat((float) counttrire*3 / seqcount);lt.writeFloat((float) counttrire*3 / bpcount);
                                    stats.printf("|tri    |" + cell(Integer.toString(counttri.get(i)), 7) + "|"
                                            + cell(Integer.toString(counttrire.get(i) * 3), 12)
                                            + "|%s|%s|%s|%s|" + cell((float) counttri.get(i) / totalcount, 15)
                                            + "|" + cell((float) counttrire.get(i) * 3 / seqcount, 15) + "|"
                                            + cell((float) counttrire.get(i) * 3 / bpcount, 15) + "|\n",
                                            cell((float) (Atri.get(i) * 100) / (counttrire.get(i) * 3), 7),
                                            cell((float) (Ttri.get(i) * 100) / (counttrire.get(i) * 3), 7),
                                            cell((float) (Ctri.get(i) * 100) / (counttrire.get(i) * 3), 7),
                                            cell((float) (Gtri.get(i) * 100) / (counttrire.get(i) * 3), 7));
                                    stats.println(
                                            "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                    html.println("<tr><td><b>tri</b></td><td>" + counttri.get(i) + "</td><td>"
                                            + (3 * counttrire.get(i)) + "</td><td>"
                                            + round.format(
                                                    (float) (Atri.get(i) * 100) / (3 * counttrire.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Ttri.get(i) * 100) / (3 * counttrire.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Ctri.get(i) * 100) / (3 * counttrire.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Gtri.get(i) * 100) / (3 * counttrire.get(i)))
                                            + "</td><td>" + round.format((float) counttri.get(i) / totalcount)
                                            + "</td><td>"
                                            + round.format((float) 3 * counttrire.get(i) / seqcount)
                                            + "</td><td>"
                                            + round.format((float) 3 * counttrire.get(i) / bpcount)
                                            + "</td></tr>");
                                }
                                if (tetra.isSelected()) {
                                    Aperc += Atetra.get(i);
                                    Tperc += Ttetra.get(i);
                                    Gperc += Gtetra.get(i);
                                    Cperc += Ctetra.get(i);
                                    //lt.writeInt(counttetra);lt.writeInt(counttetrare*4);lt.writeFloat((float)Atetra*100/counttetrare*4);lt.writeFloat((float)Ttetra*100/counttetrare*4);lt.writeFloat((float)Gtetra*100/counttetrare*4);lt.writeFloat((float)Ctetra*100/counttetrare*4);lt.writeFloat((float) counttetra / totalcount);lt.writeFloat((float) counttetrare*4 / seqcount);lt.writeFloat((float) counttetrare*4 / bpcount);
                                    stats.printf("|tetra  |" + cell(Integer.toString(counttetra.get(i)), 7)
                                            + "|" + cell(Integer.toString(counttetrare.get(i) * 4), 12)
                                            + "|%s|%s|%s|%s|" + cell((float) counttetra.get(i) / totalcount, 15)
                                            + "|" + cell((float) counttetrare.get(i) * 4 / seqcount, 15) + "|"
                                            + cell((float) counttetrare.get(i) * 4 / bpcount, 15) + "|\n",
                                            cell((float) (Atetra.get(i) * 100) / (counttetrare.get(i) * 4), 7),
                                            cell((float) (Ttetra.get(i) * 100) / (counttetrare.get(i) * 4), 7),
                                            cell((float) (Ctetra.get(i) * 100) / (counttetrare.get(i) * 4), 7),
                                            cell((float) (Gtetra.get(i) * 100) / (counttetrare.get(i) * 4), 7));
                                    stats.println(
                                            "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                    html.println("<tr><td><b>tetra</b></td><td>" + counttetra.get(i)
                                            + "</td><td>" + (4 * counttetrare.get(i)) + "</td><td>"
                                            + round.format(
                                                    (float) (Atetra.get(i) * 100) / (4 * counttetrare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Ttetra.get(i) * 100) / (4 * counttetrare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Ctetra.get(i) * 100) / (4 * counttetrare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Gtetra.get(i) * 100) / (4 * counttetrare.get(i)))
                                            + "</td><td>" + round.format((float) counttetra.get(i) / totalcount)
                                            + "</td><td>"
                                            + round.format((float) 4 * counttetrare.get(i) / seqcount)
                                            + "</td><td>"
                                            + round.format((float) 4 * counttetrare.get(i) / bpcount)
                                            + "</td></tr>");
                                }
                                if (penta.isSelected()) {
                                    Aperc += Apenta.get(i);
                                    Tperc += Tpenta.get(i);
                                    Gperc += Gpenta.get(i);
                                    Cperc += Cpenta.get(i);
                                    //lt.writeInt(countpenta);lt.writeInt(countpentare*5);lt.writeFloat((float)Apenta*100/countpentare*5);lt.writeFloat((float)Tpenta*100/countpentare*5);lt.writeFloat((float)Gpenta*100/countpentare*5);lt.writeFloat((float)Cpenta*100/countpentare*5);lt.writeFloat((float) countpenta / totalcount);lt.writeFloat((float) countpentare*5 / seqcount);lt.writeFloat((float) countpentare*5 / bpcount);
                                    stats.printf("|penta  |" + cell(Integer.toString(countpenta.get(i)), 7)
                                            + "|" + cell(Integer.toString(countpentare.get(i) * 5), 12)
                                            + "|%s|%s|%s|%s|" + cell((float) countpenta.get(i) / totalcount, 15)
                                            + "|" + cell((float) countpentare.get(i) * 5 / seqcount, 15) + "|"
                                            + cell((float) countpentare.get(i) * 5 / bpcount, 15) + "|\n",
                                            cell((float) (Apenta.get(i) * 100) / (countpentare.get(i) * 5), 7),
                                            cell((float) (Tpenta.get(i) * 100) / (countpentare.get(i) * 5), 7),
                                            cell((float) (Cpenta.get(i) * 100) / (countpentare.get(i) * 5), 7),
                                            cell((float) (Gpenta.get(i) * 100) / (countpentare.get(i) * 5), 7));
                                    stats.println(
                                            "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                    html.println("<tr><td><b>penta</b></td><td>" + countpenta.get(i)
                                            + "</td><td>" + (5 * countpentare.get(i)) + "</td><td>"
                                            + round.format(
                                                    (float) (Apenta.get(i) * 100) / (5 * countpentare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Tpenta.get(i) * 100) / (5 * countpentare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Cpenta.get(i) * 100) / (5 * countpentare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Gpenta.get(i) * 100) / (5 * countpentare.get(i)))
                                            + "</td><td>" + round.format((float) countpenta.get(i) / totalcount)
                                            + "</td><td>"
                                            + round.format((float) 5 * countpentare.get(i) / seqcount)
                                            + "</td><td>"
                                            + round.format((float) 5 * countpentare.get(i) / bpcount)
                                            + "</td></tr>");
                                }
                                if (hexa.isSelected()) {
                                    Aperc += Ahexa.get(i);
                                    Tperc += Thexa.get(i);
                                    Gperc += Ghexa.get(i);
                                    Cperc += Chexa.get(i);
                                    //lt.writeInt(counthexa);lt.writeInt(counthexare*6);lt.writeFloat((float)Ahexa*100/counthexare*6);lt.writeFloat((float)Thexa*100/counthexare*6);lt.writeFloat((float)Ghexa*100/counthexare*6);lt.writeFloat((float)Chexa*100/counthexare*6);lt.writeFloat((float) counthexa / totalcount);lt.writeFloat((float) counthexare*6 / seqcount);lt.writeFloat((float) counthexare*6 / bpcount);
                                    stats.printf("|hexa   |" + cell(Integer.toString(counthexa.get(i)), 7) + "|"
                                            + cell(Integer.toString(counthexare.get(i) * 6), 12)
                                            + "|%s|%s|%s|%s|" + cell((float) counthexa.get(i) / totalcount, 15)
                                            + "|" + cell((float) counthexare.get(i) * 6 / seqcount, 15) + "|"
                                            + cell((float) counthexare.get(i) * 6 / bpcount, 15) + "|\n",
                                            cell((float) (Ahexa.get(i) * 100) / (counthexare.get(i) * 6), 7),
                                            cell((float) (Thexa.get(i) * 100) / (counthexare.get(i) * 6), 7),
                                            cell((float) (Chexa.get(i) * 100) / (counthexare.get(i) * 6), 7),
                                            cell((float) (Ghexa.get(i) * 100) / (counthexare.get(i) * 6), 7));
                                    stats.println(
                                            "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                    html.println("<tr><td><b>hexa</b></td><td>" + counthexa.get(i) + "</td><td>"
                                            + (6 * counthexare.get(i)) + "</td><td>"
                                            + round.format(
                                                    (float) (Ahexa.get(i) * 100) / (6 * counthexare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Thexa.get(i) * 100) / (6 * counthexare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Chexa.get(i) * 100) / (6 * counthexare.get(i)))
                                            + "</td><td>"
                                            + round.format(
                                                    (float) (Ghexa.get(i) * 100) / (6 * counthexare.get(i)))
                                            + "</td><td>" + round.format((float) counthexa.get(i) / totalcount)
                                            + "</td><td>"
                                            + round.format((float) 6 * counthexare.get(i) / seqcount)
                                            + "</td><td>"
                                            + round.format((float) 6 * counthexare.get(i) / bpcount)
                                            + "</td></tr>");
                                }

                                if (mono.isSelected()) {
                                    relfreq += (float) countmono.get(i) / totalcount;
                                    abfreq += (float) countmonore.get(i) / bpcount;
                                }
                                if (di.isSelected()) {
                                    relfreq += (float) countdi.get(i) / totalcount;
                                    abfreq += (float) countdire.get(i) * 2 / bpcount;
                                }
                                if (tri.isSelected()) {
                                    relfreq += (float) counttri.get(i) / totalcount;
                                    abfreq += (float) counttrire.get(i) * 3 / bpcount;
                                }
                                if (tetra.isSelected()) {
                                    relfreq += (float) counttetra.get(i) / totalcount;
                                    abfreq += (float) counttetrare.get(i) * 4 / bpcount;
                                }
                                if (penta.isSelected()) {
                                    relfreq += (float) countpenta.get(i) / totalcount;
                                    abfreq += (float) countpentare.get(i) * 5 / bpcount;
                                }
                                if (hexa.isSelected()) {
                                    relfreq += (float) counthexa.get(i) / totalcount;
                                    abfreq += (float) counthexare.get(i) * 6 / bpcount;
                                }

                                Globals.A = Aperc;
                                Globals.T = Tperc;
                                Globals.G = Gperc;
                                Globals.C = Cperc;

                                lt.writeLong(seqcount);
                                lt.writeInt(totalcount);
                                lt.writeLong(bpcount);
                                lt.writeInt(Aperc);
                                lt.writeInt(Tperc);
                                lt.writeInt(Gperc);
                                lt.writeInt(Cperc);
                                stats.println("|TOTAL  |" + cell(Integer.toString(totalcount), 7) + "|"
                                        + cell(Long.toString(bpcount), 12) + "|"
                                        + cell((float) Aperc * 100 / bpcount, 7) + "|"
                                        + cell((float) Tperc * 100 / bpcount, 7) + "|"
                                        + cell((float) Cperc * 100 / bpcount, 7) + "|"
                                        + cell((float) Gperc * 100 / bpcount, 7) + "|" + cell(relfreq, 15) + "|"
                                        + cell((float) bpcount / seqcount, 15) + "|" + cell((float) abfreq, 15)
                                        + "|");
                                stats.println(
                                        "|_______|_______|____________|_______|_______|_______|_______|_______________|_______________|_______________|");
                                stats.println("Genome length (bp): " + seqcount);
                                stats.println("Relative Frequency: Count of each motif type / total SSR count");
                                stats.println("Abundance: bp of each motif type / total sequence bp");
                                stats.println(
                                        "Relative Abundance: bp of each motif type / total microsatellites bp");
                                stats.println();
                                stats.println();
                                stats.close();
                                lt.close();

                                html.println("<tr><td><b>TOTAL</b></td><td>" + totalcount + "</td><td>"
                                        + bpcount + "</td><td>" + round.format((float) Aperc * 100 / bpcount)
                                        + "</td><td>" + round.format((float) Tperc * 100 / bpcount)
                                        + "</td><td>" + round.format((float) Cperc * 100 / bpcount)
                                        + "</td><td>" + round.format((float) Gperc * 100 / bpcount)
                                        + "</td><td>" + round.format((float) relfreq) + "</td><td>"
                                        + round.format((float) bpcount / seqcount) + "</td><td>"
                                        + round.format((float) abfreq) + "</td></tr></table></html>");
                                html.close();

                                // it = map.keySet().iterator();

                                for (String key : map.keySet()) {
                                    map.get(key).refresh();
                                }

                                List<String> n1 = new ArrayList<String>();
                                List<String> n2 = new ArrayList<String>();
                                List<String> n3 = new ArrayList<String>();
                                List<String> n4 = new ArrayList<String>();
                                List<String> n5 = new ArrayList<String>();
                                List<String> n6 = new ArrayList<String>();

                                Iterator<String> it = map.keySet().iterator();

                                while (it.hasNext()) {
                                    String next = it.next();
                                    int len = next.length();
                                    if (len == 1)
                                        n1.add(next);
                                    else if (len == 2)
                                        n2.add(next);
                                    else if (len == 3)
                                        n3.add(next);
                                    else if (len == 4)
                                        n4.add(next);
                                    else if (len == 5)
                                        n5.add(next);
                                    else if (len == 6)
                                        n6.add(next);

                                }

                                Collections.sort(n1);
                                Collections.sort(n2);
                                Collections.sort(n3);
                                Collections.sort(n4);
                                Collections.sort(n5);
                                Collections.sort(n6);

                                boolean[] id1 = new boolean[n1.size()];
                                boolean[] id2 = new boolean[n2.size()];
                                boolean[] id3 = new boolean[n3.size()];
                                boolean[] id4 = new boolean[n4.size()];
                                boolean[] id5 = new boolean[n5.size()];
                                boolean[] id6 = new boolean[n6.size()];

                                motifhtml.println("<html><head><title>Motif Statistics</title></head><body>");
                                int stand = checkStandardize();
                                // stand=2; debug
                                if (stand == 0) {
                                    motifstats.println("**** Not Standardized ****");
                                    motifhtml.println("<h1>**** Not Standardized ****</h1>");
                                    Arrays.fill(id1, true);
                                    Arrays.fill(id2, true);
                                    Arrays.fill(id3, true);
                                    Arrays.fill(id4, true);
                                    Arrays.fill(id5, true);
                                    Arrays.fill(id6, true);
                                } else {
                                    if (stand == 1) {
                                        motifstats.println("**** Partially Standardized ****");
                                        motifhtml.println("<h1>**** Partially Standardized ****</h1>");
                                        matrix = new parser(1);
                                    }
                                    if (stand == 2) {
                                        motifstats.println("**** Fully Standardized ****");
                                        motifhtml.println("<h1>**** Fully Standardized ****</h1>");
                                        matrix = new parser(2);
                                    }

                                    Arrays.fill(id1, true);
                                    Arrays.fill(id2, true);
                                    Arrays.fill(id3, true);
                                    Arrays.fill(id4, true);
                                    Arrays.fill(id5, true);
                                    Arrays.fill(id6, true);

                                    for (int n = 0; n < n1.size(); n++) {
                                        int id = -2;
                                        id = matrix.SearchMap(1, n1.get(n));
                                        if (id >= 0) {
                                            int found = matrix.checkFound(1, id);
                                            if (found >= 0) {
                                                map.get(n1.get(found)).merge(map.get(n1.get(n)));
                                                id1[n] = false; // gia clean twn listwn apo merged TODO *
                                            }
                                            if (found == -4) {
                                                matrix.makeFound(1, id, n);
                                            }
                                        }
                                    }

                                    for (int n = 0; n < n2.size(); n++) {
                                        int id = -2;
                                        id = matrix.SearchMap(2, n2.get(n));
                                        if (id >= 0) {
                                            int found = matrix.checkFound(2, id);
                                            if (found >= 0) {
                                                map.get(n2.get(found)).merge(map.get(n2.get(n)));
                                                id2[n] = false; // gia clean twn listwn apo merged TODO *
                                            } else {
                                                matrix.makeFound(2, id, n);
                                                id2[n] = true;
                                            }
                                        }
                                    }

                                    for (int n = 0; n < n3.size(); n++) {
                                        int id = -2;
                                        id = matrix.SearchMap(3, n3.get(n));
                                        if (id >= 0) {
                                            int found = matrix.checkFound(3, id);
                                            if (found >= 0) {
                                                map.get(n3.get(found)).merge(map.get(n3.get(n)));
                                                id3[n] = false; // gia clean twn listwn apo merged TODO *
                                            } else {
                                                matrix.makeFound(3, id, n);
                                                id3[n] = true;
                                            }
                                        }
                                    }

                                    for (int n = 0; n < n4.size(); n++) {
                                        int id = -2;
                                        id = matrix.SearchMap(4, n4.get(n));
                                        if (id >= 0) {
                                            int found = matrix.checkFound(4, id);
                                            if (found >= 0) {
                                                map.get(n4.get(found)).merge(map.get(n4.get(n)));
                                                id4[n] = false; // gia clean twn listwn apo merged TODO *
                                            } else {
                                                matrix.makeFound(4, id, n);
                                                id4[n] = true;
                                            }
                                        }
                                    }

                                    for (int n = 0; n < n5.size(); n++) {
                                        int id = -2;
                                        id = matrix.SearchMap(5, n5.get(n));
                                        if (id >= 0) {
                                            int found = matrix.checkFound(5, id);
                                            if (found >= 0) {
                                                map.get(n5.get(found)).merge(map.get(n5.get(n)));
                                                id5[n] = false; // gia clean twn listwn apo merged TODO *
                                            } else {
                                                matrix.makeFound(5, id, n);
                                                id5[n] = true;
                                            }
                                        }
                                    }

                                    for (int n = 0; n < n6.size(); n++) {
                                        int id = -2;
                                        id = matrix.SearchMap(6, n6.get(n));
                                        if (id >= 0) {
                                            int found = matrix.checkFound(6, id);
                                            if (found >= 0) {
                                                map.get(n6.get(found)).merge(map.get(n6.get(n)));
                                                id6[n] = false; // gia clean twn listwn apo merged TODO *
                                            } else {
                                                matrix.makeFound(6, id, n);
                                                id6[n] = true;
                                            }
                                        }
                                    }
                                }

                                for (String key : map.keySet()) {
                                    map.get(key).refresh();
                                }
                                motifstats.println(
                                        " Motif   Count  Repeats          bp  Avg_Length  SD_Length  Max_Length  Avg_Repeats    A%      T%      C%      G%    ");
                                motifhtml.println(
                                        "<table border=\"1\"><tr><td><b>Motif</b></td><td><b>Count</b></td><td><b>Repeats</b></td><td><b>bp</b></td><td><b>Avg_Length</b></td><td><b>SD_Length</b></td><td><b>Max_Length</b></td><td><b>Avg_Repeats</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td></tr>");
                                if (mono.isSelected()) {
                                    for (int z = 0; z < n1.size(); z++) {
                                        if (id1[z] && !map.get(n1.get(z)).getMotif().contains("N")) {
                                            motifstats.println(map.get(n1.get(z)).toString());
                                            motifhtml.println(map.get(n1.get(z)).toHTML());
                                        }

                                    }
                                }
                                if (di.isSelected()) {
                                    for (int z = 0; z < n2.size(); z++) {
                                        if (id2[z] && !map.get(n2.get(z)).getMotif().contains("N")) {
                                            motifstats.println(map.get(n2.get(z)).toString());
                                            motifhtml.println(map.get(n2.get(z)).toHTML());
                                        }
                                    }
                                }
                                if (tri.isSelected()) {
                                    for (int z = 0; z < n3.size(); z++) {
                                        if (id3[z] && !map.get(n3.get(z)).getMotif().contains("N")) {
                                            motifstats.println(map.get(n3.get(z)).toString());
                                            motifhtml.println(map.get(n3.get(z)).toHTML());
                                        }
                                    }
                                }
                                if (tetra.isSelected()) {
                                    for (int z = 0; z < n4.size(); z++) {
                                        if (id4[z] && !map.get(n4.get(z)).getMotif().contains("N")) {
                                            motifstats.println(map.get(n4.get(z)).toString());
                                            motifhtml.println(map.get(n4.get(z)).toHTML());
                                        }
                                    }
                                }
                                if (penta.isSelected()) {
                                    for (int z = 0; z < n5.size(); z++) {
                                        if (id5[z] && !map.get(n5.get(z)).getMotif().contains("N")) {
                                            motifstats.println(map.get(n5.get(z)).toString());
                                            motifhtml.println(map.get(n5.get(z)).toHTML());
                                        }
                                    }
                                }
                                if (hexa.isSelected()) {
                                    for (int z = 0; z < n6.size(); z++) {
                                        if (id6[z] && !map.get(n6.get(z)).getMotif().contains("N")) {
                                            motifstats.println(map.get(n6.get(z)).toString());
                                            motifhtml.println(map.get(n6.get(z)).toHTML());
                                        }
                                    }
                                }
                                motifstats.close();
                                motifhtml.println("</table></body></html>");
                                motifhtml.close();

                                Runtime.getRuntime().exec("notepad " + location2);

                            }

                        } catch (FileNotFoundException ex) {
                            //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE);
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (SQLException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (ClassNotFoundException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } else {
                        msg.showMessageDialog(paneldown, "Minimum length requires an Integer", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                } else {
                    msg.showMessageDialog(paneldown, "Please fill in the minimum length (Integers only)",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
            if (box2.isSelected()) {
                boolean gapisnumber = false;
                boolean minisnumber = false;
                int gap = 0;
                int min = 0;
                try {
                    gap = Integer.parseInt(max.getText());
                    gapisnumber = true;
                } catch (NumberFormatException ex) {
                    gapisnumber = false;
                }

                try {
                    min = Integer.parseInt(minpregap.getText());
                    minisnumber = true;
                } catch (NumberFormatException ex) {
                    minisnumber = false;
                }
                if (gapisnumber && minisnumber) {
                    try {
                        getImPerfectSSRs(organisms, min, flag, gap);

                        for (int i = 0; i < organisms.length; i++) {

                            PrintWriter stats = null;
                            PrintWriter html = null;

                            String location = ""; // 18/11/2013 added starting here
                            String filetype = "";
                            String filepro = "";

                            if (flag) {
                                filetype = "organisms";
                                filepro = "organisms/" + organisms[i] + "/data/";
                                int ret = getOrganismStatus(organisms[i]);
                                if (ret == -1)
                                    indexer = new Indexer(chromosomelist);
                                else
                                    indexer = new Indexer(ret);

                            } else {
                                filetype = "local";
                                filepro = "local/" + organisms[i] + "/data/";
                                String indexfile = "local/" + organisms[i] + "/index.txt";
                                indexer = new Indexer(indexfile);
                            }
                            //List<String> files = getFiles(organisms[i], minlen, flag);

                            // 18/11/2013 added ending here
                            PrintWriter out = null;
                            DataOutputStream lt = null;
                            if (filetype.contains("organisms")) {
                                File f = new File("organisms/" + organisms[i] + "/stats/");
                                if (!f.exists()) {
                                    f.mkdir();
                                }

                                stats = new PrintWriter(new FileWriter(
                                        "organisms/" + organisms[i] + "/stats/" + "summary_statistics"
                                                + now.toString().replace(':', '_').replace(' ', '_') + ".txt",
                                        true));
                                lt = new DataOutputStream(new BufferedOutputStream(
                                        new FileOutputStream("organisms/" + organisms[i] + "/data/"
                                                + now.toString().replace(':', '_').replace(' ', '_')
                                                + ".imperf")));
                                html = new PrintWriter(new FileWriter(
                                        "organisms/" + organisms[i] + "/stats/" + "summary_statistics"
                                                + now.toString().replace(':', '_').replace(' ', '_') + ".html",
                                        true));

                                File fi = new File("organisms/" + organisms[i] + "/results/");
                                if (!fi.exists()) {
                                    fi.mkdir();
                                }
                                String toopen = "organisms/" + organisms[i] + "/results/allImPerfect_"
                                        + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                                location = toopen;
                                out = new PrintWriter(toopen);

                                out.println("Results for organism: " + organisms[i]
                                        + "\t Search Parameters --> Maximum Mismatch length for ImPerfect SSRs : "
                                        + gap + " minimum SSR length before given gap: " + min);
                            } else if (filetype.contains("local")) {

                                File f = new File("local/" + organisms[i] + "/stats/");
                                if (!f.exists()) {
                                    f.mkdir();
                                }

                                stats = new PrintWriter(new FileWriter(
                                        "local/" + organisms[i] + "/stats/" + "summary_statistics"
                                                + now.toString().replace(':', '_').replace(' ', '_') + ".txt",
                                        true));
                                lt = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("local/"
                                        + organisms[i] + "/data/"
                                        + now.toString().replace(':', '_').replace(' ', '_') + ".imperf")));
                                html = new PrintWriter(new FileWriter(
                                        "local/" + organisms[i] + "/stats/" + "summary_statistics"
                                                + now.toString().replace(':', '_').replace(' ', '_') + ".html",
                                        true));

                                File fi = new File("local/" + organisms[i] + "/results/");
                                if (!fi.exists()) {
                                    fi.mkdir();
                                }
                                String toopen = "local/" + organisms[i] + "/results/allImPerfect_"
                                        + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                                location = toopen;
                                out = new PrintWriter(toopen);
                                out.println("Results for project: " + organisms[i]
                                        + "\t Search Parameters --> Maximum Mismatch length for ImPerfect SSRs : "
                                        + gap + " minimum SSR length before given gap: " + min);
                            }

                            if (mono.isSelected()) {
                                // 18/11/2013 added starting here

                                if (flag) {
                                    filetype = "organisms";
                                    filepro = "organisms/" + organisms[i] + "/data/";
                                    int ret = getOrganismStatus(organisms[i]);
                                    if (ret == -1)
                                        indexer = new Indexer(chromosomelist);
                                    else
                                        indexer = new Indexer(ret);

                                } else {
                                    filetype = "local";
                                    filepro = "local/" + organisms[i] + "/data/";
                                    String indexfile = "local/" + organisms[i] + "/index.txt";
                                    indexer = new Indexer(indexfile);
                                }

                                while (indexer.hasNext()) {
                                    String files = filepro + indexer.getNextFileName();
                                    DataInputStream in = new DataInputStream(
                                            new BufferedInputStream(new FileInputStream(
                                                    files + "_" + min + "_" + gap + "_monoImPerfect.temp")));
                                    boolean eof = false;
                                    while (!eof) {
                                        try {
                                            String ssr = in.readUTF();
                                            int start = in.readInt();
                                            int end = in.readInt();
                                            if (!ssr.contains("N"))
                                                out.println("SSR: " + ssr + " start-end " + start + "-" + end
                                                        + " Path(../data/chromosome): "
                                                        + files.substring(0, files.lastIndexOf('.')));
                                        } catch (EOFException exc) {
                                            eof = true;
                                        }
                                    }
                                    in.close();
                                }
                            }
                            if (di.isSelected()) {
                                // 18/11/2013 added starting here

                                if (flag) {
                                    filetype = "organisms";
                                    filepro = "organisms/" + organisms[i] + "/data/";
                                    int ret = getOrganismStatus(organisms[i]);
                                    if (ret == -1)
                                        indexer = new Indexer(chromosomelist);
                                    else
                                        indexer = new Indexer(ret);

                                } else {
                                    filetype = "local";
                                    filepro = "local/" + organisms[i] + "/data/";
                                    String indexfile = "local/" + organisms[i] + "/index.txt";
                                    indexer = new Indexer(indexfile);
                                }
                                while (indexer.hasNext()) {
                                    String files = filepro + indexer.getNextFileName();
                                    DataInputStream in = new DataInputStream(
                                            new BufferedInputStream(new FileInputStream(
                                                    files + "_" + min + "_" + gap + "_diImPerfect.temp")));
                                    boolean eof = false;
                                    while (!eof) {
                                        try {
                                            String ssr = in.readUTF();
                                            int start = in.readInt();
                                            int end = in.readInt();
                                            if (!ssr.contains("N"))
                                                out.println("SSR: " + ssr + " start-end " + start + "-" + end
                                                        + " Path(../data/chromosome): "
                                                        + files.substring(0, files.lastIndexOf('.')));
                                        } catch (EOFException exc) {
                                            eof = true;
                                        }
                                    }
                                    in.close();
                                }
                            }
                            if (tri.isSelected()) {
                                // 18/11/2013 added starting here

                                if (flag) {
                                    filetype = "organisms";
                                    filepro = "organisms/" + organisms[i] + "/data/";
                                    int ret = getOrganismStatus(organisms[i]);
                                    if (ret == -1)
                                        indexer = new Indexer(chromosomelist);
                                    else
                                        indexer = new Indexer(ret);

                                } else {
                                    filetype = "local";
                                    filepro = "local/" + organisms[i] + "/data/";
                                    String indexfile = "local/" + organisms[i] + "/index.txt";
                                    indexer = new Indexer(indexfile);
                                }
                                while (indexer.hasNext()) {
                                    String files = filepro + indexer.getNextFileName();
                                    DataInputStream in = new DataInputStream(
                                            new BufferedInputStream(new FileInputStream(
                                                    files + "_" + min + "_" + gap + "_triImPerfect.temp")));
                                    boolean eof = false;
                                    while (!eof) {
                                        try {
                                            String ssr = in.readUTF();
                                            int start = in.readInt();
                                            int end = in.readInt();
                                            if (!ssr.contains("N"))
                                                out.println("SSR: " + ssr + " start-end " + start + "-" + end
                                                        + " Path(../data/chromosome): "
                                                        + files.substring(0, files.lastIndexOf('.')));
                                        } catch (EOFException exc) {
                                            eof = true;
                                        }
                                    }
                                    in.close();
                                }
                            }
                            if (tetra.isSelected()) {
                                // 18/11/2013 added starting here

                                if (flag) {
                                    filetype = "organisms";
                                    filepro = "organisms/" + organisms[i] + "/data/";
                                    int ret = getOrganismStatus(organisms[i]);
                                    if (ret == -1)
                                        indexer = new Indexer(chromosomelist);
                                    else
                                        indexer = new Indexer(ret);

                                } else {
                                    filetype = "local";
                                    filepro = "local/" + organisms[i] + "/data/";
                                    String indexfile = "local/" + organisms[i] + "/index.txt";
                                    indexer = new Indexer(indexfile);
                                }
                                while (indexer.hasNext()) {
                                    String files = filepro + indexer.getNextFileName();
                                    DataInputStream in = new DataInputStream(
                                            new BufferedInputStream(new FileInputStream(
                                                    files + "_" + min + "_" + gap + "_tetraImPerfect.temp")));
                                    boolean eof = false;
                                    while (!eof) {
                                        try {
                                            String ssr = in.readUTF();
                                            int start = in.readInt();
                                            int end = in.readInt();
                                            if (!ssr.contains("N"))
                                                out.println("SSR: " + ssr + " start-end " + start + "-" + end
                                                        + " Path(../data/chromosome): "
                                                        + files.substring(0, files.lastIndexOf('.')));
                                        } catch (EOFException exc) {
                                            eof = true;
                                        }
                                    }
                                    in.close();
                                }
                            }
                            if (penta.isSelected()) {
                                // 18/11/2013 added starting here

                                if (flag) {
                                    filetype = "organisms";
                                    filepro = "organisms/" + organisms[i] + "/data/";
                                    int ret = getOrganismStatus(organisms[i]);
                                    if (ret == -1)
                                        indexer = new Indexer(chromosomelist);
                                    else
                                        indexer = new Indexer(ret);

                                } else {
                                    filetype = "local";
                                    filepro = "local/" + organisms[i] + "/data/";
                                    String indexfile = "local/" + organisms[i] + "/index.txt";
                                    indexer = new Indexer(indexfile);
                                }
                                while (indexer.hasNext()) {
                                    String files = filepro + indexer.getNextFileName();
                                    DataInputStream in = new DataInputStream(
                                            new BufferedInputStream(new FileInputStream(
                                                    files + "_" + min + "_" + gap + "_pentaImPerfect.temp")));
                                    boolean eof = false;
                                    while (!eof) {
                                        try {
                                            String ssr = in.readUTF();
                                            int start = in.readInt();
                                            int end = in.readInt();
                                            if (!ssr.contains("N"))
                                                out.println("SSR: " + ssr + " start-end " + start + "-" + end
                                                        + " Path(../data/chromosome): "
                                                        + files.substring(0, files.lastIndexOf('.')));
                                        } catch (EOFException exc) {
                                            eof = true;
                                        }
                                    }
                                    in.close();
                                }
                            }
                            if (hexa.isSelected()) {
                                // 18/11/2013 added starting here

                                if (flag) {
                                    filetype = "organisms";
                                    filepro = "organisms/" + organisms[i] + "/data/";
                                    int ret = getOrganismStatus(organisms[i]);
                                    if (ret == -1)
                                        indexer = new Indexer(chromosomelist);
                                    else
                                        indexer = new Indexer(ret);

                                } else {
                                    filetype = "local";
                                    filepro = "local/" + organisms[i] + "/data/";
                                    String indexfile = "local/" + organisms[i] + "/index.txt";
                                    indexer = new Indexer(indexfile);
                                }
                                while (indexer.hasNext()) {
                                    String files = filepro + indexer.getNextFileName();
                                    DataInputStream in = new DataInputStream(
                                            new BufferedInputStream(new FileInputStream(
                                                    files + "_" + min + "_" + gap + "_hexaImPerfect.temp")));
                                    boolean eof = false;
                                    while (!eof) {
                                        try {
                                            String ssr = in.readUTF();
                                            int start = in.readInt();
                                            int end = in.readInt();
                                            if (!ssr.contains("N"))
                                                out.println("SSR: " + ssr + "  start-end " + start + "-" + end
                                                        + " Path(../data/chromosome): "
                                                        + files.substring(0, files.lastIndexOf('.')));
                                        } catch (EOFException exc) {
                                            eof = true;
                                        }
                                    }
                                    in.close();
                                }
                            }

                            out.close();

                            Runtime.getRuntime().exec("notepad " + location);

                            DecimalFormat round = new DecimalFormat("#.###");

                            html.println("<html><h1>******* ImPerfect SSRs *******</h1>");
                            html.println("<h4>Results for project: " + organisms[i]
                                    + "</h4><h4>Search Parameters --> Maximum Mismatch length for ImPerfect SSRs (bp): "
                                    + gap + "</h4><h4>minimum SSR length before given Mismatch length (bp): "
                                    + min + "</h4>");
                            html.println(
                                    "<table border=\"1\"><tr><td><b>motif</b></td><td><b>count</b></td><td><b>bp</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td><td><b>Relative Frequency</b></td><td><b>Abundance</b></td><td><b>Relative Abundance</b></td></tr>");

                            stats.println("******* ImPerfect SSRs *******");
                            stats.println("Results for project: " + organisms[i]
                                    + "\n Search Parameters --> Maximum Mismatch length for ImPerfect SSRs (bp): "
                                    + gap + " \nminimum SSR length before given Mismatch length (bp): " + min);

                            stats.println(
                                    " ____________________________________________________________________________________________________________ ");
                            stats.println(
                                    "|       |       |            |       |       |       |       |   Relative    |               |   Relative    |");
                            stats.println(
                                    "| motif | count |     bp     |   A%  |   T%  |   C%  |   G%  |   Frequency   |   Abundance   |   Abundance   |");
                            stats.println(
                                    "|=======|=======|============|=======|=======|=======|=======|===============|===============|===============|");
                            int totalcount = 0;
                            long bpcount = 0;
                            int Aperc = 0;
                            int Tperc = 0;
                            int Gperc = 0;
                            int Cperc = 0;
                            float relfreq = 0;
                            float abfreq = 0;
                            long seqcount = 0;

                            if (mono.isSelected()) {
                                totalcount += countmono.get(i);
                                bpcount += countmonore.get(i);
                            }
                            if (di.isSelected()) {
                                totalcount += countdi.get(i);
                                bpcount += countdire.get(i);
                            }
                            if (tri.isSelected()) {
                                totalcount += counttri.get(i);
                                bpcount += counttrire.get(i);
                            }
                            if (tetra.isSelected()) {
                                totalcount += counttetra.get(i);
                                bpcount += counttetrare.get(i);
                            }
                            if (penta.isSelected()) {
                                totalcount += countpenta.get(i);
                                bpcount += countpentare.get(i);
                            }
                            if (hexa.isSelected()) {
                                totalcount += counthexa.get(i);
                                bpcount += counthexare.get(i);
                            }
                            try {
                                Class.forName("com.mysql.jdbc.Driver");
                            } catch (ClassNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            Connection con = null;
                            try {
                                con = DriverManager.getConnection("jdbc:mysql://localhost:3306", "biouser",
                                        "thesis2012");
                            } catch (SQLException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            Statement st = null;
                            try {
                                st = con.createStatement();
                            } catch (SQLException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            st.executeUpdate("use lobid");
                            seqcount = 0;

                            if (filetype.contains("organisms")) {
                                ResultSet rs = st.executeQuery(
                                        "SELECT end FROM slices INNER JOIN organism WHERE slices.org_id=organism.org_id AND organism.name='"
                                                + organisms[i] + "'");
                                while (rs.next()) {
                                    seqcount += Long.parseLong(rs.getString(1));
                                }
                            } else if (filetype.contains("local")) {
                                BufferedReader in = new BufferedReader(
                                        new FileReader("local/" + organisms[i] + "/index.txt"));
                                int count = countlines("local/" + organisms[i] + "/index.txt");
                                for (int c = 0; c < count; c++) {
                                    String temp = in.readLine();
                                    BufferedReader tmp = new BufferedReader(
                                            new FileReader("local/" + organisms[i] + "/" + temp + ".txt"));

                                    boolean eof = false;
                                    while (!eof) {

                                        String s = tmp.readLine();
                                        if (s != null) {
                                            seqcount += s.length();
                                        } else {
                                            eof = true;
                                        }
                                    }
                                    tmp.close();
                                }
                            }
                            int tempmono = countmonore.get(i);
                            int tempdi = countdire.get(i);
                            int temptri = counttrire.get(i);
                            int temptetra = counttetrare.get(i);
                            int temppenta = countpentare.get(i);
                            int temphexa = counthexare.get(i);
                            if (tempmono == 0)
                                tempmono = 1;
                            if (tempdi == 0)
                                tempdi = 1;
                            if (temptri == 0)
                                temptri = 1;
                            if (temptetra == 0)
                                temptetra = 1;
                            if (temppenta == 0)
                                temppenta = 1;
                            if (temphexa == 0)
                                temphexa = 1;

                            if (mono.isSelected()) {
                                Aperc += Amono.get(i);
                                Tperc += Tmono.get(i);
                                Gperc += Gmono.get(i);
                                Cperc += Cmono.get(i);

                                //lt.writeInt(countmono.get(i));lt.writeInt(countmonore.get(i));lt.writeFloat((float)Amono.get(i)*100/tempmono);lt.writeFloat((float)Tmono.get(i)*100/tempmono);lt.writeFloat((float)Gmono.get(i)*100/tempmono);lt.writeFloat((float)Cmono.get(i)*100/tempmono);lt.writeFloat((float) countmono.get(i) / totalcount);lt.writeFloat((float) countmonore.get(i) / seqcount);lt.writeFloat((float) countmonore.get(i) / bpcount);
                                stats.printf("|mono   |" + cell(Integer.toString(countmono.get(i)), 7) + "|"
                                        + cell(Integer.toString(countmonore.get(i)), 12) + "|%s|%s|%s|%s|"
                                        + cell((float) countmono.get(i) / totalcount, 15) + "|"
                                        + cell((float) countmonore.get(i) / seqcount, 15) + "|"
                                        + cell((float) countmonore.get(i) / bpcount, 15) + "|\n",
                                        cell((float) (Amono.get(i) * 100) / (tempmono), 7),
                                        cell((float) (Tmono.get(i) * 100) / (tempmono), 7),
                                        cell((float) (Cmono.get(i) * 100) / (tempmono), 7),
                                        cell((float) (Gmono.get(i) * 100) / (tempmono), 7));
                                stats.println(
                                        "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                html.println("<tr><td><b>mono</b></td><td>" + countmono.get(i) + "</td><td>"
                                        + (countmonore.get(i)) + "</td><td>"
                                        + round.format((float) (Amono.get(i) * 100) / (tempmono)) + "</td><td>"
                                        + round.format((float) (Tmono.get(i) * 100) / (tempmono)) + "</td><td>"
                                        + round.format((float) (Cmono.get(i) * 100) / (tempmono)) + "</td><td>"
                                        + round.format((float) (Gmono.get(i) * 100) / (tempmono)) + "</td><td>"
                                        + round.format((float) countmono.get(i) / totalcount) + "</td><td>"
                                        + round.format((float) countmonore.get(i) / seqcount) + "</td><td>"
                                        + round.format((float) countmonore.get(i) / bpcount) + "</td></tr>");
                            }
                            if (di.isSelected()) {
                                Aperc += Adi.get(i);
                                Tperc += Tdi.get(i);
                                Gperc += Gdi.get(i);
                                Cperc += Cdi.get(i);

                                //lt.writeInt(countdi.get(i));lt.writeInt(countdi.get(i)re.get(i));lt.writeFloat((float)Adi.get(i)*100/tempdi);lt.writeFloat((float)Tdi.get(i)*100/tempdi);lt.writeFloat((float)Gdi.get(i)*100/tempdi);lt.writeFloat((float)Cdi.get(i)*100/tempdi);lt.writeFloat((float) countdi.get(i) / totalcount);lt.writeFloat((float) countdi.get(i)re.get(i) / seqcount);lt.writeFloat((float) countdi.get(i)re.get(i) / bpcount);
                                stats.printf(
                                        "|di     |" + cell(Integer.toString(countdi.get(i)), 7) + "|"
                                                + cell(Integer.toString(countdire.get(i)), 12) + "|%s|%s|%s|%s|"
                                                + cell((float) countdi.get(i) / totalcount, 15) + "|"
                                                + cell((float) countdi.get(i) / seqcount, 15) + "|"
                                                + cell((float) countdi.get(i) / bpcount, 15) + "|\n",
                                        cell((float) (Adi.get(i) * 100) / (tempdi), 7),
                                        cell((float) (Tdi.get(i) * 100) / (tempdi), 7),
                                        cell((float) (Cdi.get(i) * 100) / (tempdi), 7),
                                        cell((float) (Gdi.get(i) * 100) / (tempdi), 7));
                                stats.println(
                                        "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                html.println("<tr><td><b>di</b></td><td>" + countdi.get(i) + "</td><td>"
                                        + (countdire.get(i)) + "</td><td>"
                                        + round.format((float) (Adi.get(i) * 100) / (tempdi)) + "</td><td>"
                                        + round.format((float) (Tdi.get(i) * 100) / (tempdi)) + "</td><td>"
                                        + round.format((float) (Cdi.get(i) * 100) / (tempdi)) + "</td><td>"
                                        + round.format((float) (Gdi.get(i) * 100) / (tempdi)) + "</td><td>"
                                        + round.format((float) countdi.get(i) / totalcount) + "</td><td>"
                                        + round.format((float) countdire.get(i) / seqcount) + "</td><td>"
                                        + round.format((float) countdire.get(i) / bpcount) + "</td></tr>");
                            }
                            if (tri.isSelected()) {
                                Aperc += Atri.get(i);
                                Tperc += Ttri.get(i);
                                Gperc += Gtri.get(i);
                                Cperc += Ctri.get(i);
                                //lt.writeInt(counttri.get(i));lt.writeInt(counttrire.get(i).get(i));lt.writeFloat((float)Atri.get(i)*100/temptri);lt.writeFloat((float)Ttri.get(i)*100/temptri);lt.writeFloat((float)Gtri.get(i)*100/temptri);lt.writeFloat((float)Ctri.get(i)*100/temptri);lt.writeFloat((float) counttri.get(i) / totalcount);lt.writeFloat((float) counttrire.get(i).get(i) / seqcount);lt.writeFloat((float) counttrire.get(i).get(i) / bpcount);
                                stats.printf("|tri    |" + cell(Integer.toString(counttri.get(i)), 7) + "|"
                                        + cell(Integer.toString(counttrire.get(i)), 12) + "|%s|%s|%s|%s|"
                                        + cell((float) counttri.get(i) / totalcount, 15) + "|"
                                        + cell((float) counttrire.get(i) / seqcount, 15) + "|"
                                        + cell((float) counttrire.get(i) / bpcount, 15) + "|\n",
                                        cell((float) (Atri.get(i) * 100) / (temptri), 7),
                                        cell((float) (Ttri.get(i) * 100) / (temptri), 7),
                                        cell((float) (Ctri.get(i) * 100) / (temptri), 7),
                                        cell((float) (Gtri.get(i) * 100) / (temptri), 7));
                                stats.println(
                                        "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                html.println("<tr><td><b>tri</b></td><td>" + counttri.get(i) + "</td><td>"
                                        + (counttrire.get(i)) + "</td><td>"
                                        + round.format((float) (Atri.get(i) * 100) / (temptri)) + "</td><td>"
                                        + round.format((float) (Ttri.get(i) * 100) / (temptri)) + "</td><td>"
                                        + round.format((float) (Ctri.get(i) * 100) / (temptri)) + "</td><td>"
                                        + round.format((float) (Gtri.get(i) * 100) / (temptri)) + "</td><td>"
                                        + round.format((float) counttri.get(i) / totalcount) + "</td><td>"
                                        + round.format((float) counttrire.get(i) / seqcount) + "</td><td>"
                                        + round.format((float) counttrire.get(i) / bpcount) + "</td></tr>");
                            }
                            if (tetra.isSelected()) {
                                Aperc += Atetra.get(i);
                                Tperc += Ttetra.get(i);
                                Gperc += Gtetra.get(i);
                                Cperc += Ctetra.get(i);
                                //lt.writeInt(counttetra.get(i));lt.writeInt(counttetrare.get(i));lt.writeFloat((float)Atetra.get(i)*100/temptetra);lt.writeFloat((float)Ttetra.get(i)*100/temptetra);lt.writeFloat((float)Gtetra.get(i)*100/temptetra);lt.writeFloat((float)Ctetra.get(i)*100/temptetra);lt.writeFloat((float) counttetra.get(i) / totalcount);lt.writeFloat((float) counttetrare.get(i) / seqcount);lt.writeFloat((float) counttetrare.get(i) / bpcount);
                                stats.printf("|tetra  |" + cell(Integer.toString(counttetra.get(i)), 7) + "|"
                                        + cell(Integer.toString(counttetrare.get(i)), 12) + "|%s|%s|%s|%s|"
                                        + cell((float) counttetra.get(i) / totalcount, 15) + "|"
                                        + cell((float) counttetrare.get(i) / seqcount, 15) + "|"
                                        + cell((float) counttetrare.get(i) / bpcount, 15) + "|\n",
                                        cell((float) (Atetra.get(i) * 100) / (temptetra), 7),
                                        cell((float) (Ttetra.get(i) * 100) / (temptetra), 7),
                                        cell((float) (Ctetra.get(i) * 100) / (temptetra), 7),
                                        cell((float) (Gtetra.get(i) * 100) / (temptetra), 7));
                                stats.println(
                                        "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                html.println("<tr><td><b>tetra</b></td><td>" + counttetra.get(i) + "</td><td>"
                                        + (counttetrare.get(i)) + "</td><td>"
                                        + round.format((float) (Atetra.get(i) * 100) / (temptetra))
                                        + "</td><td>"
                                        + round.format((float) (Ttetra.get(i) * 100) / (temptetra))
                                        + "</td><td>"
                                        + round.format((float) (Ctetra.get(i) * 100) / (temptetra))
                                        + "</td><td>"
                                        + round.format((float) (Gtetra.get(i) * 100) / (temptetra))
                                        + "</td><td>" + round.format((float) counttetra.get(i) / totalcount)
                                        + "</td><td>" + round.format((float) counttetrare.get(i) / seqcount)
                                        + "</td><td>" + round.format((float) counttetrare.get(i) / bpcount)
                                        + "</td></tr>");
                            }
                            if (penta.isSelected()) {
                                Aperc += Apenta.get(i);
                                Tperc += Tpenta.get(i);
                                Gperc += Gpenta.get(i);
                                Cperc += Cpenta.get(i);
                                //lt.writeInt(countpenta.get(i));lt.writeInt(countpentare.get(i));lt.writeFloat((float)Apenta.get(i)*100/temppenta);lt.writeFloat((float)Tpenta.get(i)*100/temppenta);lt.writeFloat((float)Gpenta.get(i)*100/temppenta);lt.writeFloat((float)Cpenta.get(i)*100/temppenta);lt.writeFloat((float) countpenta.get(i) / totalcount);lt.writeFloat((float) countpentare.get(i) / seqcount);lt.writeFloat((float) countpentare.get(i) / bpcount);
                                stats.printf("|penta  |" + cell(Integer.toString(countpenta.get(i)), 7) + "|"
                                        + cell(Integer.toString(countpentare.get(i)), 12) + "|%s|%s|%s|%s|"
                                        + cell((float) countpenta.get(i) / totalcount, 15) + "|"
                                        + cell((float) countpentare.get(i) / seqcount, 15) + "|"
                                        + cell((float) countpentare.get(i) / bpcount, 15) + "|\n",
                                        cell((float) (Apenta.get(i) * 100) / (temppenta), 7),
                                        cell((float) (Tpenta.get(i) * 100) / (temppenta), 7),
                                        cell((float) (Cpenta.get(i) * 100) / (temppenta), 7),
                                        cell((float) (Gpenta.get(i) * 100) / (temppenta), 7));
                                stats.println(
                                        "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                html.println("<tr><td><b>penta</b></td><td>" + countpenta.get(i) + "</td><td>"
                                        + (countpentare.get(i)) + "</td><td>"
                                        + round.format((float) (Apenta.get(i) * 100) / (temppenta))
                                        + "</td><td>"
                                        + round.format((float) (Tpenta.get(i) * 100) / (temppenta))
                                        + "</td><td>"
                                        + round.format((float) (Cpenta.get(i) * 100) / (temppenta))
                                        + "</td><td>"
                                        + round.format((float) (Gpenta.get(i) * 100) / (temppenta))
                                        + "</td><td>" + round.format((float) countpenta.get(i) / totalcount)
                                        + "</td><td>" + round.format((float) countpentare.get(i) / seqcount)
                                        + "</td><td>" + round.format((float) countpentare.get(i) / bpcount)
                                        + "</td></tr>");
                            }
                            if (hexa.isSelected()) {
                                Aperc += Ahexa.get(i);
                                Tperc += Thexa.get(i);
                                Gperc += Ghexa.get(i);
                                Cperc += Chexa.get(i);
                                //lt.writeInt(counthexa.get(i));lt.writeInt(counthexare.get(i));lt.writeFloat((float)Ahexa.get(i)*100/temphexa);lt.writeFloat((float)Thexa.get(i)*100/temphexa);lt.writeFloat((float)Ghexa.get(i)*100/temphexa);lt.writeFloat((float)Chexa.get(i)*100/temphexa);lt.writeFloat((float) counthexa.get(i) / totalcount);lt.writeFloat((float) counthexare.get(i) / seqcount);lt.writeFloat((float) counthexare.get(i) / bpcount);
                                stats.printf("|hexa   |" + cell(Integer.toString(counthexa.get(i)), 7) + "|"
                                        + cell(Integer.toString(counthexare.get(i)), 12) + "|%s|%s|%s|%s|"
                                        + cell((float) counthexa.get(i) / totalcount, 15) + "|"
                                        + cell((float) counthexare.get(i) / seqcount, 15) + "|"
                                        + cell((float) counthexare.get(i) / bpcount, 15) + "|\n",
                                        cell((float) (Ahexa.get(i) * 100) / (temphexa), 7),
                                        cell((float) (Thexa.get(i) * 100) / (temphexa), 7),
                                        cell((float) (Chexa.get(i) * 100) / (temphexa), 7),
                                        cell((float) (Ghexa.get(i) * 100) / (temphexa), 7));
                                stats.println(
                                        "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                                html.println("<tr><td><b>hexa</b></td><td>" + counthexa.get(i) + "</td><td>"
                                        + (counthexare.get(i)) + "</td><td>"
                                        + round.format((float) (Ahexa.get(i) * 100) / (temphexa)) + "</td><td>"
                                        + round.format((float) (Thexa.get(i) * 100) / (temphexa)) + "</td><td>"
                                        + round.format((float) (Chexa.get(i) * 100) / (temphexa)) + "</td><td>"
                                        + round.format((float) (Ghexa.get(i) * 100) / (temphexa)) + "</td><td>"
                                        + round.format((float) counthexa.get(i) / totalcount) + "</td><td>"
                                        + round.format((float) counthexare.get(i) / seqcount) + "</td><td>"
                                        + round.format((float) counthexare.get(i) / bpcount) + "</td></tr>");
                            }

                            if (mono.isSelected()) {
                                relfreq += (float) countmono.get(i) / totalcount;
                                abfreq += (float) countmonore.get(i) / bpcount;
                            }
                            if (di.isSelected()) {
                                relfreq += (float) countdi.get(i) / totalcount;
                                abfreq += (float) countdire.get(i) / bpcount;
                            }
                            if (tri.isSelected()) {
                                relfreq += (float) counttri.get(i) / totalcount;
                                abfreq += (float) counttrire.get(i) / bpcount;
                            }
                            if (tetra.isSelected()) {
                                relfreq += (float) counttetra.get(i) / totalcount;
                                abfreq += (float) counttetrare.get(i) / bpcount;
                            }
                            if (penta.isSelected()) {
                                relfreq += (float) countpenta.get(i) / totalcount;
                                abfreq += (float) countpentare.get(i) / bpcount;
                            }
                            if (hexa.isSelected()) {
                                relfreq += (float) counthexa.get(i) / totalcount;
                                abfreq += (float) counthexare.get(i) / bpcount;
                            }

                            lt.writeLong(seqcount);
                            lt.writeInt(totalcount);
                            lt.writeLong(bpcount);
                            lt.writeInt(Aperc);
                            lt.writeInt(Tperc);
                            lt.writeInt(Gperc);
                            lt.writeInt(Cperc);
                            stats.println("|TOTAL  |" + cell(Integer.toString(totalcount), 7) + "|"
                                    + cell(Long.toString(bpcount), 12) + "|"
                                    + cell((float) Aperc * 100 / bpcount, 7) + "|"
                                    + cell((float) Tperc * 100 / bpcount, 7) + "|"
                                    + cell((float) Cperc * 100 / bpcount, 7) + "|"
                                    + cell((float) Gperc * 100 / bpcount, 7) + "|" + cell(relfreq, 15) + "|"
                                    + cell((float) bpcount / seqcount, 15) + "|" + cell((float) abfreq, 15)
                                    + "|");
                            stats.println(
                                    "|_______|_______|____________|_______|_______|_______|_______|_______________|_______________|_______________|");
                            stats.println("Genome length (bp): " + seqcount);
                            stats.println("Relative Frequency: Count of each motif type / total SSR count");
                            stats.println("Abundance: bp of each motif type / total sequence bp");
                            stats.println(
                                    "Relative Abundance: bp of each motif type / total microsatellites bp");
                            stats.println();
                            stats.println();
                            stats.close();
                            lt.close();
                            html.println("<tr><td><b>TOTAL</b></td><td>" + totalcount + "</td><td>" + bpcount
                                    + "</td><td>" + round.format((float) Aperc * 100 / bpcount) + "</td><td>"
                                    + round.format((float) Tperc * 100 / bpcount) + "</td><td>"
                                    + round.format((float) Cperc * 100 / bpcount) + "</td><td>"
                                    + round.format((float) Gperc * 100 / bpcount) + "</td><td>"
                                    + round.format((float) relfreq) + "</td><td>"
                                    + round.format((float) bpcount / seqcount) + "</td><td>"
                                    + round.format((float) abfreq) + "</td></tr></table></html>");
                            html.close();

                        }

                    } catch (SQLException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (ClassNotFoundException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE);
                    } catch (IOException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    if (!gapisnumber && !minisnumber) {
                        msg.showMessageDialog(paneldown,
                                "Fill in Mismatch length for Imperfect SSRs \n and the minimum sequence length before the Mismatch length\n (Integers only)",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    } else {
                        if (!gapisnumber) {
                            msg.showMessageDialog(paneldown,
                                    "Fill in Mismatch length for Imperfect SSRs (Integer only)", "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                        if (!minisnumber) {
                            msg.showMessageDialog(paneldown,
                                    "Fill in the minimum sequence length before the Mismatch length (Integer only)",
                                    "Error", JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }

            }

            if (box3.isSelected()) {
                boolean lenisnumber;
                boolean gapisnumber;
                int minlen = 0;
                int gap = 0;
                if (!com.isSelected() && !incom.isSelected()) {
                    msg.showMessageDialog(paneldown, "Select a Compound SSR Option", "Error",
                            JOptionPane.ERROR_MESSAGE);
                } else {

                    try {
                        minlen = Integer.parseInt(score.getText());
                        lenisnumber = true;
                    } catch (NumberFormatException ex) {
                        lenisnumber = false;
                    }

                    try {
                        gap = Integer.parseInt(maxgapcomp.getText());
                        gapisnumber = true;
                    } catch (NumberFormatException ex) {
                        gapisnumber = false;
                    }

                    if (lenisnumber && gapisnumber) {

                        if (com.isSelected()) {
                            try {
                                getCompoundPerfectSSRs(organisms, minlen, flag, gap);
                            } catch (SQLException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            } catch (ClassNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            } catch (FileNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                                //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE);
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        if (incom.isSelected()) {
                            try {
                                getImPerfectCompoundSSRs(organisms, minlen, flag, gap);
                            } catch (SQLException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            } catch (ClassNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            } catch (FileNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                                //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE);
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                    } else {
                        if (!lenisnumber) {
                            msg.showMessageDialog(paneldown, "Minimum length requires an Integer", "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                        if (!gapisnumber) {
                            msg.showMessageDialog(paneldown,
                                    "Inter-repeat Region between compound SSRs requires an Integer", "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
            }
            if (box1.isSelected() || box2.isSelected() || box3.isSelected() || com.isSelected()
                    || incom.isSelected()) {
                PrintWriter out = null;
                PrintWriter html = null;
                boolean orgs = true;
                DecimalFormat round = new DecimalFormat("#.###");
                //String file="";
                for (int i = 0; i < organisms.length; i++) {

                    String file = "organisms/" + organisms[i] + "/stats/" + "summary_statistics"
                            + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                    File stats = new File(file);
                    if (!stats.exists()) {
                        orgs = false;

                        file = "local/" + organisms[i] + "/stats/" + "summary_statistics"
                                + now.toString().replace(':', '_').replace(' ', '_') + ".txt";
                    }
                    try {

                        html = new PrintWriter(
                                new FileWriter(file.substring(0, file.indexOf(".")) + ".html", true));
                        html.println("<html><h1>******* SUMMARY TABLE *******</h1>");
                        html.println(
                                "<table border=\"1\"><tr><td>type</td><td><b>count</b></td><td><b>bp</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td><td><b>Relative Frequency</b></td><td><b>Abundance</b></td><td><b>Relative Abundance</b></td></tr>");

                        out = new PrintWriter(new FileWriter(file, true));
                        out.println("******* SUMMARY TABLE *******");

                        out.println(
                                " _________________________________________________________________________________________________________________ ");
                        out.println(
                                "|            |       |            |       |       |       |       |   Relative    |               |   Relative    |");
                        out.println(
                                "|    type    | count |     bp     |   A%  |   T%  |   C%  |   G%  |   Frequency   |   Abundance   |   Abundance   |");
                        out.println(
                                "|============|=======|============|=======|=======|=======|=======|===============|===============|===============|");

                    } catch (IOException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    //TOTAL
                    long seqcount = 0;
                    int SSRcount = 0;
                    int SSRbpcount = 0;
                    int A = 0, T = 0, G = 0, C = 0;
                    float relfreq = 0;
                    float abfreq = 0;

                    //perfect
                    int pcount = 0;
                    long pbpcount = 0;
                    int Ap = 0, Tp = 0, Gp = 0, Cp = 0;
                    //imperfect
                    int imcount = 0;
                    long imbpcount = 0;
                    int Aim = 0, Tim = 0, Gim = 0, Cim = 0;

                    //compound perfect
                    int ccount = 0;
                    long cbpcount = 0;
                    int Ac = 0, Tc = 0, Gc = 0, Cc = 0;
                    //compound imperfect
                    int cicount = 0;
                    long cibpcount = 0;
                    int Aci = 0, Tci = 0, Gci = 0, Cci = 0;

                    if (box1.isSelected()) {
                        DataInputStream in = null;
                        if (orgs) {
                            try {
                                in = new DataInputStream(
                                        new BufferedInputStream(new FileInputStream("organisms/" + organisms[i]
                                                + "/data/" + now.toString().replace(':', '_').replace(' ', '_')
                                                + ".perf")));
                            } catch (FileNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        } else {
                            try {
                                in = new DataInputStream(new BufferedInputStream(new FileInputStream("local/"
                                        + organisms[i] + "/data/"
                                        + now.toString().replace(':', '_').replace(' ', '_') + ".perf")));
                            } catch (FileNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        try {
                            seqcount = in.readLong();
                            pcount = in.readInt();
                            pbpcount = in.readLong();
                            Ap = in.readInt();
                            Tp = in.readInt();
                            Gp = in.readInt();
                            Cp = in.readInt();
                            A += Ap;
                            T += Tp;
                            G += Gp;
                            C += Cp;

                            SSRcount += pcount;
                            SSRbpcount += pbpcount;
                            in.close();
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                    if (box2.isSelected()) {
                        DataInputStream in = null;
                        if (orgs) {
                            try {
                                in = new DataInputStream(
                                        new BufferedInputStream(new FileInputStream("organisms/" + organisms[i]
                                                + "/data/" + now.toString().replace(':', '_').replace(' ', '_')
                                                + ".imperf")));
                            } catch (FileNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        } else {
                            try {
                                in = new DataInputStream(new BufferedInputStream(new FileInputStream("local/"
                                        + organisms[i] + "/data/"
                                        + now.toString().replace(':', '_').replace(' ', '_') + ".imperf")));
                            } catch (FileNotFoundException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        try {
                            seqcount = in.readLong();
                            imcount = in.readInt();
                            imbpcount = in.readLong();
                            Aim = in.readInt();
                            Tim = in.readInt();
                            Gim = in.readInt();
                            Cim = in.readInt();
                            A += Aim;
                            T += Tim;
                            G += Gim;
                            C += Cim;

                            SSRcount += imcount;
                            SSRbpcount += imbpcount;
                            in.close();
                        } catch (IOException ex) {
                            Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                    if (box3.isSelected()) {
                        if (com.isSelected()) {
                            DataInputStream in = null;
                            if (orgs) {
                                try {
                                    in = new DataInputStream(new BufferedInputStream(
                                            new FileInputStream("organisms/" + organisms[i] + "/data/"
                                                    + now.toString().replace(':', '_').replace(' ', '_')
                                                    + ".compp")));
                                } catch (FileNotFoundException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                            } else {
                                try {
                                    in = new DataInputStream(new BufferedInputStream(
                                            new FileInputStream("local/" + organisms[i] + "/data/"
                                                    + now.toString().replace(':', '_').replace(' ', '_')
                                                    + ".compp")));
                                } catch (FileNotFoundException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                            }
                            try {
                                seqcount = in.readLong();
                                ccount = in.readInt();
                                cbpcount = in.readInt();
                                Ac = in.readInt();
                                Tc = in.readInt();
                                Gc = in.readInt();
                                Cc = in.readInt();
                                A += Ac;
                                T += Tc;
                                G += Gc;
                                C += Cc;

                                SSRcount += ccount;
                                SSRbpcount += cbpcount;
                                in.close();
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        if (incom.isSelected()) {
                            DataInputStream in = null;
                            if (orgs) {
                                try {
                                    in = new DataInputStream(new BufferedInputStream(
                                            new FileInputStream("organisms/" + organisms[i] + "/data/"
                                                    + now.toString().replace(':', '_').replace(' ', '_')
                                                    + ".compim")));
                                } catch (FileNotFoundException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                            } else {
                                try {
                                    in = new DataInputStream(new BufferedInputStream(
                                            new FileInputStream("local/" + organisms[i] + "/data/"
                                                    + now.toString().replace(':', '_').replace(' ', '_')
                                                    + ".compim")));
                                } catch (FileNotFoundException ex) {
                                    Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null,
                                            ex);
                                }
                            }
                            try {
                                seqcount = in.readLong();
                                cicount = in.readInt();
                                cibpcount = in.readInt();
                                Aci = in.readInt();
                                Tci = in.readInt();
                                Gci = in.readInt();
                                Cci = in.readInt();
                                A += Aci;
                                T += Tci;
                                G += Gci;
                                C += Cci;

                                SSRcount += cicount;
                                SSRbpcount += cibpcount;
                                in.close();
                            } catch (IOException ex) {
                                Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                    }

                    if (box1.isSelected()) {
                        relfreq += (float) pcount / SSRcount;
                        abfreq += (float) pbpcount / SSRbpcount;
                        out.printf(
                                "|Perfect     |" + cell(Integer.toString(pcount), 7) + "|"
                                        + cell(Long.toString(pbpcount), 12) + "|%s|%s|%s|%s|"
                                        + cell((float) pcount / SSRcount, 15) + "|"
                                        + cell((float) pbpcount / seqcount, 15) + "|"
                                        + cell((float) pbpcount / SSRbpcount, 15) + "|\n",
                                cell((float) (Ap * 100) / (SSRbpcount), 7),
                                cell((float) (Tp * 100) / (SSRbpcount), 7),
                                cell((float) (Cp * 100) / (SSRbpcount), 7),
                                cell((float) (Gp * 100) / (SSRbpcount), 7));
                        out.println(
                                "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                        html.println("<tr><td><b>Perfect</b></td><td>" + pcount + "</td><td>" + pbpcount
                                + "</td><td>" + round.format((float) Ap * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) Tp * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) Cp * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) Gp * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) pcount / SSRcount) + "</td><td>"
                                + round.format((float) pbpcount / seqcount) + "</td><td>"
                                + round.format((float) pbpcount / SSRbpcount) + "</td></tr>");
                    }
                    if (box2.isSelected()) {
                        relfreq += (float) imcount / SSRcount;
                        abfreq += (float) imbpcount / SSRbpcount;
                        out.printf(
                                "|Imperfect   |" + cell(Integer.toString(imcount), 7) + "|"
                                        + cell(Long.toString(imbpcount), 12) + "|%s|%s|%s|%s|"
                                        + cell((float) imcount / SSRcount, 15) + "|"
                                        + cell((float) imbpcount / seqcount, 15) + "|"
                                        + cell((float) imbpcount / SSRbpcount, 15) + "|\n",
                                cell((float) (Aim * 100) / (SSRbpcount), 7),
                                cell((float) (Tim * 100) / (SSRbpcount), 7),
                                cell((float) (Cim * 100) / (SSRbpcount), 7),
                                cell((float) (Gim * 100) / (SSRbpcount), 7));
                        out.println(
                                "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                        html.println("<tr><td><b>Imperfect</b></td><td>" + imcount + "</td><td>" + imbpcount
                                + "</td><td>" + round.format((float) Aim * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) Tim * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) Cim * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) Gim * 100 / SSRbpcount) + "</td><td>"
                                + round.format((float) imcount / SSRcount) + "</td><td>"
                                + round.format((float) imbpcount / seqcount) + "</td><td>"
                                + round.format((float) imbpcount / SSRbpcount) + "</td></tr>");
                    }
                    if (box3.isSelected()) {
                        if (com.isSelected()) {
                            abfreq += (float) cbpcount / SSRbpcount;
                            relfreq += (float) ccount / SSRcount;
                            out.printf(
                                    "|Compound Per|" + cell(Integer.toString(ccount), 7) + "|"
                                            + cell(Long.toString(cbpcount), 12) + "|%s|%s|%s|%s|"
                                            + cell((float) ccount / SSRcount, 15) + "|"
                                            + cell((float) cbpcount / seqcount, 15) + "|"
                                            + cell((float) cbpcount / SSRbpcount, 15) + "|\n",
                                    cell((float) (Ac * 100) / (SSRbpcount), 7),
                                    cell((float) (Tc * 100) / (SSRbpcount), 7),
                                    cell((float) (Cc * 100) / (SSRbpcount), 7),
                                    cell((float) (Gc * 100) / (SSRbpcount), 7));
                            out.println(
                                    "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                            html.println("<tr><td><b>Compound Perf.</b></td><td>" + ccount + "</td><td>"
                                    + cbpcount + "</td><td>" + round.format((float) Ac * 100 / SSRbpcount)
                                    + "</td><td>" + round.format((float) Tc * 100 / SSRbpcount) + "</td><td>"
                                    + round.format((float) Cc * 100 / SSRbpcount) + "</td><td>"
                                    + round.format((float) Gc * 100 / SSRbpcount) + "</td><td>"
                                    + round.format((float) ccount / SSRcount) + "</td><td>"
                                    + round.format((float) cbpcount / seqcount) + "</td><td>"
                                    + round.format((float) cbpcount / SSRbpcount) + "</td></tr>");
                        }
                        if (incom.isSelected()) {
                            abfreq += (float) cibpcount / SSRbpcount;
                            relfreq += (float) cicount / SSRcount;
                            out.printf(
                                    "|Compound Imp|" + cell(Integer.toString(cicount), 7) + "|"
                                            + cell(Long.toString(cibpcount), 12) + "|%s|%s|%s|%s|"
                                            + cell((float) cicount / SSRcount, 15) + "|"
                                            + cell((float) cibpcount / seqcount, 15) + "|"
                                            + cell((float) cibpcount / SSRbpcount, 15) + "|\n",
                                    cell((float) (Aci * 100) / (SSRbpcount), 7),
                                    cell((float) (Tci * 100) / (SSRbpcount), 7),
                                    cell((float) (Cci * 100) / (SSRbpcount), 7),
                                    cell((float) (Gci * 100) / (SSRbpcount), 7));
                            out.println(
                                    "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|");
                            html.println("<tr><td><b>Compound Imperf.</b></td><td>" + cicount + "</td><td>"
                                    + cibpcount + "</td><td>" + round.format((float) Aci * 100 / SSRbpcount)
                                    + "</td><td>" + round.format((float) Tci * 100 / SSRbpcount) + "</td><td>"
                                    + round.format((float) Cci * 100 / SSRbpcount) + "</td><td>"
                                    + round.format((float) Gci * 100 / SSRbpcount) + "</td><td>"
                                    + round.format((float) cicount / SSRcount) + "</td><td>"
                                    + round.format((float) cibpcount / seqcount) + "</td><td>"
                                    + round.format((float) cibpcount / SSRbpcount) + "</td></tr>");
                        }
                    }

                    out.println("|TOTAL       |" + cell(Integer.toString(SSRcount), 7) + "|"
                            + cell(Long.toString(SSRbpcount), 12) + "|" + cell((float) A * 100 / SSRbpcount, 7)
                            + "|" + cell((float) T * 100 / SSRbpcount, 7) + "|"
                            + cell((float) C * 100 / SSRbpcount, 7) + "|"
                            + cell((float) G * 100 / SSRbpcount, 7) + "|" + cell(relfreq, 15) + "|"
                            + cell((float) SSRbpcount / seqcount, 15) + "|" + cell((float) abfreq, 15) + "|");
                    out.println(
                            "|____________|_______|____________|_______|_______|_______|_______|_______________|_______________|_______________|");
                    out.println("Genome length (bp): " + seqcount);
                    out.println("Relative Frequency: Count of each motif type / total SSR count");
                    out.println("Abundance: bp of each motif type / total sequence bp");
                    out.println("Relative Abundance: bp of each motif type / total microsatellites bp");
                    out.println();
                    out.println();
                    out.close();
                    html.println("<tr><td><b>TOTAL</b></td><td>" + SSRcount + "</td><td>" + SSRbpcount
                            + "</td><td>" + round.format((float) A * 100 / SSRbpcount) + "</td><td>"
                            + round.format((float) T * 100 / SSRbpcount) + "</td><td>"
                            + round.format((float) C * 100 / SSRbpcount) + "</td><td>"
                            + round.format((float) G * 100 / SSRbpcount) + "</td><td>"
                            + round.format((float) relfreq) + "</td><td>"
                            + round.format((float) SSRbpcount / seqcount) + "</td><td>"
                            + round.format((float) abfreq) + "</td></tr></table></html>");
                    html.close();

                    try {
                        Runtime.getRuntime().exec("notepad " + file);
                    } catch (IOException ex) {
                        Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }

            }

            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

        }
    });

    selectsp = new JButton("Select new Species");
    selectsp.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                input_frame frame = new input_frame();
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(updateframe.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(updateframe.class.getName()).log(Level.SEVERE, null, ex);
            }
            dispose();
        }
    });

    quit = new JButton("Quit");
    quit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });

    tab = new JTabbedPane();
    tab.setSize(790, 590);

    // about us panel
    ImageIcon image = new ImageIcon("miga.png");
    JLabel label = new JLabel("", image, JLabel.CENTER);
    contact = new JLabel(
            "<html><b><p>Machine Learning and Knowledge Discovery Group</p><p>Computer Science Department</p><p>Aristotle University of Thessaloniki</p><p> </p><p>In collaboration with the laboratory of</p><p> </p><p>Population Genetics of Animal Organisms</p><p>Department of Genetics, Development and Molecular Biology</p><p>School of Biology</p><p>Aristotle University of Thessaloniki</p><p> </p><p> </p><p>For any comments or information please contact with:</p><p><a href=\"mailto:ikavak@csd.auth.gr\">ikavak@csd.auth.gr</a></p></b></html>");
    about = new JPanel();
    about.setLayout(new GridBagLayout());
    GridBagConstraints ab = new GridBagConstraints();

    ab.fill = GridBagConstraints.WEST;
    ab.weightx = 0.5;
    ab.weighty = 0.5;
    ab.gridx = 0;
    ab.gridy = 0;
    about.add(label, ab);

    ab.fill = GridBagConstraints.WEST;
    ab.weightx = 0.5;
    ab.weighty = 0.5;
    ab.gridx = 0;
    ab.gridy = 1;
    about.add(contact, ab);

    //end of about us 

    //below are the rest of th panels

    paneltop = new JPanel();
    TitledBorder t = BorderFactory.createTitledBorder("Select Period");
    paneltop.setBorder(t);

    paneltop.setLayout(new GridBagLayout());
    GridBagConstraints pt = new GridBagConstraints();

    pt.fill = GridBagConstraints.HORIZONTAL;
    pt.weightx = 0.5;
    pt.weighty = 0.5;
    pt.gridx = 0;
    pt.gridy = 0;
    paneltop.add(mono, pt);

    pt.fill = GridBagConstraints.HORIZONTAL;
    pt.weightx = 0.5;
    pt.weighty = 0.5;
    pt.gridx = 0;
    pt.gridy = -1;
    paneltop.add(di, pt);

    pt.fill = GridBagConstraints.HORIZONTAL;
    pt.weightx = 0.5;
    pt.weighty = 0.5;
    pt.gridx = 0;
    pt.gridy = -2;
    paneltop.add(tri, pt);

    pt.fill = GridBagConstraints.HORIZONTAL;
    pt.weightx = 0.5;
    pt.weighty = 0.5;
    pt.gridx = 0;
    pt.gridy = -3;
    paneltop.add(tetra, pt);

    pt.fill = GridBagConstraints.HORIZONTAL;
    pt.weightx = 0.5;
    pt.weighty = 0.5;
    pt.gridx = 0;
    pt.gridy = -4;
    paneltop.add(penta, pt);

    pt.fill = GridBagConstraints.HORIZONTAL;
    pt.weightx = 0.5;
    pt.weighty = 0.5;
    pt.gridx = 0;
    pt.gridy = -5;
    paneltop.add(hexa, pt);

    panel1 = new JPanel();
    TitledBorder title = BorderFactory.createTitledBorder("Type");
    panel1.setBorder(title);

    panel1.setLayout(new GridBagLayout());
    GridBagConstraints a = new GridBagConstraints();

    a.fill = GridBagConstraints.HORIZONTAL;
    a.weightx = 0.5;
    a.weighty = 0.5;
    a.gridx = 0;
    a.gridy = 0;
    panel1.add(select, a);

    a.fill = GridBagConstraints.HORIZONTAL;
    a.weightx = 0.5;
    a.weighty = 0.5;
    a.gridx = 0;
    a.gridy = -1;
    panel1.add(box1, a);

    a.fill = GridBagConstraints.HORIZONTAL;
    a.weightx = 0.5;
    a.weighty = 0.5;
    a.gridx = 0;
    a.gridy = -2;
    panel1.add(box2, a);

    a.fill = GridBagConstraints.HORIZONTAL;
    a.weightx = 0.5;
    a.weighty = 0.5;
    a.gridx = 0;
    a.gridy = -3;
    panel1.add(box3, a);

    panel2 = new JPanel();
    panel2.setVisible(false);
    TitledBorder title2 = BorderFactory.createTitledBorder("More Options");
    panel2.setBorder(title2);

    panel2.setLayout(new GridBagLayout());
    GridBagConstraints b = new GridBagConstraints();

    b.fill = GridBagConstraints.HORIZONTAL;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 0;
    b.gridy = 0;
    panel2.add(minimumssrlen, b);

    b.fill = GridBagConstraints.CENTER;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 1;
    b.gridy = 0;
    panel2.add(score, b);

    b.fill = GridBagConstraints.HORIZONTAL;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 0;
    b.gridy = -1;
    panel2.add(gapmax, b);

    b.fill = GridBagConstraints.CENTER;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 1;
    b.gridy = -1;
    panel2.add(max, b);

    b.fill = GridBagConstraints.HORIZONTAL;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 0;
    b.gridy = -2;
    panel2.add(minlenpregap, b);

    b.fill = GridBagConstraints.CENTER;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 1;
    b.gridy = -2;
    panel2.add(minpregap, b);

    b.fill = GridBagConstraints.HORIZONTAL;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 0;
    b.gridy = -3;
    panel2.add(gapcomp, b);

    b.fill = GridBagConstraints.CENTER;
    b.weightx = 0.5;
    b.weighty = 0.5;
    b.gridx = 1;
    b.gridy = -3;
    panel2.add(maxgapcomp, b);

    paneldownleft = new JPanel();
    paneldownleft.setVisible(false);
    TitledBorder titledl = BorderFactory.createTitledBorder("Compound SSR options");
    paneldownleft.setBorder(titledl);
    paneldownleft.setLayout(new GridBagLayout());

    GridBagConstraints dl = new GridBagConstraints();

    dl.fill = GridBagConstraints.CENTER;
    dl.weightx = 0.5;
    dl.weighty = 0.5;
    dl.gridx = 0;
    dl.gridy = 0;
    paneldownleft.add(com, dl);

    dl.fill = GridBagConstraints.CENTER;
    dl.weightx = 0.5;
    dl.weighty = 0.5;
    dl.gridx = 0;
    dl.gridy = -1;
    paneldownleft.add(incom, dl);

    paneldownright = new JPanel();
    paneldownright.setLayout(new GridBagLayout());
    GridBagConstraints dr = new GridBagConstraints();

    dr.fill = GridBagConstraints.CENTER;
    dr.weightx = 0.5;
    dr.weighty = 0.5;
    dr.gridx = 0;
    dr.gridy = 0;
    paneldownright.add(show, dr);

    dr.fill = GridBagConstraints.CENTER;
    dr.weightx = 0.5;
    dr.weighty = 0.5;
    dr.gridx = 0;
    dr.gridy = -1;
    paneldownright.add(selectsp, dr);

    dr.fill = GridBagConstraints.CENTER;
    dr.weightx = 0.5;
    dr.weighty = 0.5;
    dr.gridx = 0;
    dr.gridy = -2;
    paneldownright.add(quit, dr);

    panelup = new JPanel();
    TitledBorder titleup = BorderFactory.createTitledBorder("Statistics");
    panelup.setBorder(titleup);

    panelup.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.gridx = 0;
    c.gridy = 0;
    panelup.add(paneltop, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.gridx = 1;
    c.gridy = 0;
    panelup.add(panel1, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.gridx = 0;
    c.gridy = -1;
    panelup.add(paneldownleft, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.gridx = 1;
    c.gridy = -1;
    panelup.add(panel2, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.gridx = 0;
    c.gridy = -2;
    panelup.add(paneldownright, c);

    TitledBorder s = BorderFactory.createTitledBorder("Standardization");
    std.setBorder(s);
    std.add(no_st);
    std.add(part_st);
    std.add(full_st);
    std.setEnabled(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.gridx = 0;
    c.gridy = -3;
    panelup.add(std, c);

    tab.add(panelup, "Statistics");

    panelshow = new JPanel();
    TitledBorder ps = BorderFactory.createTitledBorder("Sequence Retrieval");
    panelshow.setBorder(ps);

    panelshow.setLayout(new GridBagLayout());
    GridBagConstraints psg = new GridBagConstraints();

    panelshowup = new JPanel();

    panelshowup.setLayout(new GridBagLayout());
    GridBagConstraints p = new GridBagConstraints();

    p.fill = GridBagConstraints.WEST;
    p.weightx = 0.5;
    p.weighty = 0.5;
    p.gridx = 0;
    p.gridy = 0;
    panelshowup.add(lab, p);

    panelshowd = new JPanel();

    panelshowd.setLayout(new GridBagLayout());
    GridBagConstraints pd = new GridBagConstraints();

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 0;
    pd.gridy = -1;
    panelshowd.add(startlab, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 1;
    pd.gridy = -1;
    panelshowd.add(startnum, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 0;
    pd.gridy = -2;
    panelshowd.add(endlab, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 1;
    pd.gridy = -2;
    panelshowd.add(endnum, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 0;
    pd.gridy = -3;
    panelshowd.add(titlelab, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 1;
    pd.gridy = -3;
    panelshowd.add(titlef, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 0;
    pd.gridy = -4;
    panelshowd.add(flk, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 1;
    pd.gridy = -4;
    panelshowd.add(new JLabel(" "), pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 0;
    pd.gridy = -5;
    panelshowd.add(flankst, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 1;
    pd.gridy = -5;
    panelshowd.add(flankstn, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 0;
    pd.gridy = -6;
    panelshowd.add(flankend, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 1;
    pd.gridy = -6;
    panelshowd.add(flankendn, pd);

    pd.fill = GridBagConstraints.CENTER;
    pd.weightx = 0.5;
    pd.weighty = 0.5;
    pd.gridx = 1;
    pd.gridy = -7;
    panelshowd.add(retrieve, pd);

    psg.fill = GridBagConstraints.CENTER;
    psg.weightx = 0.5;
    psg.weighty = 0.5;
    psg.gridx = 0;
    psg.gridy = 0;
    panelshow.add(panelshowup, psg);

    psg.fill = GridBagConstraints.CENTER;
    psg.weightx = 0.5;
    psg.weighty = 0.5;
    psg.gridx = 0;
    psg.gridy = -1;
    panelshow.add(panelshowd, psg);

    psg.fill = GridBagConstraints.CENTER;
    psg.weightx = 0.5;
    psg.weighty = 0.5;
    psg.gridx = 0;
    psg.gridy = -2;
    panelshow.add(sbrText, psg);

    tab.add(panelshow, "Sequence Retrieval");
    tab.add(about, "About us");
    add(tab);
    setVisible(true);

}