public EnterElementSwingModule(IChemModelRelay chemModelRelay) {
super(chemModelRelay);
String filename = "org/openscience/jchempaint/resources/funcgroups.txt";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
SmilesParser sp=new SmilesParser(DefaultChemObjectBuilder.getInstance());
StringBuffer sb=new StringBuffer();
InputStreamReader isr = new InputStreamReader(ins);
try{
while(true){
int i=isr.read();
if(i==-1){
break;
}else if(((char)i)=='\n' || ((char)i)=='\r'){
if(!sb.toString().equals("")){
StringTokenizer st=new StringTokenizer(sb.toString());
String key=(String)st.nextElement();
String value=(String)st.nextElement();
IAtomContainer mol = sp.parseSmiles(value);
//for some reason, smilesparser sets valencies, which we don't want in jcp
for(int k=0;k<mol.getAtomCount();k++){
mol.getAtom(k).setValency(null);
}
funcgroupsmap.put(key, mol);
sb=new StringBuffer();
}
}else{
sb.append((char)i);
}
}
if(!sb.toString().equals("")){
StringTokenizer st=new StringTokenizer(sb.toString());
String key=(String)st.nextElement();
String value=(String)st.nextElement();
IAtomContainer mol = sp.parseSmiles(value);
//for some reason, smilesparser sets valencies, which we don't want in jcp
for(int k=0;k<mol.getAtomCount();k++){
mol.getAtom(k).setValency(null);
}
funcgroupsmap.put(key, mol);