Search in sources :

Example 1 with NucleotideDecorator

use of dr.app.beauti.alignmentviewer.NucleotideDecorator in project beast-mcmc by beast-dev.

the class DataPanel method showAlignment.

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);
    }
}
Also used : AlignmentViewer(dr.app.beauti.alignmentviewer.AlignmentViewer) AminoAcidDecorator(dr.app.beauti.alignmentviewer.AminoAcidDecorator) NucleotideDecorator(dr.app.beauti.alignmentviewer.NucleotideDecorator) Alignment(dr.evolution.alignment.Alignment) StateCellDecorator(dr.app.beauti.alignmentviewer.StateCellDecorator)

Aggregations

AlignmentViewer (dr.app.beauti.alignmentviewer.AlignmentViewer)1 AminoAcidDecorator (dr.app.beauti.alignmentviewer.AminoAcidDecorator)1 NucleotideDecorator (dr.app.beauti.alignmentviewer.NucleotideDecorator)1 StateCellDecorator (dr.app.beauti.alignmentviewer.StateCellDecorator)1 Alignment (dr.evolution.alignment.Alignment)1