Beispiel #1
0
 private void lireMatFormu(
     Programme prog, StringBuffer buf, int indent, Argument arg, String indice1, String indice2) {
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   // les boucles
   instr_pere.addVariable(new Variable(indice1, "ENTIER"));
   instr_pere.addVariable(new Variable(indice2, "ENTIER"));
   Divers.ecrire(
       buf,
       "for(int "
           + indice1
           + "=0; "
           + indice1
           + "<"
           + prog.getDim(1, arg)
           + "; "
           + indice1
           + "++) {",
       indent);
   Divers.ecrire(
       buf,
       "for(int "
           + indice2
           + "=0; "
           + indice2
           + "<"
           + prog.getDim(2, arg)
           + "; "
           + indice2
           + "++) {",
       indent + 1);
   Argument arg1 =
       new Argument(arg.nom + "[" + indice1 + "][" + indice2 + "]", arg.getTypeOfMat(), arg.mode);
   lireFormu(prog, buf, indent + 2, arg1);
   Divers.ecrire(buf, "}", indent + 1);
   Divers.ecrire(buf, "}", indent);
 }
Beispiel #2
0
 private void constrMatFormu(
     Programme prog, StringBuffer buf, int indent, String msg, String p_pere, Argument arg) {
   this.constrLabelFormu(prog, buf, indent, msg, p_pere, arg);
   Divers.indenter(buf, indent);
   String p_zone = "p_" + arg.nom;
   p_zone = Divers.remplacer(p_zone, ".", "_");
   Divers.ecrire(
       buf,
       p_zone
           + "=new JPanel(new GridLayout("
           + prog.getMaxTab()
           + ","
           + prog.getMaxTab()
           + ")); ");
   Divers.ecrire(buf, p_pere + ".add(" + p_zone + "); ");
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   if (arg.isMatBooleens()) {
     Divers.indenter(buf, indent);
     Divers.ecrire(
         buf, zone + "=new Checkbox [" + prog.getMaxTab() + "][" + prog.getMaxTab() + "]; ");
   } else if (arg.isMatTextes() && arg.avecTexteRadio()) {
     String group = "group_" + arg.nom;
     group = Divers.remplacer(group, ".", "_");
     Divers.indenter(buf, indent);
     Divers.ecrire(
         buf, group + "=new ButtonGroup[" + prog.getMaxTab() + "][" + prog.getMaxTab() + "]; ");
     String p_group = "p_" + group;
     Divers.indenter(buf, indent);
     Divers.ecrire(
         buf, p_group + "=new JPanel[ " + prog.getMaxTab() + "][" + prog.getMaxTab() + "]; ");
     String[] liste = arg.getTexteRadio();
     int n = liste.length;
     for (int i = 0; i < n; i++) {
       String zone_bouton = "zone_" + liste[i] + "_" + arg.nom;
       zone_bouton = Divers.remplacer(zone_bouton, ".", "_");
       Divers.indenter(buf, indent);
       Divers.ecrire(
           buf,
           zone_bouton
               + "=new JRadioButton[ "
               + prog.getMaxTab()
               + "]["
               + prog.getMaxTab()
               + "]; ");
     }
   } else if (arg.isMatTextes() && arg.avecTexteListe()) {
     String model = "model_" + arg.nom;
     model = Divers.remplacer(model, ".", "_");
     Divers.indenter(buf, indent);
     Divers.ecrire(
         buf, zone + "=new JList [" + prog.getMaxTab() + "][" + prog.getMaxTab() + "]; ");
     Divers.indenter(buf, indent);
     Divers.ecrire(
         buf,
         model + "=new DefaultListModel [" + prog.getMaxTab() + "][" + prog.getMaxTab() + "]; ");
   } else {
     Divers.indenter(buf, indent);
     Divers.ecrire(
         buf, zone + "=new JTextField [" + prog.getMaxTab() + "][" + prog.getMaxTab() + "]; ");
   }
   // les boucles
   arg.addVariable(new Variable("i1", "ENTIER"));
   arg.addVariable(new Variable("j1", "ENTIER"));
   Divers.ecrire(buf, "for(int i1=0; i1<" + prog.getMaxTab() + "; i1++) {", indent);
   Divers.ecrire(buf, "for(int j1=0; j1<" + prog.getMaxTab() + "; j1++) {", indent + 1);
   String msg1 = null;
   Argument arg1 = new Argument(arg.nom + "[i1][j1]", arg.getTypeOfMat(), arg.mode);
   constrFormu(prog, buf, indent + 2, msg1, p_zone, arg1);
   Divers.ecrire(buf, "}", indent + 1);
   Divers.ecrire(buf, "}", indent);
 }