X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAppJmol.java;h=ea7fb6b22bfc22e508e6e9477a51c254fcc71bc7;hb=7e207b38944654b23b1dffe17c50bee095573176;hp=fef7451d7118664d2f2e6d4f82f4aca60c2320e9;hpb=14193747f3831242bc7dfac12394eb20eb0ba480;p=jalview.git diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index fef7451..ea7fb6b 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Vector; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JInternalFrame; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.SwingUtilities; @@ -58,7 +57,7 @@ public class AppJmol extends StructureViewerBase private static final String SPACE = " "; - private static final String BACKSLASH = "\""; + private static final String QUOTE = "\""; AppJmolBinding jmb; @@ -162,8 +161,9 @@ public class AppJmol extends StructureViewerBase { return progressBar; } + /** - * add a single PDB structure to a new or existing Jmol view + * display a single PDB structure in a new Jmol view * * @param pdbentry * @param seq @@ -174,33 +174,14 @@ public class AppJmol extends StructureViewerBase final AlignmentPanel ap) { progressBar = ap.alignFrame; - String pdbId = pdbentry.getId(); - /* - * If the PDB file is already loaded, the user may just choose to add to an - * existing viewer (or cancel) - */ - if (addAlreadyLoadedFile(seq, chains, ap, pdbId)) - { - return; - } - - /* - * Check if there are other Jmol views involving this alignment and prompt - * user about adding this molecule to one of them - */ - if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId)) - { - return; - } - - /* - * If the options above are declined or do not apply, open a new viewer - */ - openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq }); + openNewJmol(ap, alignAddedStructures, new PDBEntry[] { pdbentry }, + new SequenceI[][] + { seq }); } - private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys, + private void openNewJmol(AlignmentPanel ap, boolean alignAdded, + PDBEntry[] pdbentrys, SequenceI[][] seqs) { progressBar = ap.alignFrame; @@ -209,11 +190,9 @@ public class AppJmol extends StructureViewerBase addAlignmentPanel(ap); useAlignmentPanelForColourbyseq(ap); - if (pdbentrys.length > 1) - { - alignAddedStructures = true; - useAlignmentPanelForSuperposition(ap); - } + alignAddedStructures = alignAdded; + useAlignmentPanelForSuperposition(ap); + jmb.setColourBySequence(true); setSize(400, 400); // probably should be a configurable/dynamic default here initMenus(); @@ -234,41 +213,21 @@ public class AppJmol extends StructureViewerBase } /** - * create a new Jmol containing several structures superimposed using the - * given alignPanel. + * create a new Jmol containing several structures optionally superimposed + * using the given alignPanel. * * @param ap + * @param alignAdded + * - true to superimpose * @param pe * @param seqs */ - public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs) + public AppJmol(AlignmentPanel ap, boolean alignAdded, PDBEntry[] pe, + SequenceI[][] seqs) { - openNewJmol(ap, pe, seqs); + openNewJmol(ap, alignAdded, pe, seqs); } - /** - * Returns a list of any Jmol viewers. The list is restricted to those linked - * to the given alignment panel if it is not null. - */ - @Override - protected List getViewersFor(AlignmentPanel apanel) - { - List result = new ArrayList<>(); - JInternalFrame[] frames = Desktop.instance.getAllFrames(); - - for (JInternalFrame frame : frames) - { - if (frame instanceof AppJmol) - { - if (apanel == null - || ((StructureViewerBase) frame).isLinkedWith(apanel)) - { - result.add((StructureViewerBase) frame); - } - } - } - return result; - } void initJmol(String command) { @@ -300,8 +259,6 @@ public class AppJmol extends StructureViewerBase jmb.setFinishedInit(true); } - boolean allChainsSelected = false; - @Override void showSelectedChains() { @@ -368,8 +325,8 @@ public class AppJmol extends StructureViewerBase StringBuilder fileList = new StringBuilder(); for (String s : files) { - fileList.append(SPACE).append(BACKSLASH) - .append(Platform.escapeString(s)).append(BACKSLASH); + fileList.append(SPACE).append(QUOTE) + .append(Platform.escapeBackslashes(s)).append(QUOTE); } String filesString = fileList.toString(); @@ -444,7 +401,7 @@ public class AppJmol extends StructureViewerBase jmb.updateColours(ap); } // do superposition if asked to - if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures) + if (alignAddedStructures) { alignAddedStructures(); } @@ -478,7 +435,7 @@ public class AppJmol extends StructureViewerBase } } }); - alignAddedStructures = false; + } /** @@ -507,6 +464,7 @@ public class AppJmol extends StructureViewerBase String file = jmb.getPdbEntry(pi).getFile(); if (file == null) { + // todo: extract block as method and pull up (also ChimeraViewFrame) // retrieve the pdb and store it locally AlignmentI pdbseq = null; pdbid = jmb.getPdbEntry(pi).getId(); @@ -557,7 +515,7 @@ public class AppJmol extends StructureViewerBase addingStructures = true; // already files loaded. for (int c = 0; c < filesInViewer.length; c++) { - if (filesInViewer[c].equals(file)) + if (Platform.pathEquals(filesInViewer[c], file)) { file = null; break;