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
|
import java.awt.Color;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ColorCode {
public java.util.Hashtable colors_code;
public ColorCode(){
double r = 0.99, v = 1., b = 1.;
int cpt=0;
colors_code = new java.util.Hashtable();
colors_code.put("", Color.WHITE);
File file = new File("/home/gldavid/Snippets/Bases/GeneOntology/GO.terms_and_ids");
try {
BufferedReader bf = new BufferedReader(new FileReader(file));
String current;
while((current=bf.readLine())!=null){
Pattern p = Pattern.compile("(GO:\\d+)\\t");
Matcher m = p.matcher(current);
if(m.find()){
cpt++;
System.out.println(""+cpt+" "+r+" "+v+" "+b);
Color color = new Color((float)r, (float)v, (float)b);
colors_code.put(m.group().trim(), color);
r-=0.01;
if(r<=0)
r=0;
if(r%2==0){
System.out.println("r pair");
v-=0.01;
}
if(v<=0)
v=0;
if(v%2==0){
System.out.println("v pair");
b-=0.01;
}
if(b<=0)
b=0;
}
}
}
catch(FileNotFoundException fnfe){
javax.swing.JOptionPane.showMessageDialog(null, fnfe, "Error", 0);
}
catch(IOException ioe){
javax.swing.JOptionPane.showMessageDialog(null, ioe, "Error", 0);
}
java.util.Enumeration keys = this.colors_code.keys();
while(keys.hasMoreElements()){
String key = (String)keys.nextElement();
Color c = (Color)this.colors_code.get(key);
//System.out.println(""+key+" r="+c.getRed()+" v="+c.getGreen()+" b="+c.getBlue());
}
}
} |
Partager