1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
public class FenetreAlignement extends JFrame {
private JSplitPane split;
private MyTextPane textPaneSeq = new MyTextPane();
private MyTextPane textPaneID = new MyTextPane();
private MyJScrollPane scroll;
private JPanel panId = new JPanel();
private JPanel panSeq = new JPanel();
private ArbreAlignement arbre;
public FenetreAlignement(ArbreAlignement arbre) {
this("ALignement multiple de sequences",300000,300000,false,arbre);
}
public FenetreAlignement(String titre, int largeur, int hauteur, boolean boolExit, ArbreAlignement arbre) {
this.arbre = arbre;
this.setTitle(titre);
this.setSize(largeur,hauteur);
/* centrage */
this.setLocationRelativeTo(null);
if(boolExit == true)
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
else
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
int taille;
char c;
HashMap<Integer,SequenceAlignement> sequencesInitiales = arbre.getSequences();
ArrayList<String> seq = arbre.getResultatFinal();
StyledDocument doc = textPaneSeq.getStyledDocument();
StyledDocument docID = textPaneID.getStyledDocument();
Color cA = new Color(64,128,255);
Attribut styleA = new Attribut("Courier new",18,cA);
Attribut styleT = new Attribut("Courier new",18,Color.PINK);
Attribut styleG = new Attribut("Courier new",18,Color.CYAN);
Attribut styleC = new Attribut("Courier new",18,Color.MAGENTA);
Attribut styleDefaut = new Attribut("Courier new",18,Color.WHITE);
try {
for(String s : seq) {
taille = s.length();
for(int i = 0; i < taille; i++) {
c = s.charAt(i);
if(c == 'A') {
doc.insertString(doc.getLength(),"A",styleA);
}
else if(c == 'G') {
doc.insertString(doc.getLength(),"G",styleG);
}
else if(c == 'C') {
doc.insertString(doc.getLength(),"C",styleC);
}
else if(c == 'T') {
doc.insertString(doc.getLength(),"T",styleT);
}
else {
doc.insertString(doc.getLength(),Character.toString(c),styleDefaut);
}
}
doc.insertString(doc.getLength(),"\n",styleDefaut);
}
}
catch(Exception e){}
try {
for (HashMap.Entry<Integer, SequenceAlignement> entry :sequencesInitiales.entrySet()) {
docID.insertString(docID.getLength(),entry.getValue().getId(),styleDefaut);
docID.insertString(docID.getLength(),"\n",styleDefaut);
}
}
catch (BadLocationException e){}
scroll = new MyJScrollPane(textPaneSeq,JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panId, panSeq);
split.setDividerLocation(60);
split.setRightComponent(scroll);
split.setLeftComponent(textPaneID);
this.getContentPane().add(split);
this.setVisible(true);
} |
Partager