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
|
private void buildTree(DefaultMutableTreeNode racine,int Acteur1, int Acteur2, ArrayList<Integer> Actions1, ArrayList<Integer> Actions2){
if(Actions1.size() != 0 && Actions2.size() != 0){
for(int i = 0; i < Actions1.size(); i++){
String S = "(";
for(int h = 0; h <= i; h++){
S = S + Actions1.get(h)+",";
if(Actions2.contains(Actions1.get(h))){
Actions2.remove(Actions2.indexOf(Actions1.get(h)));
}
Actions1.remove(h);
}
S = S + ")";
DefaultMutableTreeNode rep = new DefaultMutableTreeNode(Acteur1+","+i+"," +S);
//Et une branche
for(int j = 0; j < Actions2.size(); j++){
S = "(";
for(int h = 0; h <= j; h++){
S = S + Actions2.get(h)+",";
if(Actions1.contains(Actions2.get(h))){
Actions1.remove(Actions1.indexOf(Acteur2.get(h)));
}
Actions2.remove(h);
}
S = S + ")";
DefaultMutableTreeNode rep2 = new DefaultMutableTreeNode(Cluster2+","+j+ ","+S);
//Cette fois, on ajoute les feuilles
rep.add(rep2);
if(Actions1.size() == 0){
rep.add(new DefaultMutableTreeNode("feuille"));
if(Actions2.size() == 0){
rep2.add(new DefaultMutableTreeNode("feuille"));
}
buildTree(racine,Acteur1, Acteur2, Actions1, Actions2);
Actions1 = (ArrayList<Integer>) this.Actions1.clone();
Actions2 = (ArrayList<Integer>) this.Actions2.clone();
}
racine.add(rep);
}
}
} |
Partager