Beispiel #1
0
  private void showAlignment() {

    int[] selRows = dataTable.getSelectedRows();
    for (int row : selRows) {
      AbstractPartitionData partition = options.dataPartitions.get(row);
      Alignment alignment = null;

      if (partition instanceof PartitionData)
        alignment = ((PartitionData) partition).getAlignment();

      // alignment == null if partition is trait or microsat
      // http://code.google.com/p/beast-mcmc/issues/detail?id=343
      if (alignment == null) {
        JOptionPane.showMessageDialog(
            this,
            "Cannot display traits or microsatellite data currently.\nUse the traits panel to view and edit traits.",
            "Illegal Argument Exception",
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      JFrame frame = new JFrame();
      frame.setSize(800, 600);

      AlignmentViewer viewer = new AlignmentViewer();
      if (alignment.getDataType().getType() == DataType.NUCLEOTIDES) {
        viewer.setCellDecorator(new StateCellDecorator(new NucleotideDecorator(), false));
      } else if (alignment.getDataType().getType() == DataType.AMINO_ACIDS) {
        viewer.setCellDecorator(new StateCellDecorator(new AminoAcidDecorator(), false));
      } else {
        // no colouring
      }
      viewer.setAlignmentBuffer(new BeautiAlignmentBuffer(alignment));

      JPanel panel = new JPanel(new BorderLayout());
      panel.setOpaque(false);
      panel.add(viewer, BorderLayout.CENTER);

      JPanel infoPanel = new JPanel(new BorderLayout());
      infoPanel.setOpaque(false);
      panel.add(infoPanel, BorderLayout.SOUTH);

      frame.setContentPane(panel);
      frame.setVisible(true);
    }
  }
Beispiel #2
0
  public DataPanel(
      BeautiFrame parent,
      Action importDataAction,
      Action removeDataAction /*, Action importTraitsAction*/) {

    this.frame = parent;

    dataTableModel = new DataTableModel();
    dataTable = new JTable(dataTableModel);

    dataTable.getTableHeader().setReorderingAllowed(false);
    dataTable
        .getTableHeader()
        .setDefaultRenderer(new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    TableColumn col = dataTable.getColumnModel().getColumn(5);
    ComboBoxRenderer comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    //        col = dataTable.getColumnModel().getColumn(5);
    //        comboBoxRenderer = new ComboBoxRenderer();
    //        comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    //        col.setCellRenderer(comboBoxRenderer);

    col = dataTable.getColumnModel().getColumn(6);
    comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    col = dataTable.getColumnModel().getColumn(7);
    comboBoxRenderer = new ComboBoxRenderer();
    comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    col.setCellRenderer(comboBoxRenderer);

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(dataTable);

    dataTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    dataTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              showAlignment();
            }
          }
        });

    scrollPane =
        new JScrollPane(
            dataTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setOpaque(false);

    JToolBar toolBar1 = new JToolBar();
    toolBar1.setFloatable(false);
    toolBar1.setOpaque(false);
    toolBar1.setLayout(new BoxLayout(toolBar1, BoxLayout.X_AXIS));

    JButton button = new JButton(unlinkModelsAction);
    unlinkModelsAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkModelsAction);
    linkModelsAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    toolBar1.addSeparator();

    button = new JButton(unlinkClocksAction);
    unlinkClocksAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkClocksAction);
    linkClocksAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    toolBar1.addSeparator();

    button = new JButton(unlinkTreesAction);
    unlinkTreesAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    button = new JButton(linkTreesAction);
    linkTreesAction.setEnabled(false);
    PanelUtils.setupComponent(button);
    toolBar1.add(button);

    // too crowded on the toolbar  - just double click to show
    //            button = new JButton(showAction);
    //            showAction.setEnabled(false);
    //            PanelUtils.setupComponent(button);
    //            toolBar1.add(button);

    ActionPanel actionPanel1 = new ActionPanel(false);
    actionPanel1.setAddAction(importDataAction);
    actionPanel1.setRemoveAction(removeDataAction);
    removeDataAction.setEnabled(false);

    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.setOpaque(false);
    controlPanel1.add(actionPanel1);

    controlPanel1.add(new JLabel("   "));
    PanelUtils.setupComponent(createImportTraitButton);
    controlPanel1.add(createImportTraitButton);

    //        controlPanel1.add(new JLabel(" or "));
    //
    //        button = new JButton(importTraitsAction);
    //        PanelUtils.setupComponent(button);
    //        controlPanel1.add(button);

    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.setOpaque(false);
    panel1.add(useStarBEASTCheck, BorderLayout.NORTH);
    panel1.add(toolBar1, BorderLayout.SOUTH);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    add(panel1, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(controlPanel1, BorderLayout.SOUTH);

    useStarBEASTCheck.setEnabled(false);
    useStarBEASTCheck.setToolTipText(STARBEASTOptions.CITATION);
    useStarBEASTCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(
              ActionEvent e) { // wrong listener Issue 397: *BEAST in BEAUti is broken
            frame.setupStarBEAST(useStarBEASTCheck.isSelected());
            dataTableModel.fireTableDataChanged();
          }
        });
  }