*/
void raiseViewer();
+ AlignmentViewPanel getAlignmentPanel();
+
+ /**
+ * Answers true if the given alignment view is used to colour structures by
+ * sequence, false if not
+ *
+ * @param ap
+ * @return
+ */
+ boolean isUsedForColourBy(AlignmentViewPanel ap);
+
+ /**
+ * If implemented, shows a command line console in the structure viewer
+ *
+ * @param show
+ * true to show, false to hide
+ */
+ void showConsole(boolean show);
+
+ /**
+ * Remove references to the given alignment view for this structure viewer
+ *
+ * @param avp
+ */
+ void removeAlignmentPanel(AlignmentViewPanel avp);
+
+ /**
+ * Updates the progress bar if there is one. Call stopProgressBar with the
+ * returned handle to remove the message.
+ *
+ * @param msg
+ * @return handle
+ */
+ long startProgressBar(String progressMsg);
+
+ void stopProgressBar(Object object, long handle);
+
}
* without an additional javascript library to exchange messages between the
* distinct applets. See http://issues.jalview.org/browse/JAL-621
*
- * @param viewer
+ * @param jmolViewer
* JmolViewer instance
* @param sequenceIds
* - sequence Ids to search for associations
else if (protocol == DataSourceType.FILE
|| protocol == DataSourceType.URL)
{
- jmb.viewer.openFile(pdbentry.getFile());
+ jmb.jmolViewer.openFile(pdbentry.getFile());
}
else
{
throw new Exception(MessageManager.getString(
"exception.invalid_datasource_couldnt_obtain_reader"));
}
- jmb.viewer.openReader(pdbentry.getFile(), pdbentry.getId(),
+ jmb.jmolViewer.openReader(pdbentry.getFile(), pdbentry.getId(),
freader);
} catch (Exception e)
{
{
currentSize = this.getSize();
- if (jmb.viewer == null)
+ if (jmb.jmolViewer == null)
{
g.setColor(Color.black);
g.fillRect(0, 0, currentSize.width, currentSize.height);
}
else
{
- jmb.viewer.renderScreenImage(g, currentSize.width,
+ jmb.jmolViewer.renderScreenImage(g, currentSize.width,
currentSize.height);
}
}
}
@Override
- public jalview.api.FeatureRenderer getFeatureRenderer(
- AlignmentViewPanel alignment)
- {
- return appletJmolBinding.ap.getFeatureRenderer();
- }
-
- @Override
public jalview.api.SequenceRenderer getSequenceRenderer(
AlignmentViewPanel alignment)
{
Container consolePanel, String buttonsToShow)
{
JmolAppConsoleInterface appc = new AppletConsole();
- appc.start(viewer);
+ appc.start(jmolViewer);
return appc;
}
package jalview.appletgui;
import jalview.api.AlignmentViewPanel;
-import jalview.api.FeatureRenderer;
import jalview.api.SequenceRenderer;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
}
@Override
- public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment)
- {
- AlignmentPanel alignPanel = (AlignmentPanel) alignment;
- if (alignPanel.av.isShowSequenceFeatures())
- {
- return alignPanel.getFeatureRenderer();
- }
- else
- {
- return null;
- }
- }
-
-
- @Override
public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
{
return ((AlignmentPanel) alignment).getSequenceRenderer();
StringBuffer resetLastRes = new StringBuffer();
- public Viewer viewer;
+ public Viewer jmolViewer;
public JalviewJmolBinding(StructureSelectionManager ssm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
{
super(ssm, seqs);
- viewer = theViewer;
- viewer.setJmolStatusListener(this);
- viewer.addSelectionListener(this);
+ jmolViewer = theViewer;
+ jmolViewer.setJmolStatusListener(this);
+ jmolViewer.addSelectionListener(this);
}
/**
{
// remove listeners for all structures in viewer
getSsm().removeStructureViewerListener(this, this.getStructureFiles());
- viewer.dispose();
+ jmolViewer.dispose();
lastCommand = null;
- viewer = null;
+ jmolViewer = null;
releaseUIResources();
}
public String superposeStructures(AlignmentI[] _alignment,
int[] _refStructure, HiddenColumns[] _hiddenCols)
{
- while (viewer.isScriptExecuting())
+ while (jmolViewer.isScriptExecuting())
{
try
{
jmolHistory(false);
if (lastCommand == null || !lastCommand.equals(command))
{
- viewer.evalStringQuiet(command + "\n");
+ jmolViewer.evalStringQuiet(command + "\n");
}
jmolHistory(true);
lastCommand = command;
}
// TODO: verify atomIndex is selecting correct model.
// return new Color(viewer.getAtomArgb(atomIndex)); Jmol 12.2.4
- int colour = viewer.ms.at[atomIndex].atomPropertyInt(T.color);
+ int colour = jmolViewer.ms.at[atomIndex].atomPropertyInt(T.color);
return new Color(colour);
}
public synchronized String[] getStructureFiles()
{
List<String> mset = new ArrayList<>();
- if (viewer == null)
+ if (jmolViewer == null)
{
return new String[0];
}
if (modelFileNames == null)
{
- int modelCount = viewer.ms.mc;
+ int modelCount = jmolViewer.ms.mc;
String filePath = null;
for (int i = 0; i < modelCount; ++i)
{
- filePath = viewer.ms.getModelFileName(i);
+ filePath = jmolViewer.ms.getModelFileName(i);
if (!mset.contains(filePath))
{
mset.add(filePath);
{
if (resetLastRes.length() > 0)
{
- viewer.evalStringQuiet(resetLastRes.toString());
+ jmolViewer.evalStringQuiet(resetLastRes.toString());
resetLastRes.setLength(0);
}
for (AtomSpec atom : atoms)
cmd.append("spacefill 200;select none");
- viewer.evalStringQuiet(cmd.toString());
+ jmolViewer.evalStringQuiet(cmd.toString());
jmolHistory(true);
}
private void jmolHistory(boolean enable)
{
- viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
+ jmolViewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
}
public void loadInline(String string)
// Then, construct pass a reader for the string to Jmol.
// ((org.jmol.Viewer.Viewer) viewer).loadModelFromFile(fullPathName,
// fileName, null, reader, false, null, null, 0);
- viewer.openStringInline(string);
+ jmolViewer.openStringInline(string);
}
protected void mouseOverStructure(int atomIndex, final String strInfo)
if (pdbfilename == null)
{
- pdbfilename = new File(viewer.ms.getModelFileName(mnumber))
+ pdbfilename = new File(jmolViewer.ms.getModelFileName(mnumber))
.getAbsolutePath();
}
}
if (!atomsPicked.contains(picked))
{
- viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
+ jmolViewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
atomsPicked.addElement(picked);
}
else
{
- viewer.evalString("select " + picked + ";label off");
+ jmolViewer.evalString("select " + picked + ";label off");
atomsPicked.removeElement(picked);
}
jmolHistory(true);
// calculate essential attributes for the pdb data imported inline.
// prolly need to resolve modelnumber properly - for now just use our
// 'best guess'
- pdbfile = viewer.getData(
+ pdbfile = jmolViewer.getData(
"" + (1 + _modelFileNameMap[modelnum]) + ".0", "PDB");
}
// search pdbentries and sequences to find correct pdbentry for this
// this is a foreign pdb file that jalview doesn't know about - add
// it to the dataset and try to find a home - either on a matching
// sequence or as a new sequence.
- String pdbcontent = viewer.getData("/" + (modelnum + 1) + ".1",
+ String pdbcontent = jmolViewer.getData("/" + (modelnum + 1) + ".1",
"PDB");
// parse pdb file into a chain, etc.
// locate best match for pdb in associated views and add mapping to
// }
if (!isLoadingFromArchive())
{
- viewer.evalStringQuiet(
+ jmolViewer.evalStringQuiet(
"model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
}
// register ourselves as a listener and notify the gui that it needs to
{
commandOptions = "";
}
- viewer = (Viewer) JmolViewer.allocateViewer(renderPanel,
+ jmolViewer = (Viewer) JmolViewer.allocateViewer(renderPanel,
(jmolfileio ? new SmarterJmolAdapter() : null),
htmlName + ((Object) this).toString(), documentBase, codeBase,
commandOptions, this);
- viewer.setJmolStatusListener(this); // extends JmolCallbackListener
+ jmolViewer.setJmolStatusListener(this); // extends JmolCallbackListener
console = createJmolConsole(consolePanel, buttonsToShow);
if (consolePanel != null)
public void setBackgroundColour(java.awt.Color col)
{
jmolHistory(false);
- viewer.evalStringQuiet("background [" + col.getRed() + ","
+ jmolViewer.evalStringQuiet("background [" + col.getRed() + ","
+ col.getGreen() + "," + col.getBlue() + "];");
jmolHistory(true);
}
/*
* Object through which we talk to Chimera
*/
- private ChimeraManager viewer;
+ private ChimeraManager chimeraManager;
/*
* Object which listens to Chimera notifications
try
{
List<ChimeraModel> modelsToMap = new ArrayList<>();
- List<ChimeraModel> oldList = viewer.getModelList();
+ List<ChimeraModel> oldList = chimeraManager.getModelList();
boolean alreadyOpen = false;
/*
*/
if (!alreadyOpen)
{
- viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL);
- if (viewer.isChimeraX())
+ chimeraManager.openModel(file, pe.getId(), ModelType.PDB_MODEL);
+ if (chimeraManager.isChimeraX())
{
/*
* ChimeraX hack: force chimera model name to pdbId
* Chimera: query for actual models and find the one with
* matching model name - set in viewer.openModel()
*/
- List<ChimeraModel> newList = viewer.getModelList();
+ List<ChimeraModel> newList = chimeraManager.getModelList();
// JAL-1728 newList.removeAll(oldList) does not work
for (ChimeraModel cm : newList)
{
DataSourceType protocol)
{
super(ssm, pdbentry, sequenceIs, protocol);
- viewer = new ChimeraManager(new StructureManager(true));
+ chimeraManager = new ChimeraManager(new StructureManager(true));
String viewerType = Cache.getProperty(Preferences.STRUCTURE_DISPLAY);
- viewer.setChimeraX(ViewerType.CHIMERAX.name().equals(viewerType));
+ chimeraManager.setChimeraX(ViewerType.CHIMERAX.name().equals(viewerType));
}
*/
protected void startChimeraProcessMonitor()
{
- final Process p = viewer.getChimeraProcess();
+ final Process p = chimeraManager.getChimeraProcess();
chimeraMonitor = new Thread(new Runnable()
{
try
{
chimeraListener = new ChimeraListener(this);
- viewer.startListening(chimeraListener.getUri());
+ chimeraManager.startListening(chimeraListener.getUri());
} catch (BindException e)
{
System.err.println(
getSsm().removeStructureViewerListener(this, this.getStructureFiles());
if (closeChimera)
{
- viewer.exitChimera();
+ chimeraManager.exitChimera();
}
if (this.chimeraListener != null)
{
chimeraListener.shutdown();
chimeraListener = null;
}
- viewer = null;
+ chimeraManager = null;
if (chimeraMonitor != null)
{
public void colourByCharge()
{
colourBySequence = false;
- String command = viewer.isChimeraX()
+ String command = chimeraManager.isChimeraX()
? "color white;color :ASP,GLU red;color :LYS,ARG blue;color :CYS yellow"
: "color white;color red ::ASP;color red ::GLU;color blue ::LYS;color blue ::ARG;color yellow ::CYS";
sendAsynchronousCommand(command, COLOURING_CHIMERA);
refreshPdbEntries();
StringBuilder selectioncom = new StringBuilder(256);
- boolean chimeraX = viewer.isChimeraX();
+ boolean chimeraX = chimeraManager.isChimeraX();
for (int a = 0; a < _alignment.length; a++)
{
int refStructure = _refStructure[a];
*/
public boolean launchChimera()
{
- if (viewer.isChimeraLaunched())
+ if (chimeraManager.isChimeraLaunched())
{
return true;
}
- boolean launched = viewer.launchChimera(
- StructureManager.getChimeraPaths(viewer.isChimeraX()));
+ boolean launched = chimeraManager.launchChimera(
+ StructureManager.getChimeraPaths(chimeraManager.isChimeraX()));
if (launched)
{
startChimeraProcessMonitor();
*/
public boolean isChimeraRunning()
{
- return viewer.isChimeraLaunched();
+ return chimeraManager.isChimeraLaunched();
}
/**
public List<String> sendChimeraCommand(final String command,
boolean getResponse)
{
- if (viewer == null)
+ if (chimeraManager == null)
{
// ? thread running after viewer shut down
return null;
if (true /*lastCommand == null || !lastCommand.equals(command)*/)
{
// trim command or it may never find a match in the replyLog!!
- List<String> lastReply = viewer.sendChimeraCommand(command.trim(),
+ List<String> lastReply = chimeraManager.sendChimeraCommand(command.trim(),
getResponse);
if (getResponse)
{
String[] files, SequenceRenderer sr, AlignmentViewPanel viewPanel)
{
return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
- getSequence(), sr, viewPanel, viewer.isChimeraX());
+ getSequence(), sr, viewPanel, chimeraManager.isChimeraX());
}
/**
private void waitForChimera()
{
- while (viewer != null && viewer.isBusy())
+ while (chimeraManager != null && chimeraManager.isBusy())
{
try
{
@Override
public synchronized String[] getStructureFiles()
{
- if (viewer == null)
+ if (chimeraManager == null)
{
return new String[0];
}
return;
}
- boolean forChimeraX = viewer.isChimeraX();
+ boolean forChimeraX = chimeraManager.isChimeraX();
StringBuilder cmd = new StringBuilder(128);
boolean first = true;
boolean found = false;
*/
if (lastHighlightCommand != null)
{
- viewer.sendChimeraCommand("~" + lastHighlightCommand, false);
+ chimeraManager.sendChimeraCommand("~" + lastHighlightCommand, false);
}
if (found)
{
- viewer.sendChimeraCommand(command, false);
+ chimeraManager.sendChimeraCommand(command, false);
}
this.lastHighlightCommand = command;
}
/*
* Ask Chimera for its current selection
*/
- List<String> selection = viewer.getSelectedResidueSpecs();
+ List<String> selection = chimeraManager.getSelectedResidueSpecs();
/*
* Parse model number, residue and chain for each selected position,
protected List<AtomSpec> convertStructureResiduesToAlignment(
List<String> structureSelection)
{
- boolean chimeraX = viewer.isChimeraX();
+ boolean chimeraX = chimeraManager.isChimeraX();
List<AtomSpec> atomSpecs = new ArrayList<>();
for (String atomSpec : structureSelection)
{
* Chimera format: color colorCode ::VAL
* ChimeraX format: color :VAL colourCode
*/
- boolean chimeraX = viewer.isChimeraX();
+ boolean chimeraX = chimeraManager.isChimeraX();
for (String resName : residueSet)
{
char res = resName.length() == 3
{
viewerCommandHistory(false);
String command = "set bgColor " + ColorUtils.toTkCode(col);
- viewer.sendChimeraCommand(command, false);
+ chimeraManager.sendChimeraCommand(command, false);
viewerCommandHistory(true);
}
* ChimeraX: https://www.cgl.ucsf.edu/chimerax/docs/user/commands/save.html
*/
String command = isChimeraX() ? "save session " : "save ";
- List<String> reply = viewer.sendChimeraCommand(command + filepath,
+ List<String> reply = chimeraManager.sendChimeraCommand(command + filepath,
true);
if (reply.contains("Session written"))
{
*/
public void focusView()
{
- sendChimeraCommand(viewer.isChimeraX() ? "view" : "focus", false);
+ sendChimeraCommand(chimeraManager.isChimeraX() ? "view" : "focus", false);
}
/**
StructureMappingcommandSet commandSet = ChimeraCommands
.getSetAttributeCommandsForFeatures(getSsm(), files,
- getSequence(), avp, viewer.isChimeraX());
+ getSequence(), avp, chimeraManager.isChimeraX());
String[] commands = commandSet.commands;
if (commands.length > 10)
{
*/
protected void sendCommandsByFile(String[] commands)
{
- boolean toChimeraX = viewer.isChimeraX();
+ boolean toChimeraX = chimeraManager.isChimeraX();
try
{
File tmp = File.createTempFile("chim", toChimeraX ? ".cxc" : ".com");
{
boolean featureAdded = false;
String featureGroup = getViewerFeatureGroup();
- boolean chimeraX = viewer.isChimeraX();
+ boolean chimeraX = chimeraManager.isChimeraX();
for (String residue : residues)
{
*/
public List<String> getChimeraAttributes()
{
- List<String> atts = viewer.getAttrList();
+ List<String> atts = chimeraManager.getAttrList();
Iterator<String> it = atts.iterator();
while (it.hasNext())
{
public boolean isChimeraX()
{
- return viewer.isChimeraX();
+ return chimeraManager.isChimeraX();
}
}
addKeyListener();
- final List<AlignmentPanel> selviews = new ArrayList<>();
+ final List<AlignmentViewPanel> selviews = new ArrayList<>();
final List<AlignmentPanel> origview = new ArrayList<>();
final String menuLabel = MessageManager
.getString("label.copy_format_from");
*/
package jalview.gui;
+import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
.getString("label.let_jmol_manage_structure_colours"));
}
- IProgressIndicator progressBar = null;
-
- @Override
- protected IProgressIndicator getIProgressIndicator()
- {
- return progressBar;
- }
-
/**
* display a single PDB structure in a new Jmol view
*
public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
final AlignmentPanel ap)
{
- progressBar = ap.alignFrame;
+ setProgressIndicator(ap.alignFrame);
openNewJmol(ap, alignAddedStructures, new PDBEntry[] { pdbentry },
new SequenceI[][]
PDBEntry[] pdbentrys,
SequenceI[][] seqs)
{
- progressBar = ap.alignFrame;
+ setProgressIndicator(ap.alignFrame);
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
pdbentrys, seqs, null);
addAlignmentPanel(ap);
}
// refresh the sequence colours for the new structure(s)
- for (AlignmentPanel ap : _colourwith)
+ for (AlignmentViewPanel ap : _colourwith)
{
jmb.updateColours(ap);
}
@Override
public void run()
{
- if (jmb.viewer.isScriptExecuting())
+ if (jmb.jmolViewer.isScriptExecuting())
{
SwingUtilities.invokeLater(this);
try
AlignmentI pdbseq = null;
pdbid = jmb.getPdbEntry(pi).getId();
long hdl = pdbid.hashCode() - System.currentTimeMillis();
- if (progressBar != null)
- {
- progressBar.setProgressBar(MessageManager
- .formatMessage("status.fetching_pdb", new String[]
- { pdbid }), hdl);
- }
+ setProgressMessage(MessageManager
+ .formatMessage("status.fetching_pdb", new String[]
+ { pdbid }), hdl);
try
{
pdbseq = pdbclient.getSequenceRecords(pdbid);
errormsgs.append("'").append(pdbid).append("'");
} finally
{
- if (progressBar != null)
- {
- progressBar.setProgressBar(
- MessageManager.getString("label.state_completed"),
- hdl);
- }
+ setProgressMessage(
+ MessageManager.getString("label.state_completed"), hdl);
}
if (pdbseq != null)
{
if (im.getGraphics() != null)
{
- jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
+ jmb.jmolViewer.renderScreenImage(im.getGraphics(), width, height);
im.writeImage();
}
}
}
}
+ @Override
public void showConsole(boolean showConsole)
{
-
if (showConsole)
{
if (splitPane == null)
}
}
}
- else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
+ else if (jmb == null || jmb.jmolViewer == null || !jmb.isFinishedInit())
{
g.setColor(Color.black);
g.fillRect(0, 0, currentSize.width, currentSize.height);
}
else
{
- jmb.viewer.renderScreenImage(g, currentSize.width,
+ jmb.jmolViewer.renderScreenImage(g, currentSize.width,
currentSize.height);
}
}
@Override
public String getStateInfo()
{
- return jmb == null ? null : jmb.viewer.getStateInfo();
+ return jmb == null ? null : jmb.jmolViewer.getStateInfo();
}
@Override
import java.awt.Container;
import java.util.Map;
+import javax.swing.JComponent;
+
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.java.BS;
import org.openscience.jmol.app.jmolpanel.console.AppConsole;
public class AppJmolBinding extends JalviewJmolBinding
{
- private AppJmol appJmolWindow;
-
public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
DataSourceType protocol)
{
super(sSm, pdbentry, sequenceIs, protocol);
- appJmolWindow = appJmol;
- }
-
- @Override
- protected IProgressIndicator getIProgressIndicator()
- {
- return appJmolWindow.progressBar;
+ setViewer(appJmol);
}
@Override
@Override
public void run()
{
- appJmolWindow.updateTitleAndMenus();
- appJmolWindow.revalidate();
+ JalviewStructureDisplayI theViewer = getViewer();
+ theViewer.updateTitleAndMenus();
+ ((JComponent) theViewer).revalidate();
}
});
}
{
AlignmentPanel ap = (AlignmentPanel) source;
// ignore events from panels not used to colour this view
- if (!appJmolWindow.isUsedforcolourby(ap))
+ if (!getViewer().isUsedForColourBy(ap))
{
return;
}
@Override
public void showConsole(boolean b)
{
- appJmolWindow.showConsole(b);
+ getViewer().showConsole(b);
}
@Override
protected JmolAppConsoleInterface createJmolConsole(
Container consolePanel, String buttonsToShow)
{
- viewer.setJmolCallbackListener(this);
- return new AppConsole(viewer, consolePanel, buttonsToShow);
+ jmolViewer.setJmolCallbackListener(this);
+ return new AppConsole(jmolViewer, consolePanel, buttonsToShow);
}
@Override
protected void releaseUIResources()
{
- appJmolWindow = null;
+ setViewer(null);
closeConsole();
}
{
if (svl instanceof SeqPanel)
{
- appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);
+ getViewer().removeAlignmentPanel(((SeqPanel) svl).ap);
}
}
// TODO Auto-generated method stub
return null;
}
-
- @Override
- public JalviewStructureDisplayI getViewer()
- {
- return appJmolWindow;
- }
-
- @Override
- public jalview.api.FeatureRenderer getFeatureRenderer(
- AlignmentViewPanel alignment)
- {
- AlignmentPanel ap = (alignment == null)
- ? appJmolWindow.getAlignmentPanel()
- : (AlignmentPanel) alignment;
- if (ap.av.isShowSequenceFeatures())
- {
- return ap.av.getAlignPanel().getSeqPanel().seqCanvas.fr;
- }
-
- return null;
- }
}
*/
package jalview.gui;
+import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Random;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JInternalFrame;
{
private JalviewChimeraBinding jmb;
- private IProgressIndicator progressBar = null;
-
/*
* Path to Chimera session file. This is set when an open Jalview/Chimera
* session is saved, or on restore from a Jalview project (if it holds the
*/
private String chimeraSessionFile = null;
- private Random random = new Random();
-
private int myWidth = 500;
private int myHeight = 150;
*/
protected void createProgressBar()
{
- if (progressBar == null)
+ if (getProgressIndicator() == null)
{
- progressBar = new ProgressBar(statusPanel, statusBar);
+ setProgressIndicator(new ProgressBar(statusPanel, statusBar));
}
}
pdb = jmb.getSsm().setMapping(jmb.getSequence()[pos],
jmb.getChains()[pos], pe.getFile(), protocol,
- progressBar);
+ getProgressIndicator());
stashFoundChains(pdb, pe.getFile());
} catch (OutOfMemoryError oomerror)
}
// refresh the sequence colours for the new structure(s)
- for (AlignmentPanel ap : _colourwith)
+ for (AlignmentViewPanel ap : _colourwith)
{
jmb.updateColours(ap);
}
return filePath;
}
- /**
- * Convenience method to update the progress bar if there is one. Be sure to
- * call stopProgressBar with the returned handle to remove the message.
- *
- * @param msg
- * @param handle
- */
- public long startProgressBar(String msg)
- {
- // TODO would rather have startProgress/stopProgress as the
- // IProgressIndicator interface
- long tm = random.nextLong();
- if (progressBar != null)
- {
- progressBar.setProgressBar(msg, tm);
- }
- return tm;
- }
-
- /**
- * End the progress bar with the specified handle, leaving a message (if not
- * null) on the status bar
- *
- * @param msg
- * @param handle
- */
- public void stopProgressBar(String msg, long handle)
- {
- if (progressBar != null)
- {
- progressBar.setProgressBar(msg, handle);
- }
- }
-
@Override
public void eps_actionPerformed(ActionEvent e)
{
}
return reply;
}
-
- @Override
- protected IProgressIndicator getIProgressIndicator()
- {
- return progressBar;
- }
}
import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
import jalview.io.DataSourceType;
import jalview.structure.StructureSelectionManager;
-import jalview.viewmodel.seqfeatures.FeatureRendererModel;
+import javax.swing.JComponent;
import javax.swing.SwingUtilities;
public class JalviewChimeraBindingModel extends JalviewChimeraBinding
{
- private ChimeraViewFrame cvf;
-
public JalviewChimeraBindingModel(ChimeraViewFrame chimeraViewFrame,
StructureSelectionManager ssm, PDBEntry[] pdbentry,
SequenceI[][] sequenceIs, DataSourceType protocol)
{
super(ssm, pdbentry, sequenceIs, protocol);
- cvf = chimeraViewFrame;
- }
-
- @Override
- public FeatureRendererModel getFeatureRenderer(AlignmentViewPanel alignment)
- {
- AlignmentPanel ap = (alignment == null) ? cvf.getAlignmentPanel()
- : (AlignmentPanel) alignment;
- if (ap.av.isShowSequenceFeatures())
- {
- return ap.getSeqPanel().seqCanvas.fr;
- }
-
- return null;
+ setViewer(chimeraViewFrame);
}
@Override
@Override
public void run()
{
- cvf.updateTitleAndMenus();
- cvf.revalidate();
+ JalviewStructureDisplayI theViewer = getViewer();
+ theViewer.updateTitleAndMenus();
+ ((JComponent) theViewer).revalidate();
}
});
}
@Override
public void updateColours(Object source)
{
- AlignmentPanel ap = (AlignmentPanel) source;
+ AlignmentViewPanel ap = (AlignmentViewPanel) source;
// ignore events from panels not used to colour this view
- if (!cvf.isUsedforcolourby(ap))
+ if (!getViewer().isUsedForColourBy(ap))
{
return;
}
final String progressMsg)
{
final long handle = progressMsg == null ? 0
- : cvf.startProgressBar(progressMsg);
+ : getViewer().startProgressBar(progressMsg);
SwingUtilities.invokeLater(new Runnable()
{
@Override
{
if (progressMsg != null)
{
- cvf.stopProgressBar(null, handle);
+ getViewer().stopProgressBar(null, handle);
}
}
}
});
}
-
- @Override
- public JalviewStructureDisplayI getViewer()
- {
- return cvf;
- }
}
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Random;
import java.util.Vector;
import javax.swing.ButtonGroup;
/**
* list of alignment panels to use for superposition
*/
- protected Vector<AlignmentPanel> _alignwith = new Vector<>();
+ protected Vector<AlignmentViewPanel> _alignwith = new Vector<>();
/**
* list of alignment panels that are used for colouring structures by aligned
* sequences
*/
- protected Vector<AlignmentPanel> _colourwith = new Vector<>();
+ protected Vector<AlignmentViewPanel> _colourwith = new Vector<>();
private String viewId = null;
*/
protected volatile boolean seqColoursApplied = false;
+ private IProgressIndicator progressBar = null;
+
+ private Random random = new Random();
+
/**
* Default constructor
*/
return _aps.contains(ap2.av.getSequenceSetId());
}
- public boolean isUsedforaligment(AlignmentPanel ap2)
+ public boolean isUsedforaligment(AlignmentViewPanel ap2)
{
return (_alignwith != null) && _alignwith.contains(ap2);
}
- public boolean isUsedforcolourby(AlignmentPanel ap2)
+ @Override
+ public boolean isUsedForColourBy(AlignmentViewPanel ap2)
{
return (_colourwith != null) && _colourwith.contains(ap2);
}
}
}
+ @Override
public AlignmentPanel getAlignmentPanel()
{
return ap;
*
* @param nap
*/
- public void removeAlignmentPanel(AlignmentPanel nap)
+ @Override
+ public void removeAlignmentPanel(AlignmentViewPanel nap)
{
try
{
public abstract ViewerType getViewerType();
- protected abstract IProgressIndicator getIProgressIndicator();
-
/**
* add a new structure (with associated sequences and chains) to this viewer,
* retrieving it if necessary first.
* create the mappings
*/
apanel.getStructureSelectionManager().setMapping(seq, chains,
- pdbFilename, DataSourceType.FILE, getIProgressIndicator());
+ pdbFilename, DataSourceType.FILE, getProgressIndicator());
/*
* alert the FeatureRenderer to show new (PDB RESNUM) features
int[] alm = new int[_alignwith.size()];
int a = 0;
- for (AlignmentPanel alignPanel : _alignwith)
+ for (AlignmentViewPanel alignPanel : _alignwith)
{
- als[a] = alignPanel.av.getAlignment();
+ als[a] = alignPanel.getAlignment();
alm[a] = -1;
- alc[a++] = alignPanel.av.getAlignment().getHiddenColumns();
+ alc[a++] = alignPanel.getAlignment().getHiddenColumns();
}
reply = getBinding().superposeStructures(als, alm, alc);
if (reply != null)
} catch (Exception e)
{
StringBuffer sp = new StringBuffer();
- for (AlignmentPanel alignPanel : _alignwith)
+ for (AlignmentViewPanel alignPanel : _alignwith)
{
- sp.append("'" + alignPanel.alignFrame.getTitle() + "' ");
+ sp.append("'" + alignPanel.getViewName() + "' ");
}
Cache.log.info("Couldn't align structures with the " + sp.toString()
+ "associated alignment panels.", e);
}
}
// Set the colour using the current view for the associated alignframe
- for (AlignmentPanel alignPanel : _colourwith)
+ for (AlignmentViewPanel alignPanel : _colourwith)
{
binding.colourBySequence(alignPanel);
}
toFront();
}
+ @Override
+ public long startProgressBar(String msg)
+ {
+ // TODO would rather have startProgress/stopProgress as the
+ // IProgressIndicator interface
+ long tm = random.nextLong();
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(msg, tm);
+ }
+ return tm;
+ }
+
+ /**
+ * End the progress bar with the specified handle, leaving a message (if not
+ * null) on the status bar
+ *
+ * @param msg
+ * @param handle
+ */
+ public void stopProgressBar(String msg, long handle)
+ {
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(msg, handle);
+ }
+ }
+
+ @Override
+ public void stopProgressBar(Object object, long handle)
+ {
+ }
+
+ protected IProgressIndicator getProgressIndicator()
+ {
+ return progressBar;
+ }
+
+ protected void setProgressIndicator(IProgressIndicator pi)
+ {
+ progressBar = pi;
+ }
+
+ protected void setProgressMessage(String message, long id)
+ {
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(message, id);
+ }
+ }
+
+ @Override
+ public void showConsole(boolean show)
+ {
+ // default does nothing
+ }
+
}
*/
package jalview.gui;
+import jalview.api.AlignmentViewPanel;
import jalview.util.MessageManager;
import java.awt.Component;
private ViewSetProvider _allviews;
- private List<AlignmentPanel> _selectedviews;
+ private List<AlignmentViewPanel> _selectedviews;
private ItemListener _handler;
* selection/deselection state
*/
public ViewSelectionMenu(String title, final ViewSetProvider allviews,
- final List<AlignmentPanel> selectedviews,
+ final List<AlignmentViewPanel> selectedviews,
final ItemListener handler)
{
super(title);
final String viewId = viewFrame.getViewId();
state.setViewId(viewId);
state.setAlignwithAlignPanel(viewFrame.isUsedforaligment(ap));
- state.setColourwithAlignPanel(viewFrame.isUsedforcolourby(ap));
+ state.setColourwithAlignPanel(viewFrame.isUsedForColourBy(ap));
state.setColourByJmol(viewFrame.isColouredByViewer());
state.setType(viewFrame.getViewerType().toString());
// pdb.addStructureState(state);
package jalview.structures.models;
import jalview.api.AlignmentViewPanel;
+import jalview.api.FeatureRenderer;
import jalview.api.SequenceRenderer;
import jalview.api.StructureSelectionManagerProvider;
import jalview.api.structures.JalviewStructureDisplayI;
extends SequenceStructureBindingModel
implements StructureListener, StructureSelectionManagerProvider
{
+ /*
+ * the Jalview panel through which the user interacts
+ * with the structure viewer
+ */
+ private JalviewStructureDisplayI viewer;
private StructureSelectionManager ssm;
{ Integer.valueOf(pe).toString() }));
}
final String nullChain = "TheNullChain";
- List<SequenceI> s = new ArrayList<SequenceI>();
- List<String> c = new ArrayList<String>();
+ List<SequenceI> s = new ArrayList<>();
+ List<String> c = new ArrayList<>();
if (getChains() == null)
{
setChains(new String[getPdbCount()][]);
public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe,
SequenceI[][] seq, String[][] chns)
{
- List<PDBEntry> v = new ArrayList<PDBEntry>();
- List<int[]> rtn = new ArrayList<int[]>();
+ List<PDBEntry> v = new ArrayList<>();
+ List<int[]> rtn = new ArrayList<>();
for (int i = 0; i < getPdbCount(); i++)
{
v.add(getPdbEntry(i));
*/
public JalviewStructureDisplayI getViewer()
{
- return null;
+ return viewer;
+ }
+
+ public void setViewer(JalviewStructureDisplayI v)
+ {
+ viewer = v;
}
public abstract void setJalviewColourScheme(ColourSchemeI cs);
return fileLoadingError != null && fileLoadingError.length() > 0;
}
- public abstract jalview.api.FeatureRenderer getFeatureRenderer(
- AlignmentViewPanel alignment);
+ /**
+ * Returns the FeatureRenderer for the given alignment view, or null if
+ * feature display is turned off in the view.
+ *
+ * @param avp
+ * @return
+ */
+ public FeatureRenderer getFeatureRenderer(AlignmentViewPanel avp)
+ {
+ AlignmentViewPanel ap = (avp == null) ? getViewer().getAlignmentPanel()
+ : avp;
+ return ap.getAlignViewport().isShowSequenceFeatures()
+ ? ap.getFeatureRenderer()
+ : null;
+ }
}
import static org.testng.AssertJUnit.assertTrue;
import jalview.api.AlignmentViewPanel;
-import jalview.api.FeatureRenderer;
import jalview.api.SequenceRenderer;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
}
@Override
- public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
String[] files, SequenceRenderer sr, AlignmentViewPanel avp)
{
public void colourByCharge()
{
}
-
- @Override
- public FeatureRenderer getFeatureRenderer(
- AlignmentViewPanel alignment)
- {
- return null;
- }
};
}