[Biojava-l] AlignmentRenderer works with TranslatedSequencePanel
but not SequencePanel???
Mark Southern
msouthern at exsar.com
Tue Apr 5 16:39:52 EDT 2005
The attached example code renders an alignment when used with a
TranslatedSequencePanel but not with a SequencePanel - the SequencePanel
remains blank.
A diff of TranslatedSequencePanel and SequencePanel shows they are quite
different. I am not sure what is going on.
Can anyone give me some pointers as to how to get this to work in a
SequencePanel? I would prefer this since SequencePanel can be scrolled in a
JScrollPane and TranslatedSequencePanel cannot.
Cheers,
Mark.
import java.awt.*;
import java.io.*;
import javax.swing.*;
import java.util.*;
import org.biojava.bio.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.impl.*;
import org.biojava.bio.seq.io.*;
import org.biojava.bio.symbol.*;
public class Test{
/** Creates a new instance of Test */
private Test() {
}
public static void main(String[] args) throws Exception{
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
// doesn't work with a SequencePanel
SequencePanel v = new SequencePanel();
v.setFont( new Font("Courier",Font.PLAIN, 12));
f.getContentPane().add(v, java.awt.BorderLayout.CENTER);
BufferedReader br = new BufferedReader( new FileReader( new File(
args[0] ) ) );
Alignment a = (Alignment)SeqIOTools.fileToBiojava(
AlignIOConstants.MSF_AA, br);
v.setSequence(a);
MultiLineRenderer mlr = new MultiLineRenderer();
SymbolSequenceRenderer ssr = new SymbolSequenceRenderer();
for(Iterator it = a.getLabels().iterator(); it.hasNext(); ){
Object o = it.next();
AlignmentRenderer ar = new AlignmentRenderer();
ar.setLabel(o);
ar.setRenderer(ssr);
mlr.addRenderer(ar);
}
v.setRenderer(mlr);
f.pack();
f.setVisible(true);
}
}
More information about the Biojava-l
mailing list