X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=42b032d361d930acc942e4f7e753fa07ef70e90c;hb=2d7deb9d3e1ddc98abae846c8ffbc62606b023be;hp=7299628f8ddcb6edf5d40162e432b703abd9b124;hpb=b1314f2aa829a8ccbb1816c6254c28f988967154;p=jalview.git diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 7299628..42b032d 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -258,7 +258,6 @@ public class FeaturesFile extends AlignFile catch (Exception ex) { System.out.println(line); - ex.printStackTrace(); System.out.println("Error parsing feature file: " + ex +"\n"+line); return false; } @@ -266,32 +265,59 @@ public class FeaturesFile extends AlignFile return true; } - void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) + public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) { + if(removeHTML && sf.getDescription().toUpperCase().indexOf("")==-1) + removeHTML = false; + StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(sf.getDescription(), "<"); String token, link; + int startTag; + String tag=null; while(st.hasMoreElements()) { - token = st.nextToken("<>"); + token = st.nextToken("&>"); if(token.equalsIgnoreCase("html") || token.startsWith("/")) + { continue; + } + + tag = null; + startTag = token.indexOf("<"); + + if (startTag > -1) + { + tag = token.substring(startTag+1); + token = token.substring(0, startTag); + } - if(token.startsWith("a href=")) + if (tag != null && tag.toUpperCase().startsWith("A HREF=")) { - link = token.substring(token.indexOf("\"")+1, token.length()-1); + if(token.length()>0) + sb.append(token); + link = tag.substring(tag.indexOf("\"") + 1, tag.length() - 1); String label = st.nextToken("<>"); - sf.addLink(label+"|"+link); - sb.append(label+"%LINK%"); + sf.addLink(label + "|" + link); + sb.append(label + "%LINK%"); } - else if(token.equalsIgnoreCase("br")) + else if (tag != null && tag.equalsIgnoreCase("br")) sb.append("\n"); + else if (token.startsWith("lt;")) + sb.append("<" + token.substring(3)); + else if (token.startsWith("gt;")) + sb.append(">" + token.substring(3)); + else if (token.startsWith("amp;")) + sb.append("&" + token.substring(4)); else + { sb.append(token); + } } if(removeHTML) sf.description = sb.toString(); + } /** @@ -383,7 +409,38 @@ public class FeaturesFile extends AlignFile if(next[j].description==null || next[j].description.equals("")) out.append(next[j].type+"\t"); else - out.append(next[j].description + "\t"); + { + if(next[j].links!=null + && next[j].getDescription().indexOf("")==-1) + out.append(""); + + out.append(next[j].description+" "); + if(next[j].links!=null) + { + for(int l=0; l" + + label + + ""); + } + } + + if (next[j].getDescription().indexOf("") == -1) + out.append(""); + } + + + out.append("\t"); + } + out.append( seqs[i].getName() + "\t-1\t" + next[j].begin + "\t"