* The syntax is: setattr r <attName> <attValue> <atomSpec> *
* For example: setattr r jv_chain "Ferredoxin-1, Chloroplastic" #0:94.A
*/
protected void sendFeaturesToChimera()
{
int count = jmb.sendFeaturesToViewer(getAlignmentPanel());
statusBar.setText(
MessageManager.formatMessage("label.attributes_set", count));
}
/**
* open a single PDB structure in a new Chimera view
*
* @param pdbentry
* @param seq
* @param chains
* @param ap
*/
public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
String[] chains, final AlignmentPanel ap)
{
this();
openNewChimera(ap, new PDBEntry[] { pdbentry },
new SequenceI[][]
{ seq });
}
/**
* Create a helper to manage progress bar display
*/
protected void createProgressBar()
{
if (getProgressIndicator() == null)
{
setProgressIndicator(new ProgressBar(statusPanel, statusBar));
}
}
private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
SequenceI[][] seqs)
{
createProgressBar();
jmb = newBindingModel(ap, pdbentrys, seqs);
addAlignmentPanel(ap);
useAlignmentPanelForColourbyseq(ap);
if (pdbentrys.length > 1)
{
useAlignmentPanelForSuperposition(ap);
}
jmb.setColourBySequence(true);
setSize(myWidth, myHeight);
initMenus();
addingStructures = false;
worker = new Thread(this);
worker.start();
this.addInternalFrameListener(new InternalFrameAdapter()
{
@Override
public void internalFrameClosing(
InternalFrameEvent internalFrameEvent)
{
closeViewer(false);
}
});
}
protected JalviewChimeraBindingModel newBindingModel(AlignmentPanel ap,
PDBEntry[] pdbentrys, SequenceI[][] seqs)
{
return new JalviewChimeraBindingModel(this,
ap.getStructureSelectionManager(), pdbentrys, seqs, null);
}
/**
* Create a new viewer from saved session state data including Chimera session
* file
*
* @param chimeraSessionFile
* @param alignPanel
* @param pdbArray
* @param seqsArray
* @param colourByChimera
* @param colourBySequence
* @param newViewId
*/
public ChimeraViewFrame(String chimeraSessionFile,
AlignmentPanel alignPanel, PDBEntry[] pdbArray,
SequenceI[][] seqsArray, boolean colourByChimera,
boolean colourBySequence, String newViewId)
{
this();
setViewId(newViewId);
this.chimeraSessionFile = chimeraSessionFile;
openNewChimera(alignPanel, pdbArray, seqsArray);
if (colourByChimera)
{
jmb.setColourBySequence(false);
seqColour.setSelected(false);
viewerColour.setSelected(true);
}
else if (colourBySequence)
{
jmb.setColourBySequence(true);
seqColour.setSelected(true);
viewerColour.setSelected(false);
}
}
/**
* create a new viewer containing several structures, optionally superimposed
* using the given alignPanel.
*
* @param pe
* @param seqs
* @param ap
*/
public ChimeraViewFrame(PDBEntry[] pe, boolean alignAdded,
SequenceI[][] seqs,
AlignmentPanel ap)
{
this();
setAlignAddedStructures(alignAdded);
openNewChimera(ap, pe, seqs);
}
/**
* Default constructor
*/
public ChimeraViewFrame()
{
super();
/*
* closeViewer will decide whether or not to close this frame
* depending on whether user chooses to Cancel or not
*/
setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
}
/**
* Launch Chimera. If we have a chimera session file name, send Chimera the
* command to open its saved session file.
*/
void initChimera()
{
jmb.setFinishedInit(false);
Desktop.addInternalFrame(this,
jmb.getViewerTitle(getViewerName(), true), getBounds().width,
getBounds().height);
if (!jmb.launchChimera())
{
JvOptionPane.showMessageDialog(Desktop.desktop,
MessageManager.getString("label.chimera_failed"),
MessageManager.getString("label.error_loading_file"),
JvOptionPane.ERROR_MESSAGE);
this.dispose();
return;
}
if (this.chimeraSessionFile != null)
{
boolean opened = jmb.openSession(chimeraSessionFile);
if (!opened)
{
System.err.println("An error occurred opening Chimera session file "
+ chimeraSessionFile);
}
}
jmb.startChimeraListener();
}
/**
* 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
*/
@Override
public void closeViewer(boolean closeChimera)
{
if (jmb != null && jmb.isChimeraRunning())
{
if (!closeChimera)
{
String prompt = MessageManager
.formatMessage("label.confirm_close_chimera", new Object[]
{ jmb.getViewerTitle(getViewerName(), false) });
prompt = JvSwingUtils.wrapTooltip(true, prompt);
int confirm = JvOptionPane.showConfirmDialog(this, prompt,
MessageManager.getString("label.close_viewer"),
JvOptionPane.YES_NO_CANCEL_OPTION);
/*
* abort closure if user hits escape or Cancel
*/
if (confirm == JvOptionPane.CANCEL_OPTION
|| confirm == JvOptionPane.CLOSED_OPTION)
{
return;
}
closeChimera = confirm == JvOptionPane.YES_OPTION;
}
jmb.closeViewer(closeChimera);
}
setAlignmentPanel(null);
_aps.clear();
_alignwith.clear();
_colourwith.clear();
// TODO: check for memory leaks where instance isn't finalised because jmb
// holds a reference to the window
jmb = null;
dispose();
}
/**
* Open any newly added PDB structures in Chimera, having first fetched data
* from PDB (if not already saved).
*/
@Override
public void run()
{
_started = true;
// todo - record which pdbids were successfully imported.
StringBuilder errormsgs = new StringBuilder(128);
StringBuilder files = new StringBuilder(128);
List