From 969d3ba3a4224ab48fe87dc85248ae8a119b2e2c Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 23 Mar 2007 17:26:20 +0000 Subject: [PATCH] updates to console --- src/jalview/appletgui/AppletJmol.java | 82 ++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index b03775b..9ff3078 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -55,6 +55,7 @@ public class AppletJmol extends Frame String fileLoadingError; boolean loadedInline; PDBEntry pdbentry; + boolean colourBySequence = true; public AppletJmol(PDBEntry pdbentry, SequenceI[] seq, @@ -224,9 +225,7 @@ public class AppletJmol extends Frame && scriptWindow.isVisible()) { viewer.evalString(inputLine.getText()); - - history.append("\n"+inputLine.getText()); - + history.append("\n$ "+inputLine.getText()); inputLine.setText(""); } @@ -317,6 +316,10 @@ public class AppletJmol extends Frame FeatureRenderer fr; public void colourBySequence(AlignmentPanel ap) { + if(!colourBySequence) + return; + + StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile()); if (mapping.length < 1) @@ -338,6 +341,7 @@ public class AppletJmol extends Frame StringBuffer command = new StringBuffer(); + int lastPos = -1; for (int s = 0; s < sequence.length; s++) { for (int m = 0; m < mapping.length; m++) @@ -349,8 +353,25 @@ public class AppletJmol extends Frame int pos = mapping[m].getPDBResNum( sequence[s].findPosition(r)); - if (pos < 1) + if (pos < 1 || pos==lastPos) + continue; + + lastPos = pos; + + Color col = sr.getResidueBoxColour(sequence[s], r); + + if (showFeatures) + col = fr.findFeatureColour(col, sequence[s], r); + + if (command.toString().endsWith(":" + mapping[m].getChain()+ + ";color[" + + col.getRed() + "," + + col.getGreen() + "," + + col.getBlue() + "]")) + { + command = condenseCommand(command.toString(), pos); continue; + } command.append(";select " + pos); @@ -359,17 +380,13 @@ public class AppletJmol extends Frame command.append(":" + mapping[m].getChain()); } - Color col = sr.getResidueBoxColour(sequence[s], r); - - if (showFeatures) - col = fr.findFeatureColour(col, sequence[s], r); - - command.append("; color [" - + col.getRed() + "," - + col.getGreen() + "," - + col.getBlue() + "]"); + command.append(";color[" + + col.getRed() + "," + + col.getGreen() + "," + + col.getBlue() + "]"); } + break; } } } @@ -377,6 +394,29 @@ public class AppletJmol extends Frame viewer.evalStringQuiet(command.toString()); } + StringBuffer condenseCommand(String command, int pos) + { + + StringBuffer sb = new StringBuffer(command.substring(0, command.lastIndexOf("select")+7)); + + command = command.substring(sb.length()); + + String start; + + if (command.indexOf("-") > -1) + { + start = command.substring(0,command.indexOf("-")); + } + else + { + start = command.substring(0, command.indexOf(":")); + } + + sb.append(start+"-"+pos+command.substring(command.indexOf(":"))); + + return sb; + } + ///////////////////////////////// //JmolStatusListener @@ -388,9 +428,7 @@ public class AppletJmol extends Frame } public void createImage(String file, String type, int quality) - { - System.out.println("JMOL CREATE IMAGE"); - } + {} public void setCallbackFunction(String callbackType, String callbackFunction) @@ -425,7 +463,6 @@ public class AppletJmol extends Frame pdbentry.getFile(), AppletFormatAdapter.PASTE); pdbentry.setFile("INLINE"+pdb.id); - } else { @@ -487,14 +524,17 @@ public class AppletJmol extends Frame public void sendConsoleMessage(String strStatus) { - // if (scriptWindow != null) - // scriptWindow.sendConsoleMessage(strStatus); + if(history!=null && strStatus!=null + && !strStatus.equals("Script completed")) + { + history.append("\n"+strStatus); + } } public void notifyScriptTermination(String strStatus, int msWalltime) { - // if (scriptWindow != null) - // scriptWindow.notifyScriptTermination(strStatus, msWalltime); + // if (scriptWindow != null) + // scriptWindow.notifyScriptTermination(strStatus, msWalltime); } public void handlePopupMenu(int x, int y) -- 1.7.10.2