import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
import java.util.Vector;
public class AppletJmol extends EmbmenuFrame implements
AlignmentPanel ap;
- ArrayList _aps = new ArrayList();
+ List<AlignmentPanel> _aps = new ArrayList<AlignmentPanel>(); // remove? never
+ // added to
String fileLoadingError;
dispose();
return;
}
- jmb.newJmolPopup(true, "Jmol", true);
+ // jmb.newJmolPopup(true, "Jmol", true);
this.addWindowListener(new WindowAdapter()
{
jmb.loadInline(string);
}
- void setChainMenuItems(Vector chains)
+ void setChainMenuItems(Vector<String> chains)
{
chainMenu.removeAll();
chainMenu.add(menuItem);
CheckboxMenuItem menuItemCB;
- for (int c = 0; c < chains.size(); c++)
+ for (String ch : chains)
{
- menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(),
- true);
+ menuItemCB = new CheckboxMenuItem(ch, true);
menuItemCB.addItemListener(this);
chainMenu.add(menuItemCB);
}
void centerViewer()
{
- Vector toshow = new Vector();
- String lbl;
- int mlength, p, mnum;
+ Vector<String> toshow = new Vector<String>();
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof CheckboxMenuItem)
else if (evt.getSource() == seqColour)
{
setEnabled(seqColour);
- jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+ jmb.colourBySequence(ap);
}
else if (!allChainsSelected)
{
public void updateColours(Object source)
{
- AlignmentPanel ap = (AlignmentPanel) source;
- jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+ AlignmentPanel panel = (AlignmentPanel) source;
+ jmb.colourBySequence(panel);
}
public void updateTitleAndMenus()
return;
}
setChainMenuItems(jmb.chainNames);
- jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+ jmb.colourBySequence(ap);
setTitle(jmb.getViewerTitle());
}
{
for (int i = 0; i < _aps.size(); i++)
{
- if (((AlignmentPanel) _aps.get(i)).av.getAlignment() == alignment)
+ if (_aps.get(i).av.getAlignment() == alignment)
{
- return ((AlignmentPanel) _aps.get(i));
+ return (_aps.get(i));
}
}
return ap;
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.console.AppletConsole;
import org.jmol.java.BS;
-import org.jmol.popup.JmolAwtPopup;
class AppletJmolBinding extends JalviewJmolBinding
{
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
- colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+ colourBySequence(ap);
}
public void showUrl(String url)
public void newJmolPopup(boolean translateLocale, String menuName,
boolean asPopup)
{
- jmolpopup = new JmolAwtPopup(); // is this used?
- jmolpopup.jpiInitialize((viewer), menuName);
-
+ // jmolpopup = new JmolAwtPopup(); // is this used?
+ // jmolpopup.jpiInitialize((viewer), menuName);
}
@Override
import org.jmol.api.JmolStatusListener;
import org.jmol.api.JmolViewer;
import org.jmol.c.CBK;
-import org.jmol.popup.JmolGenericPopup;
import org.jmol.script.T;
import org.jmol.viewer.JC;
import org.jmol.viewer.Viewer;
*/
private boolean associateNewStructs = false;
- Vector atomsPicked = new Vector();
+ Vector<String> atomsPicked = new Vector<String>();
- public Vector chainNames;
+ public Vector<String> chainNames;
- Hashtable chainFile;
-
- StringBuffer eval = new StringBuffer();
+ Hashtable<String, String> chainFile;
public String fileLoadingError;
*/
int frameNo = 0;
- protected JmolGenericPopup jmolpopup;
+ // protected JmolGenericPopup jmolpopup; // not used - remove?
String lastCommand;
* @param chainList
* list of chains to make visible
*/
- public void centerViewer(Vector chainList)
+ public void centerViewer(Vector<String> chainList)
{
- StringBuffer cmd = new StringBuffer();
- String lbl;
+ StringBuilder cmd = new StringBuilder(128);
int mlength, p;
- for (int i = 0, iSize = chainList.size(); i < iSize; i++)
+ for (String lbl : chainList)
{
mlength = 0;
- lbl = (String) chainList.elementAt(i);
do
{
p = mlength;
} while (p < mlength && mlength < (lbl.length() - 2));
// TODO: lookup each pdb id and recover proper model number for it.
cmd.append(":" + lbl.substring(mlength + 1) + " /"
- + (1 + getModelNum((String) chainFile.get(lbl))) + " or ");
+ + (1 + getModelNum(chainFile.get(lbl))) + " or ");
}
if (cmd.length() > 0)
{
jmolHistory(false);
if (lastCommand == null || !lastCommand.equals(command))
{
+ System.out.println(command);
viewer.evalStringQuiet(command + "\n");
}
jmolHistory(true);
* using the getFeatureRenderer() and getSequenceRenderer() renderers but only
* if colourBySequence is enabled.
*/
- public void colourBySequence(boolean showFeatures,
- jalview.api.AlignmentViewPanel alignmentv)
+ public void colourBySequence(AlignmentViewPanel alignmentv)
{
+ boolean showFeatures = alignmentv.getAlignViewport()
+ .isShowSequenceFeatures();
if (!colourBySequence || !isLoadingFinished())
{
return;
public void handlePopupMenu(int x, int y)
{
// jmolpopup.show(x, y);
- jmolpopup.jpiShow(x, y);
+ // jmolpopup.jpiShow(x, y);
}
/**
// look up file model number for this pdbfile
int mdlNum = 0;
- String fn;
// may need to adjust for URLencoding here - we don't worry about that yet.
while (mdlNum < modelFileNames.length
&& !pdbfile.equals(modelFileNames[mdlNum]))
{
- // System.out.println("nomatch:"+pdbfile+"\nmodelfn:"+fn);
mdlNum++;
}
if (mdlNum == modelFileNames.length)
viewer.evalStringQuiet(resetLastRes.toString());
}
- eval.setLength(0);
- eval.append("select " + pdbResNum); // +modelNum
+ StringBuilder cmd = new StringBuilder(64);
+ cmd.append("select " + pdbResNum); // +modelNum
resetLastRes.setLength(0);
resetLastRes.append("select " + pdbResNum); // +modelNum
- eval.append(":");
+ cmd.append(":");
resetLastRes.append(":");
if (!chain.equals(" "))
{
- eval.append(chain);
+ cmd.append(chain);
resetLastRes.append(chain);
}
{
- eval.append(" /" + (mdlNum + 1));
+ cmd.append(" /" + (mdlNum + 1));
resetLastRes.append("/" + (mdlNum + 1));
}
- eval.append(";wireframe 100;" + eval.toString() + " and not hetero;");
+ cmd.append(";wireframe 100;" + cmd.toString() + " and not hetero;");
resetLastRes.append(";wireframe 0;" + resetLastRes.toString()
+ " and not hetero; spacefill 0;");
- eval.append("spacefill 200;select none");
+ cmd.append("spacefill 200;select none");
- viewer.evalStringQuiet(eval.toString());
+ viewer.evalStringQuiet(cmd.toString());
jmolHistory(true);
}
fileLoadingError = null;
String[] oldmodels = modelFileNames;
modelFileNames = null;
- chainNames = new Vector();
- chainFile = new Hashtable();
+ chainNames = new Vector<String>();
+ chainFile = new Hashtable<String, String>();
boolean notifyLoaded = false;
String[] modelfilenames = getPdbFile();
// first check if we've lost any structures
String fileName = modelfilenames[modelnum];
boolean foundEntry = false;
MCview.PDBfile pdb = null;
- String pdbfile = null, pdbfhash = null;
+ String pdbfile = null;
// model was probably loaded inline - so check the pdb file hashcode
if (loadedInline)
{
// 'best guess'
pdbfile = viewer.getData("" + (1 + _modelFileNameMap[modelnum])
+ ".0", "PDB");
- pdbfhash = "" + pdbfile.hashCode();
}
// search pdbentries and sequences to find correct pdbentry for this
// model
}
// FILE LOADED OK
// so finally, update the jmol bits and pieces
- if (jmolpopup != null)
- {
- // potential for deadlock here:
- // jmolpopup.updateComputedMenus();
- }
+ // if (jmolpopup != null)
+ // {
+ // // potential for deadlock here:
+ // // jmolpopup.updateComputedMenus();
+ // }
if (!isLoadingFromArchive())
{
viewer.evalStringQuiet("model 0; select backbone;restrict;cartoon;wireframe off;spacefill off");
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
+import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Enumeration;
import java.util.Vector;
import javax.swing.JCheckBoxMenuItem;
return;
}
}
- // /////////////////////////////////
- // Check if there are other Jmol views involving this alignment
- // and prompt user about adding this molecule to one of them
- Vector existingViews = getJmolsFor(ap);
- if (existingViews.size() > 0)
+
+ /*
+ * Check if there are other Jmol views involving this alignment and prompt
+ * user about adding this molecule to one of them
+ */
+ for (AppJmol topJmol : getJmolsFor(ap))
{
- Enumeration jm = existingViews.elements();
- while (jm.hasMoreElements())
+ // TODO: highlight topJmol in view somehow
+ int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ MessageManager.formatMessage("label.add_pdbentry_to_view",
+ new String[]
+ { pdbentry.getId(), topJmol.getTitle() }),
+ MessageManager
+ .getString("label.align_to_existing_structure_view"),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
{
- AppJmol topJmol = (AppJmol) jm.nextElement();
- // TODO: highlight topJmol in view somehow
- int option = JOptionPane
- .showInternalConfirmDialog(
- Desktop.desktop,
- MessageManager.formatMessage(
- "label.add_pdbentry_to_view", new String[]
- { pdbentry.getId(), topJmol.getTitle() }),
- MessageManager
- .getString("label.align_to_existing_structure_view"),
- JOptionPane.YES_NO_CANCEL_OPTION);
- if (option == JOptionPane.CANCEL_OPTION)
- {
- return;
- }
- if (option == JOptionPane.YES_OPTION)
- {
- topJmol.useAlignmentPanelForSuperposition(ap);
- topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
- return;
- }
+ return;
+ }
+ if (option == JOptionPane.YES_OPTION)
+ {
+ topJmol.useAlignmentPanelForSuperposition(ap);
+ topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
+ return;
}
}
// /////////////////////////////////
return;
}
- private Vector getJmolsFor(AlignmentPanel apanel)
+ private Vector<AppJmol> getJmolsFor(AlignmentPanel apanel)
{
- Vector result = new Vector();
+ Vector<AppJmol> result = new Vector<AppJmol>();
JInternalFrame[] frames = Desktop.instance.getAllFrames();
for (JInternalFrame frame : frames)
{
if (frame instanceof AppJmol)
{
- if (((StructureViewerBase) frame).isLinkedWith(apanel))
+ if (((AppJmol) frame).isLinkedWith(apanel))
{
- result.addElement(frame);
+ result.addElement((AppJmol) frame);
}
}
}
scriptWindow = new JPanel(bl);
scriptWindow.setVisible(false);
}
- ;
+
jmb.allocateViewer(renderPanel, true, "", null, null, "", scriptWindow,
null);
- jmb.newJmolPopup("Jmol");
+ // jmb.newJmolPopup("Jmol");
if (command == null)
{
command = "";
jmb.setFinishedInit(true);
}
- void setChainMenuItems(Vector chains)
+ void setChainMenuItems(Vector<String> chains)
{
chainMenu.removeAll();
if (chains == null)
chainMenu.add(menuItem);
- for (int c = 0; c < chains.size(); c++)
+ for (String chain : chains)
{
- menuItem = new JCheckBoxMenuItem(chains.elementAt(c).toString(), true);
+ menuItem = new JCheckBoxMenuItem(chain, true);
menuItem.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent evt)
void centerViewer()
{
- Vector toshow = new Vector();
- String lbl;
- int mlength, p, mnum;
+ Vector<String> toshow = new Vector<String>();
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
// need to wait around until script has finished
while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
- : (jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
+ : (!jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
.getPdbFile().length != jmb.getPdbCount()))
{
try
{
}
}
+
// refresh the sequence colours for the new structure(s)
for (AlignmentPanel ap : _colourwith)
{
if (value == JalviewFileChooser.APPROVE_OPTION)
{
+ BufferedReader in = null;
try
{
// TODO: cope with multiple PDB files in view
- BufferedReader in = new BufferedReader(new FileReader(
+ in = new BufferedReader(new FileReader(
jmb.getPdbFile()[0]));
File outFile = chooser.getSelectedFile();
} catch (Exception ex)
{
ex.printStackTrace();
+ } finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ } catch (IOException e)
+ {
+ // ignore
+ }
+ }
}
}
}
// Set the colour using the current view for the associated alignframe
for (AlignmentPanel ap : _colourwith)
{
- jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+ jmb.colourBySequence(ap);
}
}
}
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.java.BS;
-import org.jmol.popup.JmolAwtPopup;
import org.openscience.jmol.app.jmolpanel.console.AppConsole;
public class AppJmolBinding extends JalviewJmolBinding
public void updateColours(Object source)
{
- AlignmentPanel ap = (AlignmentPanel) source, topap;
+ AlignmentPanel ap = (AlignmentPanel) source;
// ignore events from panels not used to colour this view
if (!appJmolWindow.isUsedforcolourby(ap))
{
}
if (!isLoadingFromArchive())
{
- colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+ colourBySequence(ap);
}
}
public void newJmolPopup(String menuName)
{
- jmolpopup = new JmolAwtPopup();
- jmolpopup.jpiInitialize((viewer), menuName);
+ // jmolpopup = new JmolAwtPopup();
+ // jmolpopup.jpiInitialize((viewer), menuName);
}
@Override