wow le tp là
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LectureFichier {
|
||||
|
||||
@@ -7,13 +8,24 @@ public class LectureFichier {
|
||||
private String[] tabNomsCouleurs;
|
||||
|
||||
public LectureFichier() {
|
||||
|
||||
this.tabCouleurs = new Color[800];
|
||||
this.tabNomsCouleurs = new String[800];
|
||||
try {
|
||||
BufferedReader lecture = new BufferedReader(new FileReader("rgb.txt"));
|
||||
|
||||
try {
|
||||
String ligne = lecture.readLine();
|
||||
// TODO : Split, trim des lignes + Gestion Molette
|
||||
int compteur = 0;
|
||||
while (ligne != null) {
|
||||
int r = Integer.parseInt(ligne.substring(0, 3).replaceAll(" ", "0"));
|
||||
int g = Integer.parseInt(ligne.substring(4, 7).replaceAll(" ", "0"));
|
||||
int b = Integer.parseInt(ligne.substring(8, 11).replaceAll(" ", "0"));
|
||||
this.tabCouleurs[compteur] = new Color(r, g, b);
|
||||
ligne = ligne.substring(11, ligne.length()).replaceAll(" ", "");
|
||||
this.tabNomsCouleurs[compteur] = ligne;
|
||||
ligne = lecture.readLine();
|
||||
compteur++;
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur de lecture.");
|
||||
}
|
||||
@@ -27,4 +39,12 @@ public class LectureFichier {
|
||||
}
|
||||
}
|
||||
|
||||
public Color[] getCouleurs() {
|
||||
return this.tabCouleurs;
|
||||
}
|
||||
|
||||
public String[] getNomsCouleurs() {
|
||||
return this.tabNomsCouleurs;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user