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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
import java.io.*;
public class Synchroniseur {
public static void affiche(String avance_sec, String deformation, String cheminFichier, String nomFichier) throws IOException
{
String ligne;
cheminFichier = cheminFichier.replace('\\','/');
try
{
double sec_sync = Double.parseDouble(avance_sec);
double a=-Double.parseDouble(deformation);
BufferedReader ficTexte;
ficTexte = new BufferedReader(new FileReader(new File(cheminFichier+'/'+nomFichier)));
File sortie = new File(cheminFichier+"/temp.srt");
PrintWriter out = new PrintWriter(new FileWriter(sortie));
if (ficTexte == null)
{
throw new FileNotFoundException("Fichier non trouvé: "+ nomFichier);
}
int k = 0;
String ancLigne_i="00000000000000000000000000000";
Plage anciNplage;
Plage nouvLplage = new Plage(ancLigne_i);
double nouvoSup_i = 0;
double nouvoInf_i = 0;
double ancienSup_i;
while ((ligne = ficTexte.readLine()) != null){
if (ligne != null)
{
boolean present = testCharTable.chainePresente(ligne,"-->");
if (present)
{
if (k==0) {ancienSup_i = sec_sync;}
else
{
ancienSup_i = nouvLplage.plageSup;
}
anciNplage = new Plage(ancLigne_i);
double ancienSup = anciNplage.plageSup;
ancLigne_i = ligne;
nouvLplage = new Plage(ligne);
double nouvoInf = nouvLplage.plageInf;
double nouvoSup = nouvLplage.plageSup;
nouvoInf_i = ancienSup_i + (1-a)*(nouvoInf-ancienSup);
nouvoSup_i = nouvoInf_i + (1-a)*(nouvoSup-nouvoInf);
nouvLplage.plageInf = nouvoInf_i;
nouvLplage.plageSup = nouvoSup_i;
nouvLplage.Converti();
Merge(nouvLplage,ligne);
Printer(nouvLplage, ligne, out);
k++;
}
else
{
String str_i = new String(ligne.toCharArray());
InterfaceAuto.listeMod.addElement(str_i);
InterfaceAuto.listeModS.addElement(str_i);
try{
out.println(ligne);
}
catch(Exception e){
e.printStackTrace();
}
}
}//fin if
}//fin while
}
catch (FileNotFoundException e) {
System.out.println(e.getMessage());
}
catch (IOException e) {
System.out.println(e.getMessage());
}
}
public static void Merge(Plage plage, String ligne) {
String str = "abcdefghijklmnopqrstuvwxyzéèà";
String str_i = ligne;
for(int i=0; i<29;i++)
{
if(i==2||i==5||i==8||i==12||i==13||i==14||i==15||i==16||i==19||i==22||i==25)
{
char tmp = str.charAt(i);
str = str.replace(tmp,ligne.charAt(i));
}
else
{
char c=' ';
if (plage.chiffre[i] >= 0 && plage.chiffre[i] <= 9)
{
c = Character.forDigit(plage.chiffre[i], 10);
}
char tmp = str.charAt(i);
str = str.replace(tmp,c);
}
}
InterfaceAuto.listeMod.addElement(str_i);
InterfaceAuto.listeModS.addElement(str);
}
public static void Printer(Plage plage, String ligne, PrintWriter out) {
try{
for(int i1=0; i1<29;i1++)
{
if(i1==2||i1==5||i1==8||i1==12||i1==13||i1==14||i1==15||i1==16||i1==19||i1==22||i1==25)
{
out.print(ligne.charAt(i1));
}
else out.print(plage.chiffre[i1]);
}
out.println();
}
catch(Exception e){
e.printStackTrace();
}
}
} |
Partager