void dispose();
/**
- * shutdown any structure viewing processes started by this display
+ * Shutdown any Jalview structure viewing processes started by this display
+ *
+ * @param closeExternalViewer
+ * if true, force close any linked external viewer process
*/
- void closeViewer();
+ void closeViewer(boolean closeExternalViewer);
/**
* apply a colourscheme to the structures in the viewer
* @param colourScheme
*/
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.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;
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.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;
{
public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
{
- closeViewer();
+ closeViewer(false);
}
});
initJmol(loadStatus); // pdbentry, seq, JBPCHECK!
{
public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
{
- closeViewer();
+ closeViewer(false);
}
});
jmb.centerViewer(toshow);
}
- public void closeViewer()
+ public void closeViewer(boolean closeExternalViewer)
{
+ // JMol does not use an external viewer
jmb.closeViewer();
setAlignmentPanel(null);
_aps.clear();
*/
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.ext.rbvi.chimera.JalviewChimeraBinding;
-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 jalview.ws.dbsources.Pdb;
-
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
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.ext.rbvi.chimera.JalviewChimeraBinding;
+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 jalview.ws.dbsources.Pdb;
+
/**
* GUI elements for handlnig an external chimera display
*
{
public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
{
- closeViewer();
+ closeViewer(false);
}
});
* Close down this instance of Jalview's Chimera viewer, giving the user the
* option to close the associated Chimera window (process). They may wish to
* keep it open until they have had an opportunity to save any work.
+ *
+ * @param closeChimera
+ * if true, close any linked Chimera process; if false, prompt first
*/
- public void closeViewer()
+ public void closeViewer(boolean closeChimera)
{
if (jmb.isChimeraRunning())
{
- String prompt = MessageManager
- .formatMessage("label.confirm_close_chimera", new Object[]
- { jmb.getViewerTitle("Chimera", false) });
- prompt = JvSwingUtils.wrapTooltip(true, prompt);
- int confirm = JOptionPane.showConfirmDialog(this, prompt,
- MessageManager.getString("label.close_viewer"),
- JOptionPane.YES_NO_OPTION);
- jmb.closeViewer(confirm == JOptionPane.YES_OPTION);
+ if (!closeChimera)
+ {
+ String prompt = MessageManager.formatMessage(
+ "label.confirm_close_chimera", new Object[]
+ { jmb.getViewerTitle("Chimera", false) });
+ prompt = JvSwingUtils.wrapTooltip(true, prompt);
+ int confirm = JOptionPane.showConfirmDialog(this, prompt,
+ MessageManager.getString("label.close_viewer"),
+ JOptionPane.YES_NO_OPTION);
+ closeChimera = confirm == JOptionPane.YES_OPTION;
+ }
+ jmb.closeViewer(closeChimera);
}
setAlignmentPanel(null);
_aps.clear();
(OutOfMemoryError) ex.getCause());
if (sview != null && sview.isVisible())
{
- sview.closeViewer();
+ sview.closeViewer(false);
sview.setVisible(false);
sview.dispose();
}
package jalview.ext.rbvi.chimera;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import java.util.Collection;
-
import org.junit.Test;
import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
-import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
public class ChimeraConnect
{
@Test
- public void test()
+ public void testLaunchAndExit()
{
- StructureManager csm;
- ext.edu.ucsf.rbvi.strucviz2.ChimeraManager cm = new ChimeraManager(csm = new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
+ final StructureManager structureManager = new StructureManager(true);
+ ChimeraManager cm = new ChimeraManager(structureManager);
assertTrue("Couldn't launch chimera",
cm.launchChimera(StructureManager.getChimeraPaths()));
- int n=0;
- while (n++<100)
- {
- try {
- Thread.sleep(1000);
- } catch (Exception q)
- {
-
- }
- Collection<ChimeraModel> cms = cm.getChimeraModels();
- for (ChimeraModel cmod :cms) {
- System.out.println(cmod.getModelName());
- }
- }
+ assertTrue(cm.isChimeraLaunched()); // Chimera process is alive
+ // int n=0;
+ // not sure of the point of this is unless the tester is loading models
+ // manually?
+ // while (n++ < 100)
+ // {
+ // try {
+ // Thread.sleep(1000);
+ // } catch (Exception q)
+ // {
+ //
+ // }
+ // Collection<ChimeraModel> cms = cm.getChimeraModels();
+ // for (ChimeraModel cmod :cms) {
+ // System.out.println(cmod.getModelName());
+ // }
+ // }
cm.exitChimera();
+ assertFalse(cm.isChimeraLaunched()); // Chimera process has ended
}
}
import org.junit.BeforeClass;
import org.junit.Test;
+import jalview.api.structures.JalviewStructureDisplayI;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
}
+ @Test
+ public void testSingleSeqViewJMol()
+ {
+ String inFile = "examples/1gaq.txt";
+ AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
+ inFile, FormatAdapter.FILE);
+ assertTrue("Didn't read input file " + inFile, af != null);
+ for (SequenceI sq : af.getViewport().getAlignment().getSequences())
+ {
+ SequenceI dsq = sq.getDatasetSequence();
+ while (dsq.getDatasetSequence() != null)
+ {
+ dsq = dsq.getDatasetSequence();
+ }
+ if (dsq.getPDBId() != null && dsq.getPDBId().size() > 0)
+ {
+ for (int q = 0; q < dsq.getPDBId().size(); q++)
+ {
+ final StructureViewer structureViewer = new StructureViewer(af
+ .getViewport().getStructureSelectionManager());
+
+ JalviewStructureDisplayI jmolViewer = structureViewer
+ .viewStructures(ViewerType.JMOL, af.getCurrentView()
+ .getAlignPanel(), new PDBEntry[]
+ { (PDBEntry) dsq.getPDBId().elementAt(q) },
+ new SequenceI[][]
+ { new SequenceI[]
+ { sq } });
+ /*
+ * Wait for viewer thread to start
+ */
+ try
+ {
+ Thread.sleep(1000);
+ } catch (InterruptedException e)
+ {
+ }
+
+ jmolViewer.closeViewer(true);
+ // todo: break here means only once through this loop?
+ break;
+ }
+ break;
+ }
+ }
+ }
@Test
- public void testSingleSeqView()
+ public void testSingleSeqViewChimera()
{
String inFile = "examples/1gaq.txt";
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
inFile, FormatAdapter.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
- for (SequenceI sq:af.getViewport().getAlignment().getSequences())
+ for (SequenceI sq : af.getViewport().getAlignment().getSequences())
{
- SequenceI dsq=sq.getDatasetSequence();
- while (dsq.getDatasetSequence()!=null)
+ SequenceI dsq = sq.getDatasetSequence();
+ while (dsq.getDatasetSequence() != null)
{
- dsq=dsq.getDatasetSequence();
+ dsq = dsq.getDatasetSequence();
}
- if (dsq.getPDBId()!=null && dsq.getPDBId().size()>0) {
- for (int q=0;q<dsq.getPDBId().size();q++)
+ if (dsq.getPDBId() != null && dsq.getPDBId().size() > 0)
+ {
+ for (int q = 0; q < dsq.getPDBId().size(); q++)
{
- new StructureViewer(af.getViewport()
- .getStructureSelectionManager()).viewStructures(
- ViewerType.JMOL,
- af.getCurrentView().getAlignPanel(),
- new PDBEntry[] { (PDBEntry)dsq.getPDBId().elementAt(q) },
- new SequenceI[][] { new SequenceI[] { sq } });
+ final StructureViewer structureViewer = new StructureViewer(af
+ .getViewport().getStructureSelectionManager());
- new StructureViewer(af.getViewport()
- .getStructureSelectionManager()).viewStructures(
- ViewerType.CHIMERA,
- af.getCurrentView().getAlignPanel(),
- new PDBEntry[] { (PDBEntry)dsq.getPDBId().elementAt(q) },
- new SequenceI[][] { new SequenceI[] { sq } });
+ JalviewStructureDisplayI chimeraViewer = structureViewer
+ .viewStructures(ViewerType.CHIMERA, af.getCurrentView()
+ .getAlignPanel(), new PDBEntry[]
+ { (PDBEntry) dsq.getPDBId().elementAt(q) },
+ new SequenceI[][]
+ { new SequenceI[]
+ { sq } });
+ /*
+ * Wait for viewer thread to start
+ */
+ try
+ {
+ Thread.sleep(1000);
+ } catch (InterruptedException e)
+ {
+ }
+ chimeraViewer.closeViewer(true);
// todo: break here means only once through this loop?
break;
}
break;
}
- }
- // try {
- // why?
-// Thread.sleep(200000);
-// } catch (InterruptedException q)
-// {
- // }
+ }
}
}