X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=c4c2c5bf13fe9d20e6a92efb6e9c2817405d031d;hb=56e5bdc625697d50d7d3f422616f0f1b40ca2828;hp=1ecf25453756a18794214d8b7281749fd5ed6a13;hpb=b67b5e0fb0aa385f944431a402efcc05051a0127;p=jalview.git diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 1ecf254..c4c2c5b 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -172,18 +172,26 @@ public class AlignFrame extends Frame implements ActionListener, StringTokenizer st; SequenceFeature sf; FeatureRenderer fr = alignPanel.seqPanel.seqCanvas.getFeatureRenderer(); - int lineNo = 0; - String featureGroup = null; + String featureGroup = null, groupLink = null; + Hashtable typeLink = new Hashtable(); + while ( (line = in.readLine()) != null) { - lineNo++; st = new StringTokenizer(line, "\t"); - if (st.countTokens() == 2) + if(!st.hasMoreTokens()) + continue; + + if (st.countTokens() < 4) { type = st.nextToken(); if(type.equalsIgnoreCase("startgroup")) { featureGroup = st.nextToken(); + if (st.hasMoreElements()) + { + groupLink = st.nextToken(); + fr.addFeatureLink(featureGroup, groupLink); + } } else if(type.equalsIgnoreCase("endgroup")) { @@ -191,11 +199,19 @@ public class AlignFrame extends Frame implements ActionListener, //but at present theres no way of showing more than 1 group st.nextToken(); featureGroup = null; + groupLink = null; } else { UserColourScheme ucs = new UserColourScheme(st.nextToken()); fr.setColour(type, ucs.findColour("A")); + if (st.hasMoreElements()) + { + String link = st.nextToken(); + typeLink.put(type, link); + fr.addFeatureLink(type, link); + } + } continue; } @@ -203,6 +219,7 @@ public class AlignFrame extends Frame implements ActionListener, while (st.hasMoreElements()) { desc = st.nextToken(); + token = st.nextToken(); if (!token.equals("ID_NOT_SPECIFIED")) { @@ -229,9 +246,21 @@ public class AlignFrame extends Frame implements ActionListener, fr.setColour(type, ucs.findColour("A")); } - sf = new SequenceFeature(type, desc, "", start, end, featureGroup); - + sf = new SequenceFeature(type, desc, start, end, 0f, featureGroup); seq.addSequenceFeature(sf); + + if(groupLink!=null) + { + sf.addLink(groupLink); + sf.description += "%LINK%"; + } + if(typeLink.containsKey(type)) + { + sf.addLink(typeLink.get(type).toString()); + sf.description += "%LINK%"; + } + + parseDescriptionHTML(sf); } } @@ -248,6 +277,33 @@ public class AlignFrame extends Frame implements ActionListener, } } + void parseDescriptionHTML(SequenceFeature sf) + { + StringBuffer sb = new StringBuffer(); + StringTokenizer st = new StringTokenizer(sf.getDescription(), "<"); + String token, link; + while(st.hasMoreElements()) + { + token = st.nextToken("<>"); + if(token.equalsIgnoreCase("html") || token.startsWith("/")) + continue; + + if(token.startsWith("a href=")) + { + link = token.substring(token.indexOf("\"")+1, token.length()-1); + String label = st.nextToken("<>"); + sf.addLink(label+"|"+link); + sb.append(label+"%LINK%"); + } + else if(token.equalsIgnoreCase("br")) + sb.append("\n"); + else + sb.append(token); + } + + sf.description = sb.toString(); + } + public void keyPressed(KeyEvent evt) { if (viewport.cursorMode @@ -1733,7 +1789,7 @@ public void itemStateChanged(ItemEvent evt) g.drawString("If you use JalView, please cite:", x, y += fh + 8); g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"", x, y += fh); - g.drawString("Bioinformatics, 2004 12;426-7.", x, y += fh); + g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh); } }