From: gmungoc Date: Fri, 26 Jun 2015 11:06:51 +0000 (+0100) Subject: JAL-1759 updates for Jmol 14.2.14_25.06.11 X-Git-Tag: Release_2_10_0~562^2~16 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f59ae49cdd2bb8f6721424ea6ce167e8245e7d15;p=jalview.git JAL-1759 updates for Jmol 14.2.14_25.06.11 --- diff --git a/.classpath b/.classpath index 5319644..5a3d60d 100644 --- a/.classpath +++ b/.classpath @@ -36,8 +36,6 @@ - - @@ -66,5 +64,6 @@ + diff --git a/appletlib/JmolApplet-12.2.4.jar b/appletlib/JmolApplet-12.2.4.jar deleted file mode 100644 index e17c4ac..0000000 Binary files a/appletlib/JmolApplet-12.2.4.jar and /dev/null differ diff --git a/appletlib/JmolApplet-14.2.14_2015.06.11.jar b/appletlib/JmolApplet-14.2.14_2015.06.11.jar new file mode 100644 index 0000000..5d6338c Binary files /dev/null and b/appletlib/JmolApplet-14.2.14_2015.06.11.jar differ diff --git a/build.xml b/build.xml index c079df9..6227d06 100755 --- a/build.xml +++ b/build.xml @@ -109,7 +109,7 @@ - + diff --git a/lib/Jmol-12.2.4.jar b/lib/Jmol-12.2.4.jar deleted file mode 100644 index f1254cd..0000000 Binary files a/lib/Jmol-12.2.4.jar and /dev/null differ diff --git a/lib/Jmol-14.2.14_2015.06.11.jar b/lib/Jmol-14.2.14_2015.06.11.jar new file mode 100644 index 0000000..f77f5f0 Binary files /dev/null and b/lib/Jmol-14.2.14_2015.06.11.jar differ diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 1510a14..2b30cd5 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -20,40 +20,6 @@ */ package jalview.appletgui; -import java.awt.BorderLayout; -import java.awt.Canvas; -import java.awt.CheckboxMenuItem; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Label; -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuItem; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.IOException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Arrays; -import java.util.Deque; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; - import jalview.analysis.AlignmentSorter; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.api.AlignViewControllerGuiI; @@ -105,6 +71,42 @@ import jalview.util.MappingUtils; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.CheckboxMenuItem; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.net.URL; +import java.net.URLEncoder; +import java.util.Arrays; +import java.util.Deque; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.Vector; + +import org.jmol.viewer.Viewer; + public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemListener, KeyListener, AlignViewControllerGuiI { @@ -3872,10 +3874,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public SequenceStructureBinding addStructureViewInstance( Object jmolviewer, String[] sequenceIds) { - org.jmol.api.JmolViewer viewer = null; + // TODO method never called - remove? + Viewer viewer = null; try { - viewer = (org.jmol.api.JmolViewer) jmolviewer; + viewer = (Viewer) jmolviewer; } catch (ClassCastException ex) { System.err.println("Unsupported viewer object :" diff --git a/src/jalview/appletgui/AppletJmolBinding.java b/src/jalview/appletgui/AppletJmolBinding.java index 80fafe3..7844f57 100644 --- a/src/jalview/appletgui/AppletJmolBinding.java +++ b/src/jalview/appletgui/AppletJmolBinding.java @@ -23,16 +23,20 @@ package jalview.appletgui; import jalview.api.AlignmentViewPanel; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; +import jalview.ext.jmol.JalviewJmolBinding; import jalview.structure.StructureSelectionManager; import java.awt.Container; -import java.util.BitSet; +import java.util.Map; + +import javajs.awt.Dimension; import org.jmol.api.JmolAppConsoleInterface; -import org.jmol.api.JmolViewer; -import org.jmol.popup.JmolPopup; +import org.jmol.console.AppletConsole; +import org.jmol.java.BS; +import org.jmol.popup.JmolAwtPopup; -class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding +class AppletJmolBinding extends JalviewJmolBinding { /** @@ -48,6 +52,7 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding appletJmolBinding = appletJmol; } + @Override public jalview.api.FeatureRenderer getFeatureRenderer( AlignmentViewPanel alignment) { @@ -68,12 +73,14 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding return appletJmolBinding.fr; } + @Override public jalview.api.SequenceRenderer getSequenceRenderer( AlignmentViewPanel alignment) { return new SequenceRenderer(((AlignmentPanel) alignment).av); } + @Override public void sendConsoleEcho(String strEcho) { if (appletJmolBinding.scriptWindow == null) @@ -84,6 +91,7 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding appletJmolBinding.history.append("\n" + strEcho); } + @Override public void sendConsoleMessage(String strStatus) { if (appletJmolBinding.history != null && strStatus != null @@ -93,12 +101,14 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding } } + @Override public void showUrl(String url, String target) { appletJmolBinding.ap.alignFrame.showURL(url, target); } + @Override public void refreshGUI() { appletJmolBinding.updateTitleAndMenus(); @@ -124,17 +134,18 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding public void newJmolPopup(boolean translateLocale, String menuName, boolean asPopup) { + jmolpopup = new JmolAwtPopup(); // is this used? + jmolpopup.jpiInitialize((viewer), menuName); - jmolpopup = new JmolPopup(); - jmolpopup.initialize(viewer, translateLocale, menuName, asPopup); } + @Override public void notifyScriptTermination(String strStatus, int msWalltime) { // do nothing. } - public void selectionChanged(BitSet arg0) + public void selectionChanged(BS arg0) { // TODO Auto-generated method stub @@ -153,12 +164,11 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding } @Override - protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2, + protected JmolAppConsoleInterface createJmolConsole( Container consolePanel, String buttonsToShow) { - // return new org.jmol.console.AppletConsole(viewer2, consolePanel); - JmolAppConsoleInterface appc = new org.jmol.console.AppletConsole() - .getAppConsole(viewer2); + JmolAppConsoleInterface appc = new AppletConsole(); + appc.start(viewer); return appc; } @@ -175,9 +185,16 @@ class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding } @Override - public void resizeInnerPanel(String data) + public Dimension resizeInnerPanel(String data) { // TODO Auto-generated method stub + return null; + } + @Override + public Map getJSpecViewProperty(String arg0) + { + // TODO Auto-generated method stub + return null; } } diff --git a/src/jalview/appletgui/ExtJmol.java b/src/jalview/appletgui/ExtJmol.java index cec77d2..c1035bd 100644 --- a/src/jalview/appletgui/ExtJmol.java +++ b/src/jalview/appletgui/ExtJmol.java @@ -29,12 +29,13 @@ import jalview.ext.jmol.JalviewJmolBinding; import java.awt.Container; import java.util.ArrayList; -import java.util.BitSet; import java.util.List; +import java.util.Map; import java.util.Vector; import org.jmol.api.JmolAppConsoleInterface; -import org.jmol.api.JmolViewer; +import org.jmol.java.BS; +import org.jmol.viewer.Viewer; /** * bind an alignment view to an external Jmol instance. @@ -55,7 +56,7 @@ public class ExtJmol extends JalviewJmolBinding chains, protocol); } - public ExtJmol(JmolViewer viewer, AlignmentPanel alignPanel, + public ExtJmol(Viewer viewer, AlignmentPanel alignPanel, SequenceI[][] seqs) { super(alignPanel.getStructureSelectionManager(), seqs, viewer); @@ -75,6 +76,7 @@ public class ExtJmol extends JalviewJmolBinding showUrl(arg0, "jmol"); } + @Override public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment) { AlignmentPanel ap = (AlignmentPanel) alignment; @@ -88,41 +90,48 @@ public class ExtJmol extends JalviewJmolBinding } } + @Override public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment) { return ((AlignmentPanel) alignment).getSequenceRenderer(); } + @Override public void notifyScriptTermination(String strStatus, int msWalltime) { // ignore } + @Override public void sendConsoleEcho(String strEcho) { // ignore } + @Override public void sendConsoleMessage(String strStatus) { // ignore } + @Override public void showUrl(String url, String target) { ap.alignFrame.showURL(url, target); } + @Override public void refreshGUI() { // ignore } - public void selectionChanged(BitSet arg0) + public void selectionChanged(BS arg0) { System.out.println(arg0); } + @Override public void refreshPdbEntries() { List pdbe = new ArrayList(); @@ -130,12 +139,12 @@ public class ExtJmol extends JalviewJmolBinding SequenceI[] sq = ap.av.getAlignment().getSequencesArray(); for (int s = 0; s < sq.length; s++) { - Vector pdbids = sq[s].getPDBId(); + Vector pdbids = sq[s].getPDBId(); if (pdbids != null) { for (int pe = 0, peSize = pdbids.size(); pe < peSize; pe++) { - PDBEntry pentry = (PDBEntry) pdbids.elementAt(pe); + PDBEntry pentry = pdbids.elementAt(pe); if (!fileids.contains(pentry.getId())) { pdbe.add(pentry); @@ -166,7 +175,7 @@ public class ExtJmol extends JalviewJmolBinding } @Override - protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2, + protected JmolAppConsoleInterface createJmolConsole( Container consolePanel, String buttonsToShow) { // TODO Auto-generated method stub @@ -188,4 +197,11 @@ public class ExtJmol extends JalviewJmolBinding } + @Override + public Map getJSpecViewProperty(String arg0) + { + // TODO Auto-generated method stub + return null; + } + } diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index cdd137b..ab5b2da 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -20,6 +20,21 @@ */ package jalview.ext.jmol; +import jalview.api.AlignmentViewPanel; +import jalview.api.FeatureRenderer; +import jalview.api.SequenceRenderer; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; +import jalview.io.AppletFormatAdapter; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ResidueProperties; +import jalview.structure.AtomSpec; +import jalview.structure.StructureMappingcommandSet; +import jalview.structure.StructureSelectionManager; +import jalview.structures.models.AAStructureBindingModel; + import java.awt.Color; import java.awt.Container; import java.awt.event.ComponentEvent; @@ -32,28 +47,18 @@ import java.util.List; import java.util.Map; import java.util.Vector; +import javajs.awt.Dimension; + import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.api.JmolAppConsoleInterface; import org.jmol.api.JmolSelectionListener; import org.jmol.api.JmolStatusListener; import org.jmol.api.JmolViewer; -import org.jmol.constant.EnumCallback; -import org.jmol.popup.JmolPopup; - -import jalview.api.AlignmentViewPanel; -import jalview.api.FeatureRenderer; -import jalview.api.SequenceRenderer; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.io.AppletFormatAdapter; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.ResidueProperties; -import jalview.structure.AtomSpec; -import jalview.structure.StructureMappingcommandSet; -import jalview.structure.StructureSelectionManager; -import jalview.structures.models.AAStructureBindingModel; +import org.jmol.c.CBK; +import org.jmol.popup.JmolGenericPopup; +import org.jmol.script.T; +import org.jmol.viewer.JC; +import org.jmol.viewer.Viewer; public abstract class JalviewJmolBinding extends AAStructureBindingModel implements JmolStatusListener, JmolSelectionListener, @@ -88,7 +93,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel */ int frameNo = 0; - protected JmolPopup jmolpopup; + protected JmolGenericPopup jmolpopup; String lastCommand; @@ -103,7 +108,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel StringBuffer resetLastRes = new StringBuffer(); - public JmolViewer viewer; + public Viewer viewer; public JalviewJmolBinding(StructureSelectionManager ssm, PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains, @@ -120,7 +125,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } public JalviewJmolBinding(StructureSelectionManager ssm, - SequenceI[][] seqs, JmolViewer theViewer) + SequenceI[][] seqs, Viewer theViewer) { super(ssm, seqs); @@ -174,7 +179,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel public void closeViewer() { - viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE); + viewer.acm.setModeMouse(JC.MOUSE_NONE); // remove listeners for all structures in viewer getSsm().removeStructureViewerListener(this, this.getPdbFile()); // and shut down jmol @@ -586,7 +591,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel return null; } // TODO: verify atomIndex is selecting correct model. - return new Color(viewer.getAtomArgb(atomIndex)); + // return new Color(viewer.getAtomArgb(atomIndex)); Jmol 12.2.4 + int colour = viewer.ms.at[atomIndex] + .atomPropertyInt(T.color); + return new Color(colour); } /** @@ -642,26 +650,33 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } if (modelFileNames == null) { - - String mset[] = new String[viewer.getModelCount()]; + String mset[] = new String[viewer.ms.mc]; _modelFileNameMap = new int[mset.length]; - int j = 1; - String m = viewer.getModelFileName(0); + String m = viewer.ms.getModelFileName(0); if (m != null) { + mset[0] = m; try { mset[0] = new File(m).getAbsolutePath(); } catch (AccessControlException x) { - // usually not allowed to do this in applet, so keep raw handle + // usually not allowed to do this in applet + System.err + .println("jmolBinding: Using local file string from Jmol: " + + m); + } + if (mset[0].indexOf("/file:") != -1) + { + // applet path with docroot - discard as format won't match pdbfile mset[0] = m; - // System.err.println("jmolBinding: Using local file string from Jmol: "+m); } } + int j = 1; for (int i = 1; i < mset.length; i++) { - m = viewer.getModelFileName(i); + m = viewer.ms.getModelFileName(i); + mset[j] = m; if (m != null) { try @@ -670,7 +685,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } catch (AccessControlException x) { // usually not allowed to do this in applet, so keep raw handle - mset[j] = m; // System.err.println("jmolBinding: Using local file string from Jmol: "+m); } } @@ -714,7 +728,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel public void handlePopupMenu(int x, int y) { - jmolpopup.show(x, y); + // jmolpopup.show(x, y); + jmolpopup.jpiShow(x, y); } /** @@ -877,7 +892,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel pdbfilename = modelFileNames[_mp]; if (pdbfilename == null) { - pdbfilename = new File(viewer.getModelFileName(mnumber)) + pdbfilename = new File( + viewer.ms.getModelFileName(mnumber)) .getAbsolutePath(); } @@ -965,7 +981,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } @Override - public void notifyCallback(EnumCallback type, Object[] data) + public void notifyCallback(CBK type, Object[] data) { try { @@ -1019,7 +1035,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } @Override - public boolean notifyEnabled(EnumCallback callbackPick) + public boolean notifyEnabled(CBK callbackPick) { switch (callbackPick) { @@ -1032,13 +1048,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel case HOVER: case ERROR: return true; - case RESIZE: - case SYNC: - case CLICK: - case ANIMFRAME: - case MINIMIZATION: + default: + return false; } - return false; } // incremented every time a load notification is successfully handled - @@ -1144,9 +1156,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } else { - File fl; - if (matches = (fl = new File(getPdbEntry(pe).getFile())) - .equals(new File(fileName))) + File fl = new File(getPdbEntry(pe).getFile()); + matches = fl.equals(new File(fileName)); + if (matches) { foundEntry = true; // TODO: Jmol can in principle retrieve from CLASSLOADER but @@ -1360,12 +1372,14 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { commandOptions = ""; } - viewer = JmolViewer.allocateViewer(renderPanel, + viewer = (Viewer) JmolViewer.allocateViewer(renderPanel, (jmolfileio ? new SmarterJmolAdapter() : null), htmlName + ((Object) this).toString(), documentBase, codeBase, commandOptions, this); - console = createJmolConsole(viewer, consolePanel, buttonsToShow); + viewer.setJmolStatusListener(this); // extends JmolCallbackListener + + console = createJmolConsole(consolePanel, buttonsToShow); if (consolePanel != null) { consolePanel.addComponentListener(this); @@ -1375,7 +1389,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } protected abstract JmolAppConsoleInterface createJmolConsole( - JmolViewer viewer2, Container consolePanel, String buttonsToShow); + Container consolePanel, String buttonsToShow); protected org.jmol.api.JmolAppConsoleInterface console = null; @@ -1388,10 +1402,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } @Override - public void resizeInnerPanel(String data) + public Dimension resizeInnerPanel(String data) { // Jalview doesn't honour resize panel requests - + return null; } public boolean isFinishedInit() @@ -1458,3 +1472,4 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel showConsole(false); } } + diff --git a/src/jalview/ext/jmol/PDBFileWithJmol.java b/src/jalview/ext/jmol/PDBFileWithJmol.java index 3df8957..2f117d3 100644 --- a/src/jalview/ext/jmol/PDBFileWithJmol.java +++ b/src/jalview/ext/jmol/PDBFileWithJmol.java @@ -34,13 +34,15 @@ import java.io.IOException; import java.util.Hashtable; import java.util.Map; +import javajs.awt.Dimension; + import org.jmol.api.JmolStatusListener; import org.jmol.api.JmolViewer; -import org.jmol.constant.EnumCallback; +import org.jmol.c.CBK; import org.jmol.modelset.Group; import org.jmol.modelset.Model; import org.jmol.modelset.ModelSet; -import org.jmol.modelset.Polymer; +import org.jmol.modelsetbio.BioModel; import org.jmol.modelsetbio.BioPolymer; import org.jmol.viewer.Viewer; import org.openscience.jmol.app.JmolApp; @@ -82,19 +84,18 @@ public class PDBFileWithJmol extends AlignFile implements private Viewer getJmolData() { if (viewer == null) - { // note that -o -n -x are all implied + { // note that -o -n -x are all implied // TODO check for Jmol 14.2 jmolApp = new JmolApp(); jmolApp.isDataOnly = true; jmolApp.haveConsole = false; jmolApp.haveDisplay = false; - jmolApp.exitUponCompletion = true; try { viewer = (Viewer) JmolViewer.allocateViewer(null, null, null, null, - null, jmolApp.commandOptions, this); + null, "-x -o -n", this); viewer.setScreenDimension(jmolApp.startupWidth, jmolApp.startupHeight); - jmolApp.startViewer(viewer, null); + jmolApp.startViewer(viewer, null, false); } catch (ClassCastException x) { throw new Error(MessageManager.formatMessage("error.jmol_version_not_compatible_with_jalview_version", new String[]{JmolViewer.getJmolVersion()}), @@ -129,136 +130,144 @@ public class PDBFileWithJmol extends AlignFile implements Viewer jmd = getJmolData(); jmd.openReader(getDataName(), getDataName(), getReader()); waitForScript(jmd); - if (jmd.getModelCount() > 0) + + if (jmd.ms.mc > 0) { - ModelSet ms = jmd.getModelSet(); - String structs = ms.calculateStructures(null, true, false, true); + ModelSet ms = jmd.ms; + // Jmol 14.2 added third argument doReport = false + ms.calculateStructures(null, true, false, false, true); // System.out.println("Structs\n"+structs); - for (Model model : ms.getModels()) + Group group = null; + int modelIndex = -1; + for (Model model : ms.am) { - for (int _bp = 0, _bpc = model.getBioPolymerCount(); _bp < _bpc; _bp++) + modelIndex++; + for (BioPolymer bp : ((BioModel) model).bioPolymers) { - Polymer bp = model.getBioPolymer(_bp); - if (bp instanceof BioPolymer) + int _lastChainId = 0; + int[] groups = bp.getLeadAtomIndices(); + char seq[] = new char[groups.length], secstr[] = new char[groups.length], secstrcode[] = new char[groups.length]; + int groupc = 0, len = 0, firstrnum = 1, lastrnum = 0; + + do { - BioPolymer biopoly = (BioPolymer) bp; - char _lastChainId = 0; - int[] groups = biopoly.getLeadAtomIndices(); - Group[] bpgrp = biopoly.getGroups(); - char seq[] = new char[groups.length], secstr[] = new char[groups.length], secstrcode[] = new char[groups.length]; - int groupc = 0, len = 0, firstrnum = 1, lastrnum = 0; - do + if (groupc >= groups.length + || ms.at[groups[groupc]].group.chain.chainID != _lastChainId) { - if (groupc >= groups.length - || ms.atoms[groups[groupc]].getChainID() != _lastChainId) + /* + * on change of chain (or at end), construct the sequence and + * secondary structure annotation for the last chain + */ + if (len > 0) { - if (len > 0) + boolean isNa = bp.isNucleic(); + // normalise sequence from Jmol to jalview + int[] cinds = isNa ? ResidueProperties.nucleotideIndex + : ResidueProperties.aaIndex; + int nonGap = isNa ? ResidueProperties.maxNucleotideIndex + : ResidueProperties.maxProteinIndex; + char ngc = 'X'; + char newseq[] = new char[len]; + Annotation asecstr[] = new Annotation[len + firstrnum - 1]; + for (int p = 0; p < len; p++) { - boolean isNa = (biopoly.isDna() || biopoly.isRna()); - // normalise sequence from Jmol to jalview - int[] cinds = isNa ? ResidueProperties.nucleotideIndex : ResidueProperties.aaIndex; - int nonGap = isNa ? ResidueProperties.maxNucleotideIndex - : ResidueProperties.maxProteinIndex; - char ngc = 'X'; - char newseq[] = new char[len]; - Annotation asecstr[] = new Annotation[len+firstrnum-1]; - for (int p = 0; p < len; p++) + newseq[p] = cinds[seq[p]] == nonGap ? ngc : seq[p]; + if (secstr[p] >= 'A' && secstr[p] <= 'z') { - newseq[p] = cinds[seq[p]] == nonGap ? ngc : seq[p]; - if (secstr[p] >= 'A' && secstr[p] <= 'z') - { - asecstr[p] = new Annotation("" + secstr[p], null, - secstrcode[p], Float.NaN); - } + asecstr[p] = new Annotation("" + secstr[p], null, + secstrcode[p], Float.NaN); } - SequenceI sq = new Sequence("" + getDataName() + "|" - + model.getModelTitle() + "|" + _lastChainId, - newseq, firstrnum, lastrnum); - PDBEntry pdbe = new PDBEntry(); - pdbe.setFile(getDataName()); - pdbe.setId(getDataName()); - pdbe.setProperty(new Hashtable()); - // pdbe.getProperty().put("CHAIN", "" + _lastChainId); - pdbe.setChainCode(String.valueOf(_lastChainId)); - sq.addPDBId(pdbe); - // JAL-1533 - // Need to put the number of models for this polymer somewhere for Chimera/others to grab - // pdbe.getProperty().put("PDBMODELS", biopoly.) - seqs.add(sq); - if (!isNa) + } + String modelTitle = (String) ms + .getInfo(modelIndex, "title"); + SequenceI sq = new Sequence("" + getDataName() + "|" + + modelTitle + "|" + _lastChainId, newseq, + firstrnum, lastrnum); + PDBEntry pdbe = new PDBEntry(); + pdbe.setFile(getDataName()); + pdbe.setId(getDataName()); + pdbe.setProperty(new Hashtable()); + // pdbe.getProperty().put("CHAIN", "" + _lastChainId); + pdbe.setChainCode(String.valueOf(_lastChainId)); + sq.addPDBId(pdbe); + // JAL-1533 + // Need to put the number of models for this polymer somewhere + // for Chimera/others to grab + // pdbe.getProperty().put("PDBMODELS", biopoly.) + seqs.add(sq); + if (!isNa) + { + String mt = modelTitle == null ? getDataName() + : modelTitle; + if (_lastChainId >= ' ') { - String mt = model.getModelTitle() == null ? getDataName() - : model.getModelTitle(); - if (_lastChainId >= ' ') - { - mt += _lastChainId; - } - AlignmentAnnotation ann = new AlignmentAnnotation( - "Secondary Structure", - "Secondary Structure for " + mt, asecstr); - ann.belowAlignment=true; - ann.visible=true; - ann.autoCalculated=false; - ann.setCalcId(getClass().getName()); - sq.addAlignmentAnnotation(ann); - ann.adjustForAlignment(); - ann.validateRangeAndDisplay(); - annotations.add(ann); + mt += _lastChainId; } + AlignmentAnnotation ann = new AlignmentAnnotation( + "Secondary Structure", "Secondary Structure for " + + mt, asecstr); + ann.belowAlignment = true; + ann.visible = true; + ann.autoCalculated = false; + ann.setCalcId(getClass().getName()); + sq.addAlignmentAnnotation(ann); + ann.adjustForAlignment(); + ann.validateRangeAndDisplay(); + annotations.add(ann); } - len = 0; - firstrnum = 1; - lastrnum = 0; } - if (groupc < groups.length) + len = 0; + firstrnum = 1; + lastrnum = 0; + } + if (groupc < groups.length) + { + group = ms.at[groups[groupc]].group; + if (len == 0) + { + firstrnum = group.getResno(); + _lastChainId = group.chain.chainID; + } + else + { + lastrnum = group.getResno(); + } + seq[len] = group.getGroup1(); + switch (group.getProteinStructureSubType()) { - if (len == 0) + case HELIX310: + if (secstr[len] == 0) { - firstrnum = bpgrp[groupc].getResno(); - _lastChainId = bpgrp[groupc].getChainID(); + secstr[len] = '3'; } - else + case HELIXALPHA: + if (secstr[len] == 0) { - lastrnum = bpgrp[groupc].getResno(); + secstr[len] = 'H'; } - seq[len] = bpgrp[groupc].getGroup1(); - switch (bpgrp[groupc].getProteinStructureSubType()) + case HELIXPI: + if (secstr[len] == 0) { - case HELIX_310: - if (secstr[len] == 0) - { - secstr[len] = '3'; - } - case HELIX_ALPHA: - if (secstr[len] == 0) - { - secstr[len] = 'H'; - } - case HELIX_PI: - if (secstr[len] == 0) - { - secstr[len] = 'P'; - } - case HELIX: - if (secstr[len] == 0) - { - secstr[len] = 'H'; - } - secstrcode[len] = 'H'; - break; - case SHEET: - secstr[len] = 'E'; - secstrcode[len] = 'E'; - break; - default: - secstr[len] = 0; - secstrcode[len] = 0; + secstr[len] = 'P'; } - len++; + case HELIX: + if (secstr[len] == 0) + { + secstr[len] = 'H'; + } + secstrcode[len] = 'H'; + break; + case SHEET: + secstr[len] = 'E'; + secstrcode[len] = 'E'; + break; + default: + secstr[len] = 0; + secstrcode[len] = 0; } - } while (groupc++ < groups.length); - - } + len++; + } + } while (groupc++ < groups.length); } } @@ -305,7 +314,7 @@ public class PDBFileWithJmol extends AlignFile implements * System.err.println("Squashed Jmol callback handler error:"); * e.printStackTrace(); } } */ - public void notifyCallback(EnumCallback type, Object[] data) + public void notifyCallback(CBK type, Object[] data) { String strInfo = (data == null || data[1] == null ? null : data[1] .toString()); @@ -343,13 +352,6 @@ public class PDBFileWithJmol extends AlignFile implements } } - private void notifyFileLoaded(String string, String string2, - String string3, String string4, int intValue) - { - // TODO Auto-generated method stub - - } - String lastConsoleEcho = ""; private void sendConsoleEcho(String string) @@ -378,7 +380,7 @@ public class PDBFileWithJmol extends AlignFile implements } @Override - public boolean notifyEnabled(EnumCallback callbackPick) + public boolean notifyEnabled(CBK callbackPick) { switch (callbackPick) { @@ -388,16 +390,9 @@ public class PDBFileWithJmol extends AlignFile implements case LOADSTRUCT: case ERROR: return true; - case MEASURE: - case PICK: - case HOVER: - case RESIZE: - case SYNC: - case CLICK: - case ANIMFRAME: - case MINIMIZATION: + default: + return false; } - return false; } @Override @@ -444,10 +439,15 @@ public class PDBFileWithJmol extends AlignFile implements } @Override - public void resizeInnerPanel(String data) + public Dimension resizeInnerPanel(String data) { - // TODO Auto-generated method stub + return null; + } + @Override + public Map getJSpecViewProperty(String arg0) + { + return null; } } diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 6139669..4e6ab83 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -20,6 +20,29 @@ */ package jalview.gui; +import jalview.bin.Cache; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; +import jalview.gui.StructureViewer.ViewerType; +import jalview.io.AppletFormatAdapter; +import jalview.io.JalviewFileChooser; +import jalview.io.JalviewFileView; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.PurinePyrimidineColourScheme; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.ZappoColourScheme; +import jalview.structures.models.AAStructureBindingModel; +import jalview.util.MessageManager; +import jalview.util.Platform; + import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -51,29 +74,6 @@ import javax.swing.event.InternalFrameEvent; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; -import jalview.bin.Cache; -import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.gui.StructureViewer.ViewerType; -import jalview.io.AppletFormatAdapter; -import jalview.io.JalviewFileChooser; -import jalview.io.JalviewFileView; -import jalview.schemes.BuriedColourScheme; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.HelixColourScheme; -import jalview.schemes.HydrophobicColourScheme; -import jalview.schemes.PurinePyrimidineColourScheme; -import jalview.schemes.StrandColourScheme; -import jalview.schemes.TaylorColourScheme; -import jalview.schemes.TurnColourScheme; -import jalview.schemes.ZappoColourScheme; -import jalview.structures.models.AAStructureBindingModel; -import jalview.util.MessageManager; -import jalview.util.Platform; - public class AppJmol extends StructureViewerBase { AppJmolBinding jmb; @@ -185,6 +185,7 @@ public class AppJmol extends StructureViewerBase this.addInternalFrameListener(new InternalFrameAdapter() { + @Override public void internalFrameClosing(InternalFrameEvent internalFrameEvent) { closeViewer(false); @@ -407,6 +408,7 @@ public class AppJmol extends StructureViewerBase } this.addInternalFrameListener(new InternalFrameAdapter() { + @Override public void internalFrameClosing(InternalFrameEvent internalFrameEvent) { closeViewer(false); @@ -527,7 +529,7 @@ public class AppJmol extends StructureViewerBase ; jmb.allocateViewer(renderPanel, true, "", null, null, "", scriptWindow, null); - jmb.newJmolPopup(true, "Jmol", true); + jmb.newJmolPopup("Jmol"); if (command == null) { command = ""; @@ -1079,6 +1081,7 @@ public class AppJmol extends StructureViewerBase final Rectangle rectClip = new Rectangle(); + @Override public void paintComponent(Graphics g) { getSize(currentSize); diff --git a/src/jalview/gui/AppJmolBinding.java b/src/jalview/gui/AppJmolBinding.java index 3a376b8..1283019 100644 --- a/src/jalview/gui/AppJmolBinding.java +++ b/src/jalview/gui/AppJmolBinding.java @@ -28,12 +28,12 @@ import jalview.ext.jmol.JalviewJmolBinding; import jalview.structure.StructureSelectionManager; import java.awt.Container; -import java.util.BitSet; +import java.util.Map; import org.jmol.api.JmolAppConsoleInterface; -import org.jmol.api.JmolViewer; -import org.jmol.popup.JmolPopup; -import org.openscience.jmol.app.jmolpanel.AppConsole; +import org.jmol.java.BS; +import org.jmol.popup.JmolAwtPopup; +import org.openscience.jmol.app.jmolpanel.console.AppConsole; public class AppJmolBinding extends JalviewJmolBinding { @@ -77,6 +77,7 @@ public class AppJmolBinding extends JalviewJmolBinding return new SequenceRenderer(((AlignmentPanel) alignment).av); } + @Override public void sendConsoleEcho(String strEcho) { if (console != null) @@ -85,6 +86,7 @@ public class AppJmolBinding extends JalviewJmolBinding } } + @Override public void sendConsoleMessage(String strStatus) { if (console != null && strStatus != null) @@ -136,6 +138,7 @@ public class AppJmolBinding extends JalviewJmolBinding } } + @Override public void notifyScriptTermination(String strStatus, int msWalltime) { // todo - script termination doesn't happen ? @@ -149,34 +152,37 @@ public class AppJmolBinding extends JalviewJmolBinding showUrl(url, "jmol"); } - public void newJmolPopup(boolean translateLocale, String menuName, - boolean asPopup) + public void newJmolPopup(String menuName) { - jmolpopup = new JmolPopup(); - jmolpopup.initialize(viewer, translateLocale, menuName, asPopup); + jmolpopup = new JmolAwtPopup(); + jmolpopup.jpiInitialize((viewer), menuName); } - public void selectionChanged(BitSet arg0) + @Override + public void selectionChanged(BS arg0) { // TODO Auto-generated method stub } + @Override public void refreshPdbEntries() { // TODO Auto-generated method stub } + @Override public void showConsole(boolean b) { appJmolWindow.showConsole(b); } @Override - protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2, + protected JmolAppConsoleInterface createJmolConsole( Container consolePanel, String buttonsToShow) { + viewer.setJmolCallbackListener(this); return new AppConsole(viewer, consolePanel, buttonsToShow); } @@ -195,4 +201,11 @@ public class AppJmolBinding extends JalviewJmolBinding appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap); } } + + @Override + public Map getJSpecViewProperty(String arg0) + { + // TODO Auto-generated method stub + return null; + } } diff --git a/src/jalview/gui/ScriptWindow.java b/src/jalview/gui/ScriptWindow.java deleted file mode 100644 index 972e5ef..0000000 --- a/src/jalview/gui/ScriptWindow.java +++ /dev/null @@ -1,739 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.gui; - -import org.jmol.api.*; - -import jalview.jbgui.GStructureViewer; - -import java.awt.*; -import java.awt.event.*; - -import javax.swing.*; -import javax.swing.text.*; - -import java.util.Vector; - -import org.jmol.i18n.GT; -import org.jmol.util.Logger; -import org.jmol.util.CommandHistory; - -// TODO: this class is copied in from jmol 11.0.2 - upgrade to 12.0.2 ? -public final class ScriptWindow extends JPanel implements ActionListener, - EnterListener -{ - - private ConsoleTextPane console; - - private JButton closeButton; - - private JButton runButton; - - private JButton haltButton; - - private JButton clearButton; - - private JButton historyButton; - - private JButton stateButton; - - JmolViewer viewer; - - GStructureViewer appJmol; - - public ScriptWindow(AppJmol appJmol) - { - this.viewer = appJmol.jmb.viewer; - this.appJmol = appJmol; - - setLayout(new BorderLayout()); - - console = new ConsoleTextPane(this); - - console.setPrompt(); - add(new JScrollPane(console), BorderLayout.CENTER); - - JPanel buttonPanel = new JPanel(); - add(buttonPanel, BorderLayout.SOUTH); - - runButton = new JButton(GT._("Run")); - haltButton = new JButton(GT._("Halt")); - runButton.addActionListener(this); - // buttonPanel.add(runButton); - haltButton.addActionListener(this); - // buttonPanel.add(haltButton); - haltButton.setEnabled(false); - - clearButton = new JButton(GT._("Clear")); - clearButton.addActionListener(this); - buttonPanel.add(clearButton); - - historyButton = new JButton(GT._("History")); - historyButton.addActionListener(this); - buttonPanel.add(historyButton); - - stateButton = new JButton(GT._("State")); - stateButton.addActionListener(this); - buttonPanel.add(stateButton); - - closeButton = new JButton(GT._("Close")); - closeButton.addActionListener(this); - buttonPanel.add(closeButton); - - for (int i = 0; i < buttonPanel.getComponentCount(); i++) - { - // ((JButton)buttonPanel.getComponent(i)) - // .setMargin(new Insets(0, 0, 0, 0)); - } - - } - - public void sendConsoleEcho(String strEcho) - { - if (strEcho != null && !isError) - { - - console.outputEcho(strEcho); - - } - setError(false); - } - - boolean isError = false; - - void setError(boolean TF) - { - isError = TF; - // if (isError) - // console.recallCommand(true); - } - - public void sendConsoleMessage(String strStatus) - { - if (strStatus == null) - { - console.clearContent(); - console.outputStatus(""); - } - else if (strStatus.indexOf("ERROR:") >= 0) - { - console.outputError(strStatus); - isError = true; - } - else if (!isError) - { - console.outputStatus(strStatus); - } - } - - public void notifyScriptTermination(String strMsg, int msWalltime) - { - if (strMsg != null && strMsg.indexOf("ERROR") >= 0) - { - console.outputError(strMsg); - } - runButton.setEnabled(true); - haltButton.setEnabled(false); - } - - public void enterPressed() - { - runButton.doClick(100); - // executeCommand(); - } - - class ExecuteCommandThread extends Thread - { - - String strCommand; - - ExecuteCommandThread(String command) - { - strCommand = command; - } - - public void run() - { - try - { - executeCommand(strCommand); - } catch (Exception ie) - { - Logger.debug("execution command interrupted!" + ie); - } - } - } - - ExecuteCommandThread execThread; - - void executeCommandAsThread() - { - String strCommand = console.getCommandString().trim(); - if (strCommand.length() > 0) - { - execThread = new ExecuteCommandThread(strCommand); - execThread.start(); - } - } - - void executeCommand(String strCommand) - { - boolean doWait; - setError(false); - console.appendNewline(); - console.setPrompt(); - if (strCommand.length() > 0) - { - String strErrorMessage = null; - doWait = (strCommand.indexOf("WAIT ") == 0); - if (doWait) - { // for testing, mainly - // demonstrates using the statusManager system. - runButton.setEnabled(false); - haltButton.setEnabled(true); - - Vector info = (Vector) viewer - .scriptWaitStatus(strCommand.substring(5), - "+fileLoaded,+scriptStarted,+scriptStatus,+scriptEcho,+scriptTerminated"); - runButton.setEnabled(true); - haltButton.setEnabled(false); - /* - * info = [ statusRecortSet0, statusRecortSet1, statusRecortSet2, ...] - * statusRecordSet = [ statusRecord0, statusRecord1, statusRecord2, ...] - * statusRecord = [int msgPtr, String statusName, int intInfo, String - * msg] - */ - for (int i = 0; i < info.size(); i++) - { - Vector statusRecordSet = (Vector) info.get(i); - for (int j = 0; j < statusRecordSet.size(); j++) - { - Vector statusRecord = (Vector) statusRecordSet.get(j); - Logger.info("msg#=" + statusRecord.get(0) + " " - + statusRecord.get(1) + " intInfo=" - + statusRecord.get(2) + " stringInfo=" - + statusRecord.get(3)); - } - } - console.appendNewline(); - } - else - { - boolean isScriptExecuting = viewer.isScriptExecuting(); - if (viewer.checkHalt(strCommand, true)) - strErrorMessage = (isScriptExecuting ? "string execution halted with " - + strCommand - : "no script was executing"); - else - strErrorMessage = "";// viewer.scriptCheck(strCommand); - // the problem is that scriptCheck is synchronized, so these might get - // backed up. - if (strErrorMessage != null && strErrorMessage.length() > 0) - { - console.outputError(strErrorMessage); - } - else - { - // runButton.setEnabled(false); - haltButton.setEnabled(true); - viewer.script(strCommand); - } - } - } - console.grabFocus(); - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if (source == closeButton) - { - // appJmol.showConsole(false); - } - else if (source == runButton) - { - executeCommandAsThread(); - } - else if (source == clearButton) - { - console.clearContent(); - } - else if (source == historyButton) - { - console.clearContent(viewer.getSetHistory(Integer.MAX_VALUE)); - } - else if (source == stateButton) - { - console.clearContent(viewer.getStateInfo()); - } - else if (source == haltButton) - { - viewer.haltScriptExecution(); - } - console.grabFocus(); // always grab the focus (e.g., after clear) - } -} - -class ConsoleTextPane extends JTextPane -{ - - ConsoleDocument consoleDoc; - - EnterListener enterListener; - - JmolViewer viewer; - - ConsoleTextPane(ScriptWindow scriptWindow) - { - super(new ConsoleDocument()); - consoleDoc = (ConsoleDocument) getDocument(); - consoleDoc.setConsoleTextPane(this); - this.enterListener = (EnterListener) scriptWindow; - this.viewer = scriptWindow.viewer; - } - - public String getCommandString() - { - String cmd = consoleDoc.getCommandString(); - return cmd; - } - - public void setPrompt() - { - consoleDoc.setPrompt(); - } - - public void appendNewline() - { - consoleDoc.appendNewline(); - } - - public void outputError(String strError) - { - consoleDoc.outputError(strError); - } - - public void outputErrorForeground(String strError) - { - consoleDoc.outputErrorForeground(strError); - } - - public void outputEcho(String strEcho) - { - consoleDoc.outputEcho(strEcho); - } - - public void outputStatus(String strStatus) - { - consoleDoc.outputStatus(strStatus); - } - - public void enterPressed() - { - if (enterListener != null) - enterListener.enterPressed(); - } - - public void clearContent() - { - clearContent(null); - } - - public void clearContent(String text) - { - consoleDoc.clearContent(); - if (text != null) - consoleDoc.outputEcho(text); - setPrompt(); - } - - /* - * (non-Javadoc) - * - * @see java.awt.Component#processKeyEvent(java.awt.event.KeyEvent) - */ - - /** - * Custom key event processing for command 0 implementation. - * - * Captures key up and key down strokes to call command history and redefines - * the same events with control down to allow caret vertical shift. - * - * @see java.awt.Component#processKeyEvent(java.awt.event.KeyEvent) - */ - protected void processKeyEvent(KeyEvent ke) - { - // Id Control key is down, captures events does command - // history recall and inhibits caret vertical shift. - if (ke.getKeyCode() == KeyEvent.VK_UP - && ke.getID() == KeyEvent.KEY_PRESSED && !ke.isControlDown()) - { - recallCommand(true); - } - else if (ke.getKeyCode() == KeyEvent.VK_DOWN - && ke.getID() == KeyEvent.KEY_PRESSED && !ke.isControlDown()) - { - recallCommand(false); - } - // If Control key is down, redefines the event as if it - // where a key up or key down stroke without modifiers. - // This allows to move the caret up and down - // with no command history recall. - else if ((ke.getKeyCode() == KeyEvent.VK_DOWN || ke.getKeyCode() == KeyEvent.VK_UP) - && ke.getID() == KeyEvent.KEY_PRESSED && ke.isControlDown()) - { - super.processKeyEvent(new KeyEvent((Component) ke.getSource(), ke - .getID(), ke.getWhen(), 0, // No modifiers - ke.getKeyCode(), ke.getKeyChar(), ke.getKeyLocation())); - } - // Standard processing for other events. - else - { - super.processKeyEvent(ke); - // check command for compiler-identifyable syntax issues - // this may have to be taken out if people start complaining - // that only some of the commands are being checked - // that is -- that the script itself is not being fully checked - - // not perfect -- help here? - if (ke.getID() == KeyEvent.KEY_RELEASED - && (ke.getKeyCode() > KeyEvent.VK_DOWN) - || ke.getKeyCode() == KeyEvent.VK_BACK_SPACE) - checkCommand(); - } - } - - /** - * Recall command history. - * - * @param up - * - history up or down - */ - void recallCommand(boolean up) - { - String cmd = viewer.getSetHistory(up ? -1 : 1); - if (cmd == null) - { - return; - } - try - { - if (cmd.endsWith(CommandHistory.ERROR_FLAG)) - { - cmd = cmd.substring(0, cmd.indexOf(CommandHistory.ERROR_FLAG)); - consoleDoc.replaceCommand(cmd, true); - } - else - { - consoleDoc.replaceCommand(cmd, false); - } - } catch (BadLocationException e) - { - e.printStackTrace(); - } - } - - void checkCommand() - { - String strCommand = consoleDoc.getCommandString(); - if (strCommand.length() == 0) - return; - consoleDoc - .colorCommand(viewer.scriptCheck(strCommand) == null ? consoleDoc.attUserInput - : consoleDoc.attError); - } - -} - -class ConsoleDocument extends DefaultStyledDocument -{ - - ConsoleTextPane consoleTextPane; - - SimpleAttributeSet attError; - - SimpleAttributeSet attEcho; - - SimpleAttributeSet attPrompt; - - SimpleAttributeSet attUserInput; - - SimpleAttributeSet attStatus; - - ConsoleDocument() - { - super(); - - attError = new SimpleAttributeSet(); - StyleConstants.setForeground(attError, Color.red); - - attPrompt = new SimpleAttributeSet(); - StyleConstants.setForeground(attPrompt, Color.magenta); - - attUserInput = new SimpleAttributeSet(); - StyleConstants.setForeground(attUserInput, Color.black); - - attEcho = new SimpleAttributeSet(); - StyleConstants.setForeground(attEcho, Color.blue); - StyleConstants.setBold(attEcho, true); - - attStatus = new SimpleAttributeSet(); - StyleConstants.setForeground(attStatus, Color.black); - StyleConstants.setItalic(attStatus, true); - } - - void setConsoleTextPane(ConsoleTextPane consoleTextPane) - { - this.consoleTextPane = consoleTextPane; - } - - Position positionBeforePrompt; // starts at 0, so first time isn't tracked - - // (at least on Mac OS X) - - Position positionAfterPrompt; // immediately after $, so this will track - - int offsetAfterPrompt; // only still needed for the insertString override and - - // replaceCommand - - /** - * Removes all content of the script window, and add a new prompt. - */ - void clearContent() - { - try - { - super.remove(0, getLength()); - } catch (BadLocationException exception) - { - System.out.println("Could not clear script window content: " - + exception.getMessage()); - } - } - - void setPrompt() - { - try - { - super.insertString(getLength(), "$ ", attPrompt); - setOffsetPositions(); - consoleTextPane.setCaretPosition(offsetAfterPrompt); - } catch (BadLocationException e) - { - e.printStackTrace(); - } - } - - void setOffsetPositions() - { - try - { - offsetAfterPrompt = getLength(); - positionBeforePrompt = createPosition(offsetAfterPrompt - 2); - // after prompt should be immediately after $ otherwise tracks the end - // of the line (and no command will be found) at least on Mac OS X it did. - positionAfterPrompt = createPosition(offsetAfterPrompt - 1); - } catch (BadLocationException e) - { - e.printStackTrace(); - } - } - - void setNoPrompt() - { - try - { - offsetAfterPrompt = getLength(); - positionAfterPrompt = positionBeforePrompt = createPosition(offsetAfterPrompt); - consoleTextPane.setCaretPosition(offsetAfterPrompt); - } catch (BadLocationException e) - { - e.printStackTrace(); - } - } - - // it looks like the positionBeforePrompt does not track when it started out - // as 0 - // and a insertString at location 0 occurs. It may be better to track the - // position after the prompt in stead - void outputBeforePrompt(String str, SimpleAttributeSet attribute) - { - try - { - int pt = consoleTextPane.getCaretPosition(); - Position caretPosition = createPosition(pt); - pt = positionBeforePrompt.getOffset(); - super.insertString(pt, str + "\n", attribute); - setOffsetPositions(); - pt = caretPosition.getOffset(); - consoleTextPane.setCaretPosition(pt); - } catch (BadLocationException e) - { - e.printStackTrace(); - } - } - - void outputError(String strError) - { - outputBeforePrompt(strError, attError); - } - - void outputErrorForeground(String strError) - { - try - { - super.insertString(getLength(), strError + "\n", attError); - consoleTextPane.setCaretPosition(getLength()); - } catch (BadLocationException e) - { - e.printStackTrace(); - - } - } - - void outputEcho(String strEcho) - { - outputBeforePrompt(strEcho, attEcho); - } - - void outputStatus(String strStatus) - { - outputBeforePrompt(strStatus, attStatus); - } - - void appendNewline() - { - try - { - super.insertString(getLength(), "\n", attUserInput); - consoleTextPane.setCaretPosition(getLength()); - } catch (BadLocationException e) - { - e.printStackTrace(); - } - } - - // override the insertString to make sure everything typed ends up at the end - // or in the 'command line' using the proper font, and the newline is - // processed. - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException - { - int ichNewline = str.indexOf('\n'); - if (ichNewline > 0) - str = str.substring(0, ichNewline); - if (ichNewline != 0) - { - if (offs < offsetAfterPrompt) - { - offs = getLength(); - } - super.insertString(offs, str, a == attError ? a : attUserInput); - consoleTextPane.setCaretPosition(offs + str.length()); - } - if (ichNewline >= 0) - { - consoleTextPane.enterPressed(); - } - } - - String getCommandString() - { - String strCommand = ""; - try - { - int cmdStart = positionAfterPrompt.getOffset(); - strCommand = getText(cmdStart, getLength() - cmdStart); - while (strCommand.length() > 0 && strCommand.charAt(0) == ' ') - strCommand = strCommand.substring(1); - } catch (BadLocationException e) - { - e.printStackTrace(); - } - return strCommand; - } - - public void remove(int offs, int len) throws BadLocationException - { - if (offs < offsetAfterPrompt) - { - len -= offsetAfterPrompt - offs; - if (len <= 0) - return; - offs = offsetAfterPrompt; - } - super.remove(offs, len); - // consoleTextPane.setCaretPosition(offs); - } - - public void replace(int offs, int length, String str, AttributeSet attrs) - throws BadLocationException - { - if (offs < offsetAfterPrompt) - { - if (offs + length < offsetAfterPrompt) - { - offs = getLength(); - length = 0; - } - else - { - length -= offsetAfterPrompt - offs; - offs = offsetAfterPrompt; - } - } - super.replace(offs, length, str, attrs); - // consoleTextPane.setCaretPosition(offs + str.length()); - } - - /** - * Replaces current command on script. - * - * @param newCommand - * new command value - * @param isError - * true to set error color ends with #?? - * - * @throws BadLocationException - */ - void replaceCommand(String newCommand, boolean isError) - throws BadLocationException - { - if (positionAfterPrompt == positionBeforePrompt) - return; - replace(offsetAfterPrompt, getLength() - offsetAfterPrompt, newCommand, - isError ? attError : attUserInput); - } - - void colorCommand(SimpleAttributeSet att) - { - if (positionAfterPrompt == positionBeforePrompt) - return; - setCharacterAttributes(offsetAfterPrompt, getLength() - - offsetAfterPrompt, att, true); - } -} - -interface EnterListener -{ - public void enterPressed(); -} diff --git a/src/jalview/ws/EnfinEnvision2OneWay.java b/src/jalview/ws/EnfinEnvision2OneWay.java index 239a626..2055596 100644 --- a/src/jalview/ws/EnfinEnvision2OneWay.java +++ b/src/jalview/ws/EnfinEnvision2OneWay.java @@ -20,17 +20,6 @@ */ package jalview.ws; -import jalview.bin.Cache; -import jalview.datamodel.DBRefEntry; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; -import jalview.gui.AlignFrame; -import jalview.gui.Desktop; -import jalview.gui.JvSwingUtils; -import jalview.util.GroupUrlLink; -import jalview.util.MessageManager; -import jalview.util.GroupUrlLink.UrlStringTooLongException; - import java.awt.Component; import java.awt.Cursor; import java.awt.event.ActionEvent; @@ -54,7 +43,16 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; -import com.lowagie.text.html.HtmlEncoder; +import jalview.bin.Cache; +import jalview.datamodel.DBRefEntry; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.JvSwingUtils; +import jalview.util.GroupUrlLink; +import jalview.util.GroupUrlLink.UrlStringTooLongException; +import jalview.util.MessageManager; /** * Lightweight runnable to discover dynamic 'one way' group URL services @@ -65,6 +63,7 @@ import com.lowagie.text.html.HtmlEncoder; * @deprecated * */ +@Deprecated public class EnfinEnvision2OneWay extends DefaultHandler implements Runnable, WSMenuEntryProviderI { @@ -321,7 +320,8 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements } try { - descr = HtmlEncoder.encode(descr); + // TODO check with Jim if this class (EnfinEnvision) is obsolete + // descr = HtmlEncoder.encode(descr); // iText removed from Jmol 14.2 } catch (Exception e) { } @@ -431,7 +431,9 @@ public class EnfinEnvision2OneWay extends DefaultHandler implements private JMenu buildGroupURLMenu(SequenceI[] seqs, SequenceGroup sg) { if (groupURLdescr == null || groupURLLinks == null) + { return null; + } // TODO: usability: thread off the generation of group url content so root // menu appears asap // sequence only URLs diff --git a/src/jalview/ws/jws2/JabaParamStore.java b/src/jalview/ws/jws2/JabaParamStore.java index be18b51..baa1d9d 100644 --- a/src/jalview/ws/jws2/JabaParamStore.java +++ b/src/jalview/ws/jws2/JabaParamStore.java @@ -27,7 +27,6 @@ import java.util.Hashtable; import java.util.List; import java.util.StringTokenizer; -import org.jmol.util.ArrayUtil; import compbio.metadata.Argument; import compbio.metadata.Option; import compbio.metadata.Parameter; diff --git a/test/jalview/io/NewickFileTests.java b/test/jalview/io/NewickFileTests.java index bd0bb52..dd6567c 100644 --- a/test/jalview/io/NewickFileTests.java +++ b/test/jalview/io/NewickFileTests.java @@ -20,19 +20,13 @@ */ package jalview.io; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Arrays; import java.util.Collection; -import java.util.Iterator; import java.util.Vector; -import jalview.analysis.NJTree; -import jalview.analysis.SequenceIdMatcher; -import jalview.datamodel.SequenceI; -import jalview.datamodel.SequenceNode; - -import org.jmol.util.ArrayUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -40,6 +34,11 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; +import jalview.analysis.NJTree; +import jalview.analysis.SequenceIdMatcher; +import jalview.datamodel.SequenceI; +import jalview.datamodel.SequenceNode; + /** * @author jimp * @@ -124,7 +123,7 @@ public class NewickFileTests { olsqs[i] = (SequenceI) ((SequenceNode) oseqs.get(i)).element(); } - nseqs = (Vector) new NJTree(new SequenceI[0], nf_regen).findLeaves( + nseqs = new NJTree(new SequenceI[0], nf_regen).findLeaves( nf_regen.getTree(), new Vector()); assertTrue(stage + "No nodes in regerated tree.", nseqs.size() > 0); SequenceI[] nsqs = new SequenceI[nseqs.size()];