files)
{
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
- .getProperty("LAST_DIRECTORY"));
-
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Save PDB File");
- chooser.setToolTipText("Save");
-
- int value = chooser.showSaveDialog(this);
+ long lastnotify = jmb.getLoadNotifiesHandled();
+ StringBuilder fileList = new StringBuilder();
+ for (String s : files)
+ {
+ fileList.append(SPACE).append(BACKSLASH)
+ .append(Platform.escapeString(s)).append(BACKSLASH);
+ }
+ String filesString = fileList.toString();
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ if (!addingStructures)
{
try
{
- BufferedReader in = new BufferedReader(new FileReader(pdbentry
- .getFile()));
- File outFile = chooser.getSelectedFile();
-
- PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
- String data;
- while ((data = in.readLine()) != null)
- {
- if (!(data.indexOf("") > -1 || data.indexOf("
") > -1))
- {
- out.println(data);
- }
- }
- out.close();
+ initJmol("load FILES " + filesString);
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("When trying to open the Jmol viewer!", oomerror);
+ Cache.log.debug("File locations are " + filesString);
} catch (Exception ex)
{
- ex.printStackTrace();
+ Cache.log.error("Couldn't open Jmol viewer!", ex);
}
}
- }
-
- public void viewMapping_actionPerformed(ActionEvent actionEvent)
- {
- jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
- jalview.gui.Desktop.addInternalFrame(cap, "PDB - Sequence Mapping",
- 550, 600);
- cap.setText(StructureSelectionManager.getStructureSelectionManager()
- .printMapping(pdbentry.getFile()));
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- public void eps_actionPerformed(ActionEvent e)
- {
- makePDBImage(jalview.util.ImageMaker.EPS);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- public void png_actionPerformed(ActionEvent e)
- {
- makePDBImage(jalview.util.ImageMaker.PNG);
- }
-
- void makePDBImage(int type)
- {
- int width = getWidth();
- int height = getHeight();
-
- jalview.util.ImageMaker im;
-
- if (type == jalview.util.ImageMaker.PNG)
- {
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
- "Make PNG image from view", width, height, null, null);
- }
else
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
- "Make EPS file from view", width, height, null, this
- .getTitle());
- }
-
- if (im.getGraphics() != null)
- {
- Rectangle rect = new Rectangle(width, height);
- viewer.renderScreenImage(im.getGraphics(), rect.getSize(), rect);
- im.writeImage();
- }
- }
-
- public void seqColour_actionPerformed(ActionEvent actionEvent)
- {
- lastCommand = null;
- colourBySequence = seqColour.isSelected();
- colourBySequence(ap.alignFrame.alignPanel);
- }
-
- public void chainColour_actionPerformed(ActionEvent actionEvent)
- {
- colourBySequence = false;
- seqColour.setSelected(false);
- viewer.evalStringQuiet("select *;color chain");
- }
-
- public void chargeColour_actionPerformed(ActionEvent actionEvent)
- {
- colourBySequence = false;
- seqColour.setSelected(false);
- viewer.evalStringQuiet("select *;color white;select ASP,GLU;color red;"
- + "select LYS,ARG;color blue;select CYS;color yellow");
- }
-
- public void zappoColour_actionPerformed(ActionEvent actionEvent)
- {
- setJalviewColourScheme(new ZappoColourScheme());
- }
-
- public void taylorColour_actionPerformed(ActionEvent actionEvent)
- {
- setJalviewColourScheme(new TaylorColourScheme());
- }
-
- public void hydroColour_actionPerformed(ActionEvent actionEvent)
- {
- setJalviewColourScheme(new HydrophobicColourScheme());
- }
-
- public void helixColour_actionPerformed(ActionEvent actionEvent)
- {
- setJalviewColourScheme(new HelixColourScheme());
- }
-
- public void strandColour_actionPerformed(ActionEvent actionEvent)
- {
- setJalviewColourScheme(new StrandColourScheme());
- }
-
- public void turnColour_actionPerformed(ActionEvent actionEvent)
- {
- setJalviewColourScheme(new TurnColourScheme());
- }
-
- public void buriedColour_actionPerformed(ActionEvent actionEvent)
- {
- setJalviewColourScheme(new BuriedColourScheme());
- }
-
- public void setJalviewColourScheme(ColourSchemeI cs)
- {
- colourBySequence = false;
- seqColour.setSelected(false);
-
- if (cs == null)
- return;
-
- String res;
- int index;
- Color col;
-
- Enumeration en = ResidueProperties.aa3Hash.keys();
- StringBuffer command = new StringBuffer("select *;color white;");
- while (en.hasMoreElements())
- {
- res = en.nextElement().toString();
- index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue();
- if (index > 20)
- continue;
-
- col = cs.findColour(ResidueProperties.aa[index].charAt(0));
-
- command.append("select " + res + ";color[" + col.getRed() + ","
- + col.getGreen() + "," + col.getBlue() + "];");
- }
-
- viewer.evalStringQuiet(command.toString());
- }
-
- public void userColour_actionPerformed(ActionEvent actionEvent)
- {
- new UserDefinedColours(this, null);
- }
-
- public void backGround_actionPerformed(ActionEvent actionEvent)
- {
- java.awt.Color col = JColorChooser.showDialog(this,
- "Select Background Colour", null);
-
- if (col != null)
- {
- viewer.evalStringQuiet("background [" + col.getRed() + ","
- + col.getGreen() + "," + col.getBlue() + "];");
- }
- }
-
- public void jmolHelp_actionPerformed(ActionEvent actionEvent)
- {
- try
- {
- jalview.util.BrowserLauncher
- .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
- } catch (Exception ex)
- {
- }
- }
-
- // ////////////////////////////////
- // /StructureListener
- public String getPdbFile()
- {
- return pdbentry.getFile();
- }
-
- Pattern pattern = Pattern
- .compile("\\[(.*)\\]([0-9]+)(:[a-zA-Z]*)?\\.([a-zA-Z]+)(/[0-9]*)?");
+ StringBuilder cmd = new StringBuilder();
+ cmd.append("loadingJalviewdata=true\nload APPEND ");
+ cmd.append(filesString);
+ cmd.append("\nloadingJalviewdata=null");
+ final String command = cmd.toString();
+ lastnotify = jmb.getLoadNotifiesHandled();
- String lastMessage;
-
- public void mouseOverStructure(int atomIndex, String strInfo)
- {
- Matcher matcher = pattern.matcher(strInfo);
- matcher.find();
- matcher.group(1);
- int pdbResNum = Integer.parseInt(matcher.group(2));
- String chainId = matcher.group(3);
-
- if (chainId != null)
- chainId = chainId.substring(1, chainId.length());
- else
- {
- chainId = " ";
+ try
+ {
+ jmb.evalStateCommand(command);
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("When trying to add structures to the Jmol viewer!",
+ oomerror);
+ Cache.log.debug("File locations are " + filesString);
+ } catch (Exception ex)
+ {
+ Cache.log.error("Couldn't add files to Jmol viewer!", ex);
+ }
}
- if (lastMessage == null || !lastMessage.equals(strInfo))
+ // need to wait around until script has finished
+ int waitMax = JMOL_LOAD_TIMEOUT;
+ int waitFor = 35;
+ int waitTotal = 0;
+ while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
+ : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
+ .getPdbFile().length == files.size()))
{
- ssm.mouseOverStructure(pdbResNum, chainId, pdbentry.getFile());
+ try
+ {
+ Cache.log.debug("Waiting around for jmb notify.");
+ Thread.sleep(waitFor);
+ waitTotal += waitFor;
+ } catch (Exception e)
+ {
+ }
+ if (waitTotal > waitMax)
+ {
+ System.err
+ .println("Timed out waiting for Jmol to load files after "
+ + waitTotal + "ms");
+// System.err.println("finished: " + jmb.isFinishedInit()
+// + "; loaded: " + Arrays.toString(jmb.getPdbFile())
+// + "; files: " + files.toString());
+ jmb.getPdbFile();
+ break;
+ }
}
- lastMessage = strInfo;
- }
-
- StringBuffer resetLastRes = new StringBuffer();
- StringBuffer eval = new StringBuffer();
-
- public void highlightAtom(int atomIndex, int pdbResNum, String chain,
- String pdbfile)
- {
- if (!pdbfile.equals(pdbentry.getFile()))
- return;
-
- if (resetLastRes.length() > 0)
+ // refresh the sequence colours for the new structure(s)
+ for (AlignmentPanel ap : _colourwith)
{
- viewer.evalStringQuiet(resetLastRes.toString());
+ jmb.updateColours(ap);
}
-
- eval.setLength(0);
- eval.append("select " + pdbResNum);
-
- resetLastRes.setLength(0);
- resetLastRes.append("select " + pdbResNum);
-
- if (!chain.equals(" "))
+ // do superposition if asked to
+ if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
{
- eval.append(":" + chain);
- resetLastRes.append(":" + chain);
+ alignAddedStructures();
}
-
- eval.append(";wireframe 100;" + eval.toString() + ".CA;");
-
- resetLastRes.append(";wireframe 0;" + resetLastRes.toString()
- + ".CA;spacefill 0;");
-
- eval.append("spacefill 200;select none");
-
- viewer.evalStringQuiet(eval.toString());
- }
-
- public Color getColour(int atomIndex, int pdbResNum, String chain,
- String pdbfile)
- {
- if (!pdbfile.equals(pdbentry.getFile()))
- return null;
-
- return new Color(viewer.getAtomArgb(atomIndex));
+ addingStructures = false;
}
- public void updateColours(Object source)
- {
- colourBySequence((AlignmentPanel) source);
- }
-
- // End StructureListener
- // //////////////////////////
-
- String lastCommand;
-
- FeatureRenderer fr = null;
-
- public void colourBySequence(AlignmentPanel sourceap)
+ /**
+ * Queues a thread to align structures with Jalview alignments
+ */
+ void alignAddedStructures()
{
- this.ap = sourceap;
-
- if (!colourBySequence || ap.alignFrame.getCurrentView() != ap.av)
- return;
-
- StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());
-
- if (mapping.length < 1)
- return;
-
- SequenceRenderer sr = new SequenceRenderer(ap.av);
-
- boolean showFeatures = false;
-
- if (ap.av.showSequenceFeatures)
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
{
- showFeatures = true;
- if (fr == null)
+ @Override
+ public void run()
{
- fr = new jalview.gui.FeatureRenderer(ap);
+ if (jmb.viewer.isScriptExecuting())
+ {
+ SwingUtilities.invokeLater(this);
+ try
+ {
+ Thread.sleep(5);
+ } catch (InterruptedException q)
+ {
+ }
+ return;
+ }
+ else
+ {
+ alignStructs_withAllAlignPanels();
+ }
}
+ });
+ alignAddedStructures = false;
+ }
- fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());
- }
-
- StringBuffer command = new StringBuffer();
+ /**
+ * Retrieves and saves as file any modelled PDB entries for which we do not
+ * already have a file saved. Returns a list of absolute paths to structure
+ * files which were either retrieved, or already stored but not modelled in
+ * the structure viewer (i.e. files to add to the viewer display).
+ *
+ * @return
+ */
+ List fetchPdbFiles()
+ {
+ // todo - record which pdbids were successfully imported.
+ StringBuilder errormsgs = new StringBuilder();
- int lastPos = -1;
- for (int sp, s = 0; s < sequence.length; s++)
+ List files = new ArrayList();
+ String pdbid = "";
+ try
{
- for (int m = 0; m < mapping.length; m++)
+ String[] filesInViewer = jmb.getPdbFile();
+ // TODO: replace with reference fetching/transfer code (validate PDBentry
+ // as a DBRef?)
+ Pdb pdbclient = new Pdb();
+ for (int pi = 0; pi < jmb.getPdbCount(); pi++)
{
- if (mapping[m].getSequence() == sequence[s]
- && (sp = ap.av.alignment.findIndex(sequence[s])) > -1)
+ String file = jmb.getPdbEntry(pi).getFile();
+ if (file == null)
{
- SequenceI asp = ap.av.alignment.getSequenceAt(sp);
- for (int r = 0; r < asp.getLength(); r++)
+ // retrieve the pdb and store it locally
+ AlignmentI pdbseq = null;
+ pdbid = jmb.getPdbEntry(pi).getId();
+ long hdl = pdbid.hashCode() - System.currentTimeMillis();
+ if (progressBar != null)
{
- // No mapping to gaps in sequence.
- if (jalview.util.Comparison.isGap(asp.getCharAt(r)))
- {
- continue;
- }
- int pos = mapping[m].getPDBResNum(asp.findPosition(r));
-
- if (pos < 1 || pos == lastPos)
- continue;
-
- lastPos = pos;
-
- Color col = sr.getResidueBoxColour(asp, r);
-
- if (showFeatures)
- col = fr.findFeatureColour(col, asp, r);
-
- if (command.toString().endsWith(
- ":" + mapping[m].getChain() + ";color[" + col.getRed()
- + "," + col.getGreen() + "," + col.getBlue()
- + "]"))
+ progressBar.setProgressBar(MessageManager.formatMessage(
+ "status.fetching_pdb", new String[] { pdbid }), hdl);
+ }
+ try
+ {
+ pdbseq = pdbclient.getSequenceRecords(pdbid);
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ errormsgs.append("'").append(pdbid).append("'");
+ } finally
+ {
+ if (progressBar != null)
{
- command = condenseCommand(command, pos);
- continue;
+ progressBar.setProgressBar(
+ MessageManager.getString("label.state_completed"),
+ hdl);
}
-
- command.append(";select " + pos);
-
- if (!mapping[m].getChain().equals(" "))
+ }
+ if (pdbseq != null)
+ {
+ // just transfer the file name from the first sequence's first
+ // PDBEntry
+ file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
+ .elementAt(0).getFile()).getAbsolutePath();
+ jmb.getPdbEntry(pi).setFile(file);
+ files.add(file);
+ }
+ else
+ {
+ errormsgs.append("'").append(pdbid).append("' ");
+ }
+ }
+ else
+ {
+ if (filesInViewer != null && filesInViewer.length > 0)
+ {
+ addingStructures = true; // already files loaded.
+ for (int c = 0; c < filesInViewer.length; c++)
{
- command.append(":" + mapping[m].getChain());
+ if (filesInViewer[c].equals(file))
+ {
+ file = null;
+ break;
+ }
}
-
- command.append(";color[" + col.getRed() + "," + col.getGreen()
- + "," + col.getBlue() + "]");
-
}
- break;
+ if (file != null)
+ {
+ files.add(file);
+ }
}
}
- }
-
- if (lastCommand == null || !lastCommand.equals(command.toString()))
+ } catch (OutOfMemoryError oomerror)
{
- viewer.evalStringQuiet(command.toString());
- }
- lastCommand = command.toString();
- }
-
- StringBuffer condenseCommand(StringBuffer command, int pos)
- {
- StringBuffer sb = new StringBuffer(command.substring(0, command
- .lastIndexOf("select") + 7));
-
- command.delete(0, sb.length());
-
- String start;
-
- if (command.indexOf("-") > -1)
+ new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
+ } catch (Exception ex)
{
- start = command.substring(0, command.indexOf("-"));
+ ex.printStackTrace();
+ errormsgs.append("When retrieving pdbfiles : current was: '")
+ .append(pdbid).append("'");
}
- else
+ if (errormsgs.length() > 0)
{
- start = command.substring(0, command.indexOf(":"));
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
+ .formatMessage("label.pdb_entries_couldnt_be_retrieved",
+ new String[] { errormsgs.toString() }),
+ MessageManager.getString("label.couldnt_load_file"),
+ JvOptionPane.ERROR_MESSAGE);
}
-
- sb.append(start + "-" + pos + command.substring(command.indexOf(":")));
-
- return sb;
- }
-
- // ///////////////////////////////
- // JmolStatusListener
-
- public String eval(String strEval)
- {
- // System.out.println(strEval);
- // "# 'eval' is implemented only for the applet.";
- return null;
+ return files;
}
- public void createImage(String file, String type, int quality)
+ @Override
+ public void eps_actionPerformed(ActionEvent e)
{
- System.out.println("JMOL CREATE IMAGE");
+ makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
}
- public void setCallbackFunction(String callbackType,
- String callbackFunction)
+ @Override
+ public void png_actionPerformed(ActionEvent e)
{
+ makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
}
- public void notifyFileLoaded(String fullPathName, String fileName,
- String modelName, Object clientFile, String errorMsg)
+ void makePDBImage(jalview.util.ImageMaker.TYPE type)
{
- if (errorMsg != null)
- {
- fileLoadingError = errorMsg;
- repaint();
- return;
- }
+ int width = getWidth();
+ int height = getHeight();
- fileLoadingError = null;
+ jalview.util.ImageMaker im;
- if (fileName != null)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
-
- // FILE LOADED OK
- ssm = StructureSelectionManager.getStructureSelectionManager();
- MCview.PDBfile pdbFile = ssm.setMapping(sequence, chains, pdbentry
- .getFile(), AppletFormatAdapter.FILE);
- ssm.addStructureViewerListener(this);
- Vector chains = new Vector();
- for (int i = 0; i < pdbFile.chains.size(); i++)
- {
- chains
- .addElement(((MCview.PDBChain) pdbFile.chains.elementAt(i)).id);
- }
- setChainMenuItems(chains);
-
- jmolpopup.updateComputedMenus();
-
- if (!loadingFromArchive)
- {
- viewer
- .evalStringQuiet("select backbone;restrict;cartoon;wireframe off;spacefill off");
-
- colourBySequence(ap);
- }
- if (fr != null)
- fr.featuresAdded();
-
- loadingFromArchive = false;
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
+ width, height, null, null, null, 0, false);
}
- else
- return;
- }
-
- public void notifyFrameChanged(int frameNo)
- {
- boolean isAnimationRunning = (frameNo <= -2);
- }
-
- public void notifyScriptStart(String statusMessage, String additionalInfo)
- {
- }
-
- public void sendConsoleEcho(String strEcho)
- {
- if (scriptWindow != null)
- scriptWindow.sendConsoleEcho(strEcho);
- }
-
- public void sendConsoleMessage(String strStatus)
- {
- if (scriptWindow != null)
- scriptWindow.sendConsoleMessage(strStatus);
- }
-
- public void notifyScriptTermination(String strStatus, int msWalltime)
- {
- if (scriptWindow != null)
- scriptWindow.notifyScriptTermination(strStatus, msWalltime);
- }
-
- public void handlePopupMenu(int x, int y)
- {
- jmolpopup.show(x, y);
- }
-
- public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
- {
- notifyAtomPicked(iatom, strMeasure);
- }
-
- public void notifyNewDefaultModeMeasurement(int count, String strInfo)
- {
- }
-
- public void notifyAtomPicked(int atomIndex, String strInfo)
- {
- Matcher matcher = pattern.matcher(strInfo);
- matcher.find();
-
- matcher.group(1);
- String resnum = new String(matcher.group(2));
- String chainId = matcher.group(3);
-
- String picked = resnum;
-
- if (chainId != null)
- picked += (":" + chainId.substring(1, chainId.length()));
-
- picked += ".CA";
-
- if (!atomsPicked.contains(picked))
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
- if (chainId != null)
- viewer.evalString("select " + picked + ";label %n %r:%c");
- else
- viewer.evalString("select " + picked + ";label %n %r");
- atomsPicked.addElement(picked);
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
+ width, height, null, this.getTitle(), null, 0, false);
}
else
{
- viewer.evalString("select " + picked + ";label off");
- atomsPicked.removeElement(picked);
+
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
+ width, height, null, this.getTitle(), null, 0, false);
}
- if (scriptWindow != null)
+ if (im.getGraphics() != null)
{
- scriptWindow.sendConsoleMessage(strInfo);
- scriptWindow.sendConsoleMessage("\n");
+ jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
+ im.writeImage();
}
}
- public void notifyAtomHovered(int atomIndex, String strInfo)
- {
- mouseOverStructure(atomIndex, strInfo);
- }
-
- public void sendSyncScript(String script, String appletName)
- {
- }
-
- public void showUrl(String url)
+ @Override
+ public void showHelp_actionPerformed(ActionEvent actionEvent)
{
+ try
+ {
+ BrowserLauncher
+ .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
+ } catch (Exception ex)
+ {
+ }
}
public void showConsole(boolean showConsole)
{
- if (scriptWindow == null)
- scriptWindow = new ScriptWindow(this);
if (showConsole)
{
@@ -929,15 +655,19 @@ public class AppJmol extends GStructureViewer implements StructureListener,
splitPane.setTopComponent(renderPanel);
splitPane.setBottomComponent(scriptWindow);
this.getContentPane().add(splitPane, BorderLayout.CENTER);
+ splitPane.setDividerLocation(getHeight() - 200);
+ scriptWindow.setVisible(true);
+ scriptWindow.validate();
+ splitPane.validate();
}
- splitPane.setDividerLocation(getHeight() - 200);
- splitPane.validate();
}
else
{
if (splitPane != null)
+ {
splitPane.setVisible(false);
+ }
splitPane = null;
@@ -947,58 +677,79 @@ public class AppJmol extends GStructureViewer implements StructureListener,
validate();
}
- public float functionXY(String functionName, int x, int y)
- {
- return 0;
- }
-
- // /End JmolStatusListener
- // /////////////////////////////
-
class RenderPanel extends JPanel
{
final Dimension currentSize = new Dimension();
- final Rectangle rectClip = new Rectangle();
-
+ @Override
public void paintComponent(Graphics g)
{
getSize(currentSize);
- g.getClipBounds(rectClip);
- if (viewer == null)
+ if (jmb != null && jmb.hasFileLoadingError())
{
g.setColor(Color.black);
g.fillRect(0, 0, currentSize.width, currentSize.height);
g.setColor(Color.white);
g.setFont(new Font("Verdana", Font.BOLD, 14));
- g.drawString("Retrieving PDB data....", 20, currentSize.height / 2);
+ g.drawString(MessageManager.getString("label.error_loading_file")
+ + "...", 20, currentSize.height / 2);
+ StringBuffer sb = new StringBuffer();
+ int lines = 0;
+ for (int e = 0; e < jmb.getPdbCount(); e++)
+ {
+ sb.append(jmb.getPdbEntry(e).getId());
+ if (e < jmb.getPdbCount() - 1)
+ {
+ sb.append(",");
+ }
+
+ if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
+ {
+ lines++;
+ g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
+ * g.getFontMetrics().getHeight());
+ }
+ }
}
- else if (fileLoadingError != null)
+ else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
{
g.setColor(Color.black);
g.fillRect(0, 0, currentSize.width, currentSize.height);
g.setColor(Color.white);
g.setFont(new Font("Verdana", Font.BOLD, 14));
- g.drawString("Error loading file..." + pdbentry.getId(), 20,
- currentSize.height / 2);
+ g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
+ 20, currentSize.height / 2);
}
else
{
- viewer.renderScreenImage(g, currentSize, rectClip);
+ jmb.viewer.renderScreenImage(g, currentSize.width,
+ currentSize.height);
}
}
}
- String viewId = null;
+ @Override
+ public AAStructureBindingModel getBinding()
+ {
+ return this.jmb;
+ }
- public String getViewId()
+ @Override
+ public String getStateInfo()
{
- if (viewId == null)
- {
- viewId = System.currentTimeMillis() + "." + this.hashCode();
- }
- return viewId;
+ return jmb == null ? null : jmb.viewer.getStateInfo();
+ }
+
+ @Override
+ public ViewerType getViewerType()
+ {
+ return ViewerType.JMOL;
}
+ @Override
+ protected String getViewerName()
+ {
+ return "Jmol";
+ }
}