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 88 89 90 91 92 93 94 95 96 97 98 99 100
   |  
package compdecomp_jpeg;
 
import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
 
public class Formule {
 
  private transient static  ArrayList<ArrayList<Double>> qi = new ArrayList<ArrayList<Double>>(),
                                               qj = new ArrayList<ArrayList<Double>>();  //Non je ne veut pas sérialisé
  //Déclaration de la 1 sur 64 matrice
  private static ArrayList<ArrayList<Double>> mat_val = new ArrayList<ArrayList<Double>>();
 
    public Formule() {
 
    double tpi=0; 
    for(int u=0; u < 8; u++)
    {  
     ArrayList<Double> tempi = new ArrayList<Double>();
     for(int i=0; i < 8; i++)
     {
      tpi= (((2 * (double)i +1) * (double)u * (22/ (double)7)) / (double)16);  
      tempi.add(tpi);   
     }
      qi.add(tempi);
    }
     /////////////////////////
    /////////////////////////
    double tpj=0; 
    for(int v=0; v < 8; v++)
    {   
     ArrayList<Double> tempj = new ArrayList<Double>();    
     for(int j = 0; j < 8; j++)
     {
      tpj = ( (2 * (double)j + 1) * (double)v * (22/ (double)7) / (double)16);   
      tempj.add(tpj);
     }
     qj.add(tempj);
    }
     /////////////////////////
    /////////////////////////
    }
 
   public void affiche_Mtrice(ArrayList<ArrayList<Double>> matrice) {
    for (int i=0; i< matrice.size(); i++) {
        for (int j=0; j< matrice.get(i).size(); j++) {
            System.out.print("\t" + matrice.get(i).get(j));
        }
        System.out.println();
    }
   }
  ///////////////////////////////////////////////  
   /* Accesseurs et mutateurs */
//////////////////////////////////////////////
    public ArrayList<ArrayList<Double>> getMat_val() {
        return mat_val;
    }
    public void setMat_val(ArrayList<ArrayList<Double>> set_mat_val) {
        this.mat_val = set_mat_val;
    }
////////////////////////////////////////////////
 
    public static void main(String[] args) throws FileNotFoundException {
/////////////////////////
    Formule qi_qj_calculer = new Formule();    
/////////////////////////        
    double tmp =0;
 /*   for(int u=0; u < qi.size(); u++)
     { 
        for(int i=0; i < qi.get(u).size(); i++)
        {   */
          int u=0, i=0; //Appelle de fonction avec c'est paramétre 
          for(int v=0; v < qj.size(); v++)
          {    
            ArrayList<Double> tempv = new ArrayList<Double>();  
            for(int j=0; j < qj.get(v).size(); j++)
            { 
              tmp = (Math.cos(qi.get(u).get(i)) * Math.cos(qj.get(v).get(j)));
              tempv.add(tmp);  
            }
            mat_val.add(tempv); //C'est la que en ajout une ligne dans mat_val
          }
          //C'est la que l'on doit crée notre fichier xml(u,v) de la matrice mat_val
          System.out.println("\n");
          qi_qj_calculer.affiche_Mtrice(mat_val);
   /*    }
        System.out.println("\n");
     } */
 
 
/////////////////////        
    XMLEncoder enc = new XMLEncoder(new FileOutputStream("fichier.xml"));
    enc.writeObject(qi_qj_calculer);
    enc.flush();
    enc.close();
 
   }
} | 
Partager