Ejemplo n.º 1
0
  public void initSiRNA() {

    siRNA s = new siRNA("p53.fasta");
    List list = s.siRNA();
    vertical.setBackground(new java.awt.Color(255, 215, 0));
    vertical.setSize(this.scrollPane1.getWidth(), this.scrollPane1.getHeight());

    s1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    s2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    //
    // Modify the text color
    s1.setForeground(Color.black);
    s2.setForeground(Color.black);
    s1.setFont(new java.awt.Font("Arial Black", 0, 18));
    s2.setFont(new java.awt.Font("Arial Black", 0, 18));
    // Modify the background color
    // s1.setBackground(new Color(255, 192, 16));
    // s2.setBackground(new Color(255, 192, 16));
    //

    t1 = new JTextArea();
    t2 = new JTextArea();
    //        t1.setLineWrap(true);
    //        t2.setLineWrap(true);
    t1.setText(list.get(0).toString());
    t2.setText(list.get(1).toString());

    vertical.add(s1);
    vertical.add(t1);
    vertical.add(s2);
    vertical.add(t2);

    scrollPane1.add(vertical);
  }
Ejemplo n.º 2
0
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed

    OpenFastaFile f = new OpenFastaFile("", "");
    try { // f.showSaveDataDialog();
      FilePath = f.showOpenDataDialog();
    } catch (IOException ex) {
      //            Logger.getLogger(Browser.class.getName()).log(Level.SEVERE, null, ex);
    }

    if (FilePath.isEmpty()) {
      return;
    }
    Box vertical = Box.createVerticalBox();
    vertical.setSize(this.scrollPane1.getWidth(), this.scrollPane1.getHeight());
    siRNA s = new siRNA(new File(FilePath));

    siRnaInputArea.setText(s.getGene());

    if (s.isValid()) {
      List list = s.siRNA();
      t1.setText(list.get(0).toString());
      t2.setText(list.get(1).toString());
      s1.setForeground(Color.black);
      s2.setForeground(Color.black);
    }
  } // GEN-LAST:event_jButton1ActionPerformed
Ejemplo n.º 3
0
  /**
   * Create JPanel asking users to select the file or directory containing files to be mapped and an
   * existing mapping file if they have one.
   *
   * @return JPanel containing elements!
   */
  private JLayeredPane createSelectFilesPanel() {
    // create overall panel

    final JPanel selectFilesContainer = new JPanel();
    selectFilesContainer.setSize(new Dimension(400, 100));
    selectFilesContainer.setLayout(new BoxLayout(selectFilesContainer, BoxLayout.PAGE_AXIS));

    // create selector for mapping files
    final FileSelectionPanel fileToMapFSP =
        new FileSelectionPanel(
            "<html>please select file(s) to be mapped (txt, csv or xls (Excel). Please ensure "
                + "that this file has <b>no empty columns</b> and if possible, please remove any special characters, e.g. &mu;</html>",
            fileChooser);
    selectFilesContainer.add(fileToMapFSP);

    JPanel selectMappingPanel = new JPanel();
    selectMappingPanel.setLayout(new BoxLayout(selectMappingPanel, BoxLayout.PAGE_AXIS));
    selectMappingPanel.setOpaque(false);

    // need a jcheckbox to ask users if they wish to use a mapping
    JPanel useMappingContainer = new JPanel(new BorderLayout());
    useMappingContainer.setOpaque(false);

    // need a file selection panel to select the file.
    JFileChooser mappingFileChooser = new JFileChooser();
    mappingFileChooser.setDialogTitle("Choose mapping file (XML)");
    mappingFileChooser.setApproveButtonText("select file");
    mappingFileChooser.setFont(UIHelper.VER_11_PLAIN);
    mappingFileChooser.setFileFilter(new CustomizableFileFilter("xml"));

    final FileSelectionPanel savedMappingsFile =
        new FileSelectionPanel(
            "<html>please select saved mapping file (xml): </html>", mappingFileChooser);
    savedMappingsFile.setVisible(false);

    final JCheckBox useMapping = new JCheckBox("use a previous mapping?");
    UIHelper.renderComponent(useMapping, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    useMapping.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            savedMappingsFile.setVisible(useMapping.isSelected());
          }
        });

    useMappingContainer.add(useMapping, BorderLayout.WEST);

    selectMappingPanel.add(useMappingContainer);

    selectMappingPanel.add(savedMappingsFile);

    selectFilesContainer.add(selectMappingPanel);

    final RoundedJTextField rowOffset = new RoundedJTextField(3);
    rowOffset.setEnabled(false);
    rowOffset.setSize(new Dimension(20, 20));
    rowOffset.setText("1");

    final JCheckBox overrideRowPosition = new JCheckBox("override row start position?");
    UIHelper.renderComponent(overrideRowPosition, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    overrideRowPosition.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            rowOffset.setEnabled(overrideRowPosition.isSelected());
          }
        });

    Box fileInputPanel = Box.createHorizontalBox();
    fileInputPanel.setSize(new Dimension(100, 20));
    fileInputPanel.add(overrideRowPosition);
    fileInputPanel.add(Box.createHorizontalStrut(5));
    fileInputPanel.add(rowOffset);

    selectFilesContainer.add(fileInputPanel);

    selectFilesContainer.add(selectMappingPanel);

    final JCheckBox mapToBlankFieldsCheckbox = new JCheckBox("Do not remove blank fields?", false);
    UIHelper.renderComponent(
        mapToBlankFieldsCheckbox, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    mapToBlankFieldsCheckbox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            mapToBlankFields = mapToBlankFieldsCheckbox.isSelected();
          }
        });

    JPanel removeBlanksContainer = new JPanel(new BorderLayout());
    removeBlanksContainer.setOpaque(false);

    removeBlanksContainer.add(mapToBlankFieldsCheckbox, BorderLayout.WEST);

    selectFilesContainer.add(removeBlanksContainer);

    JPanel statusPanel = new JPanel(new GridLayout(1, 1));
    statusPanel.setPreferredSize(new Dimension(400, 30));
    final JLabel statusLab = UIHelper.createLabel("", UIHelper.VER_11_BOLD, UIHelper.RED_COLOR);
    statusPanel.add(statusLab);

    selectFilesContainer.add(statusPanel);

    final JLayeredPane finalLayout =
        getGeneralLayout(selectFilesHeader, breadcrumb1, "", selectFilesContainer, getHeight());

    final MouseListener[] listeners = new MouseListener[2];

    listeners[0] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            backButton.setIcon(backOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            backButton.setIcon(back);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            backButton.setIcon(back);
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    ApplicationManager.getCurrentApplicationInstance().setCurrentPage(menuPanels);
                    ApplicationManager.getCurrentApplicationInstance()
                        .setGlassPanelContents(menuPanels.getCreateISAMenuGUI());
                    menuPanels.startAnimation();
                  }
                });
          }
        };

    assignListenerToLabel(backButton, listeners[0]);

    listeners[1] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            nextButton.setIcon(nextOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            nextButton.setIcon(next);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            nextButton.setIcon(next);

            Thread loadFile =
                new Thread(
                    new Runnable() {
                      public void run() {
                        ISAcreatorProperties.setProperty(
                            "isacreator.rowOffset",
                            rowOffset.isEnabled() ? rowOffset.getText() : "1");

                        if (useMapping.isSelected()) {

                          if (!savedMappingsFile.getSelectedFilePath().trim().equals("")) {

                            MappingXMLLoader loader =
                                new MappingXMLLoader(savedMappingsFile.getSelectedFilePath());
                            try {
                              preExistingMapping = loader.loadMappings();
                            } catch (XmlException e) {
                              log.error(e.getMessage());
                              statusLab.setText(
                                  "<html>problem found in xml for saved mapping: "
                                      + e.getMessage()
                                      + " </html>");
                              setCurrentPage(lastPage);
                              return;
                            } catch (IOException e) {
                              log.error(e.getMessage());
                              statusLab.setText(
                                  "<html>problem found when resolving file for saved mapping: "
                                      + e.getMessage()
                                      + " </html>");
                              setCurrentPage(lastPage);
                              return;
                            }
                          } else {
                            statusLab.setText(
                                "<html>please select a file containing previous mappings...</html>");
                            setCurrentPage(lastPage);
                            return;
                          }
                        } else {
                          log.info("Mapping is not selected");
                          statusLab.setText("");
                        }

                        if (fileToMapFSP.notEmpty()) {
                          previousPage.push(new HistoryComponent(finalLayout, listeners));
                          statusLab.setText("");
                          SwingUtilities.invokeLater(
                              new Runnable() {
                                public void run() {
                                  setCurrentPage(
                                      createAssayUsedPanel(fileToMapFSP.getSelectedFilePath()));
                                }
                              });
                        } else {
                          statusLab.setText(
                              "<html>please <strong>select</strong> a file to map!</html>");
                          setCurrentPage(lastPage);
                        }
                      }
                    });

            if (fileToMapFSP.notEmpty()
                && fileToMapFSP.checkFileExtensionValid("xls", "csv", "txt")) {
              statusLab.setText("");
              lastPage = currentPage;
              setCurrentPage(workingProgressScreen);
              loadFile.start();
            } else {
              statusLab.setText(
                  "<html>please select a file with the extension <strong>.xls</strong>, <strong>.csv</strong> or <strong>.txt</strong>...</html>");
            }
          }
        };
    assignListenerToLabel(nextButton, listeners[1]);
    return finalLayout;
  }