X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=c4c2c5bf13fe9d20e6a92efb6e9c2817405d031d;hb=e30c8f0736f711e2dc7c32680ac57a28c77d567d;hp=7a0052fcf945b4bebc0708315ffc15c5fdcf5fb6;hpb=f7d45a21db810c5f8f7ca668d1a28f1403defe32;p=jalview.git diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 7a0052f..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 @@ -329,14 +385,12 @@ public class AlignFrame extends Frame implements ActionListener, break; case KeyEvent.VK_DELETE: + case KeyEvent.VK_BACK_SPACE: if(viewport.cursorMode) { alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()); } - break; - - case KeyEvent.VK_BACK_SPACE: - if(!viewport.cursorMode) + else { cut_actionPerformed(); alignPanel.seqPanel.seqCanvas.repaint(); @@ -931,6 +985,11 @@ public void itemStateChanged(ItemEvent evt) public void deselectAllSequenceMenuItem_actionPerformed() { + if(viewport.cursorMode) + { + alignPanel.seqPanel.keyboardNo1=null; + alignPanel.seqPanel.keyboardNo2=null; + } viewport.setSelectionGroup(null); viewport.getColumnSelection().clear(); viewport.setSelectionGroup(null); @@ -1730,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); } }