*/
package jalview.gui;
-import jalview.api.SequenceStructureBinding;
-import jalview.api.structures.JalviewStructureDisplayI;
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.gui.ViewSelectionMenu.ViewSetProvider;
import jalview.io.AppletFormatAdapter;
import jalview.io.JalviewFileChooser;
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;
*
*/
public class ChimeraViewFrame extends GStructureViewer implements Runnable,
- ViewSetProvider, JalviewStructureDisplayI
-
+ ViewSetProvider
{
- private JalviewChimeraBindingModel jmb;
-
- /*
- * list of sequenceSet ids associated with the view
- */
- private ArrayList<String> _aps = new ArrayList<String>();
-
- /*
- * list of alignment panels to use for superposition
- */
- private Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
-
- /*
- * list of alignment panels that are used for colouring structures by aligned
- * sequences
- */
- private Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
+ private JalviewChimeraBinding jmb;
private boolean allChainsSelected = false;
private IProgressIndicator progressBar = null;
- private String viewId = null;
-
/*
* pdb retrieval thread.
*/
_alignwith = new Vector<AlignmentPanel>();
}
+ // save As not yet implemented
+ savemenu.setVisible(false);
+
ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
MessageManager.getString("label.colour_by"), this, _colourwith,
new ItemListener()
// TODO : Fix multiple seq to one chain issue here.
ap.getStructureSelectionManager().setMapping(seq, chains,
alreadyMapped, AppletFormatAdapter.FILE);
- if (ap.seqPanel.seqCanvas.fr != null)
+ if (ap.getSeqPanel().seqCanvas.fr != null)
{
- ap.seqPanel.seqCanvas.fr.featuresAdded();
+ ap.getSeqPanel().seqCanvas.fr.featuresAdded();
ap.paintAlignment(true);
}
final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
// JBPNOTE: this looks like a binding routine, rather than a gui
// routine
- for (int pe = 0; pe < topView.jmb.pdbentry.length; pe++)
+ for (int pe = 0; pe < topView.jmb.getPdbCount(); pe++)
{
- if (topView.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
+ if (topView.jmb.getPdbEntry(pe).getFile()
+ .equals(
+ alreadyMapped))
{
topView.jmb.addSequence(pe, seq);
topView.addAlignmentPanel(ap);
jmb.setFinishedInit(false);
// TODO: consider waiting until the structure/view is fully loaded before
// displaying
- jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
+ jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle("Chimera", true),
getBounds().width, getBounds().height);
if (command == null)
{
jmb.centerViewer(toshow);
}
+ /**
+ * 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.
+ */
public void closeViewer()
{
- jmb.closeViewer();
+ 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);
+ }
ap = null;
_aps.clear();
_alignwith.clear();
String[] curfiles = jmb.getPdbFile(); // files currently in viewer
// TODO: replace with reference fetching/transfer code (validate PDBentry
// as a DBRef?)
- for (int pi = 0; pi < jmb.pdbentry.length; pi++)
+ for (int pi = 0; pi < jmb.getPdbCount(); pi++)
{
String file = null;
- thePdbEntry = jmb.pdbentry[pi];
+ thePdbEntry = jmb.getPdbEntry(pi);
if (thePdbEntry.getFile() == null)
{
/*
} catch (Exception ex)
{
ex.printStackTrace();
- errormsgs.append("When retrieving pdbfiles : current was: '"
+ errormsgs.append("When retrieving pdbfiles for '"
+ thePdbEntry.getId() + "'");
}
if (errormsgs.length() > 0)
{
int pos = filePDBpos.get(num).intValue();
jmb.openFile(pe);
- jmb.addSequence(pos, jmb.sequence[pos]);
+ jmb.addSequence(pos, jmb.getSequence()[pos]);
File fl = new File(pe.getFile());
String protocol = AppletFormatAdapter.URL;
try
}
// Explicitly map to the filename used by Chimera ;
// TODO: use pe.getId() instead of pe.getFile() ?
- jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
+ jmb.getSsm().setMapping(jmb.getSequence()[pos], null,
+ pe.getFile(),
protocol);
} catch (OutOfMemoryError oomerror)
{
} catch (OutOfMemoryError oomerror)
{
new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
- }
- if (progressBar != null)
+ } finally
{
- progressBar.setProgressBar(
- MessageManager.getString("label.state_completed"), hdl);
+ if (progressBar != null)
+ {
+ progressBar
+ .setProgressBar(
+ pdbid
+ + " "
+ + MessageManager
+ .getString("label.state_completed"),
+ hdl);
+ }
}
/*
* If PDB data were saved and are not invalid (empty alignment), return the
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
try
{
- for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
+ for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
{
- cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
+ cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
cap.appendText("\n");
}
} catch (OutOfMemoryError e)
}
}
- public String getViewId()
- {
- if (viewId == null)
- {
- viewId = System.currentTimeMillis() + "." + this.hashCode();
- }
- return viewId;
- }
-
public void updateTitleAndMenus()
{
if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
}
setChainMenuItems(jmb.chainNames);
- this.setTitle(jmb.getViewerTitle());
- if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
+ this.setTitle(jmb.getViewerTitle("Chimera", true));
+ if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
{
viewerActionMenu.setVisible(true);
}
return ap;
}
- /**
- *
- * @param ap2
- * @return true if this Chimera instance is linked with the given alignPanel
- */
- public boolean isLinkedWith(AlignmentPanel ap2)
- {
- return _aps.contains(ap2.av.getSequenceSetId());
- }
-
- public boolean isUsedforaligment(AlignmentPanel ap2)
- {
-
- return (_alignwith != null) && _alignwith.contains(ap2);
- }
-
- public boolean isUsedforcolourby(AlignmentPanel ap2)
+ @Override
+ public AAStructureBindingModel getBinding()
{
- return (_colourwith != null) && _colourwith.contains(ap2);
+ return jmb;
}
/**
+ * Ask Chimera to save its session to the designated file path. Returns true
+ * if successful, else false.
*
- * @return TRUE if the view is NOT being coloured by sequence associations.
+ * @param filepath
*/
- public boolean isColouredByChimera()
+ public boolean saveSession(String filepath)
{
- return !jmb.isColourBySequence();
+ return jmb.saveSession(filepath);
}
-
- public SequenceStructureBinding getBinding()
- {
- return jmb;
- }
-
}