54 lines
743 B
Java
54 lines
743 B
Java
import java.io.BufferedReader;
|
|
import java.io.FileReader;
|
|
import java.util.HashMap;
|
|
|
|
public class GestionCouleurs {
|
|
|
|
public Map<String, Color> NomEtCouleur(){
|
|
|
|
Map<String, Color> couleurs = new HashMap<>();
|
|
BufferedReader lecture = new BufferedReader(new FileReader("rgb.txt"));
|
|
|
|
String ligne;
|
|
while((ligne = lecture.readLine()) != null) {
|
|
|
|
ligne = ligne.trim();
|
|
String[] t = ligne.split("\\s+");
|
|
|
|
|
|
int r = Integer.parseInt(t[0]);
|
|
int g = Integer.parseInt(t[1]);
|
|
int b = Integer.parseInt(t[2]);
|
|
|
|
String nom = "";
|
|
|
|
for(int i=3; i<t.length(); i++){
|
|
|
|
nom+=t[i]+"";
|
|
|
|
|
|
|
|
}
|
|
nom = nom.trim();
|
|
|
|
couleurs.put(nom, new Color(r,g,b));
|
|
|
|
|
|
}
|
|
|
|
lecture.close();
|
|
return couleurs;
|
|
}
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |