Biojava can render alignments.

The approach is to take the Sequences you want to render, and insert them into a SimpleAlignment object. The next step is to take a TranslatedSequencePanel and connect your Alignment to it.

What you need to do next is to setup the renderers that will render your alignment. Start with a MultiLineRenderer. To the MultiLineRenderer you connect one AlignmentRenderer for each sequence in the alignment. Each AlignmentRenderer should have the label of the sequence it should render set on it. And in the end you connect a SymbolSequenceRenderer to each AlignmentRenderer. The same SymbolSequenceRenderer can be used for all the AlignmentRenderers.

So for an Alignment with three sequences labeled seq1, seq2 and seq3 the renderer tree would look like this:

                    __  AlignmentRenderer --- SymbolSequenceRenderer
                   |    label=labelForSeq1
MultilineRenderer -|--  AlignmentRenderer --- SymbolSequenceRenderer
                   |    label=labelForSeq2
                        AlignmentRenderer --- SymbolSequenceRenderer

The following is a screenshot of the viewer generated by the AlignmentPanel class:

```java /**

* Class to create an alignment and then display it in a viewer.

//Load Java libraries import java.awt.*; import java.util.*; import javax.swing.*;

//Load BioJava libraries import*; import*; import*; import*; import*;

public class AlignmentPanel extends JFrame {

 //Create references to the sequences
 Sequence seq, seq1, seq2, seq3;
 //Instantiate the BioJava GUI elements

 //TranslatedSequencePanel to hold the renderers 
 TranslatedSequencePanel tsp = new TranslatedSequencePanel();
 //AlignmentRenderer to hold each sequence
 AlignmentRenderer render1, render2, render3;
 //MultiLineRenderer to allow display of multiple tracks in the TranslatedSequencePanel
 MultiLineRenderer multi = new MultiLineRenderer();
 //SymbolSequenceRenderer to handle display of the sequence symbols - only one instance is needed
 SymbolSequenceRenderer symbol = new SymbolSequenceRenderer();
 //RulerRenderer to display sequence coordinates
 RulerRenderer ruler = new RulerRenderer();
 public AlignmentPanel(){
   super("Alignment Panel");

   //Create the sequences for the alignment
   try {
     seq2 = DNATools.createGappedDNASequence("GAAATCGATC-ATAGC----------TACGATACGACTAGCATTCCGAC", "seq2");
     seq3 = DNATools.createGappedDNASequence("GAAAT--ATC-ATAGC----------TACGATACGACTAGCATTCCGAC", "seq3");
   catch (BioException bioe) {
     System.err.println("Bioexception: " + bioe);
   //Add the sequences to a Map 
   Map<String, Sequence> list = new HashMap();        
   list.put("1", seq1);        
   list.put("2", seq2);        
   list.put("3", seq3);

   //Use the Map to create a new SimpleAlignment
   SimpleAlignment ali = new SimpleAlignment((Map) list);
   //Instantiate the renderers and set the labels and renderers
   render1 = new AlignmentRenderer();

   render2 = new AlignmentRenderer();  
   render3 = new AlignmentRenderer(); 
   //Add the alignment renderers to the multi-line renderer
   //Set the sequence in the TranslatedSequencePanel
   //Set the background colour of the TranslatedSequencePanel
   //Set the renderer for the TranslatedSequencePanel
   //Set up the display
   Container con = getContentPane();
   con.setLayout(new BorderLayout());
   con.add(tsp, BorderLayout.CENTER);
  * Main method
 public static void main(String args []){
   new AlignmentPanel();