jmol added
authoramwaterhouse <Andrew Waterhouse>
Tue, 27 Feb 2007 13:27:58 +0000 (13:27 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 27 Feb 2007 13:27:58 +0000 (13:27 +0000)
src/jalview/appletgui/AppletJmol.java [new file with mode: 0644]
src/jalview/commands/SlideSequencesCommand.java [new file with mode: 0644]
src/jalview/gui/AppJMol.java [new file with mode: 0644]
src/jalview/gui/ScriptWindow.java [new file with mode: 0644]
src/jalview/jbgui/GStructureViewer.java [new file with mode: 0644]

diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java
new file mode 100644 (file)
index 0000000..b03775b
--- /dev/null
@@ -0,0 +1,590 @@
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
+\r
+package jalview.appletgui;\r
+\r
+import java.util.*;\r
+import java.awt.*;\r
+import java.awt.event.*;\r
+\r
+import jalview.datamodel.*;\r
+import jalview.structure.*;\r
+import jalview.io.*;\r
+\r
+import org.jmol.api.*;\r
+import org.jmol.adapter.smarter.SmarterJmolAdapter;\r
+import org.jmol.popup.*;\r
+\r
+\r
+public class AppletJmol extends Frame\r
+    implements  StructureListener, JmolStatusListener,\r
+    KeyListener, ActionListener, ItemListener\r
+\r
+{\r
+  Menu fileMenu = new Menu("File");\r
+  Menu viewMenu = new Menu("View");\r
+  Menu chainMenu = new Menu("Show Chain");\r
+  MenuItem mappingMenuItem = new MenuItem("View Mapping");\r
+\r
+  JmolViewer viewer;\r
+  JmolPopup jmolpopup;\r
+\r
+  Panel scriptWindow;\r
+  TextField inputLine;\r
+  TextArea history;\r
+  SequenceI[] sequence;\r
+  StructureSelectionManager ssm;\r
+  RenderPanel renderPanel;\r
+  AlignmentPanel ap;\r
+  String fileLoadingError;\r
+  boolean loadedInline;\r
+  PDBEntry pdbentry;\r
+\r
+  public AppletJmol(PDBEntry pdbentry,\r
+                    SequenceI[] seq,\r
+                    AlignmentPanel ap,\r
+                    String protocol)\r
+  {\r
+    this.ap = ap;\r
+    this.sequence = seq;\r
+    this.pdbentry = pdbentry;\r
+\r
+   String alreadyMapped = StructureSelectionManager\r
+        .getStructureSelectionManager()\r
+        .alreadyMappedToFile(pdbentry.getId());\r
+\r
+    if (alreadyMapped != null)\r
+    {\r
+       StructureSelectionManager.getStructureSelectionManager()\r
+            .setMapping(seq, pdbentry.getFile(), protocol);\r
+        return;\r
+    }\r
+\r
+    renderPanel = new RenderPanel();\r
+\r
+    this.add(renderPanel, BorderLayout.CENTER);\r
+\r
+    viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter());\r
+\r
+    viewer.setAppletContext("jalview",\r
+                       ap.av.applet.getDocumentBase(),\r
+                            ap.av.applet.getCodeBase(),\r
+                            null);\r
+\r
+    viewer.setJmolStatusListener(this);\r
+\r
+    jmolpopup = JmolPopup.newJmolPopup(viewer);\r
+\r
+    this.addWindowListener(new WindowAdapter()\r
+        {\r
+          public void windowClosing(WindowEvent evt)\r
+          {\r
+            closeViewer();\r
+          }\r
+        });\r
+\r
+    MenuBar menuBar = new MenuBar();\r
+    menuBar.add(fileMenu);\r
+    fileMenu.add(mappingMenuItem);\r
+    menuBar.add(viewMenu);\r
+    mappingMenuItem.addActionListener(this);\r
+    viewMenu.add(chainMenu);\r
+    this.setMenuBar(menuBar);\r
+\r
+    if(pdbentry.getFile()!=null)\r
+    {\r
+      if (protocol.equals(AppletFormatAdapter.PASTE))\r
+        loadInline(pdbentry.getFile());\r
+      else\r
+          viewer.openFile(pdbentry.getFile());\r
+    }\r
+\r
+    this.setBounds(400, 400, 400, 400);\r
+\r
+    this.setVisible(true);\r
+  }\r
+\r
+  public void loadInline(String string)\r
+  {\r
+    loadedInline = true;\r
+    viewer.openStringInline(string);\r
+  }\r
+\r
+\r
+  void setChainMenuItems(Vector chains)\r
+  {\r
+    chainMenu.removeAll();\r
+\r
+    MenuItem menuItem = new MenuItem("All");\r
+    menuItem.addActionListener(this);\r
+\r
+    chainMenu.add(menuItem);\r
+\r
+    CheckboxMenuItem menuItemCB;\r
+    for (int c = 0; c < chains.size(); c++)\r
+    {\r
+      menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(), true);\r
+      menuItemCB.addItemListener(this);\r
+      chainMenu.add(menuItemCB);\r
+    }\r
+  }\r
+\r
+  boolean allChainsSelected = false;\r
+  void centerViewer()\r
+  {\r
+    StringBuffer cmd = new StringBuffer();\r
+    for (int i = 0; i < chainMenu.getItemCount(); i++)\r
+    {\r
+      if (chainMenu.getItem(i) instanceof CheckboxMenuItem)\r
+      {\r
+        CheckboxMenuItem item = (CheckboxMenuItem) chainMenu.getItem(i);\r
+        if (item.getState())\r
+          cmd.append(":" + item.getLabel() + " or ");\r
+      }\r
+    }\r
+\r
+    if (cmd.length() > 0)\r
+      cmd.setLength(cmd.length() - 4);\r
+\r
+    viewer.evalString("select *;restrict "\r
+                      + cmd + ";cartoon;center " + cmd);\r
+  }\r
+\r
+\r
+  void closeViewer()\r
+  {\r
+    viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE);\r
+    viewer.evalStringQuiet("zap");\r
+    viewer.setJmolStatusListener(null);\r
+    viewer = null;\r
+\r
+    //We'll need to find out what other\r
+    // listeners need to be shut down in Jmol\r
+    StructureSelectionManager\r
+        .getStructureSelectionManager()\r
+        .removeStructureViewerListener(this, pdbentry.getId());\r
+\r
+    this.setVisible(false);\r
+  }\r
+\r
+  public void actionPerformed(ActionEvent evt)\r
+  {\r
+    if(evt.getSource()==mappingMenuItem)\r
+    {\r
+      jalview.appletgui.CutAndPasteTransfer cap\r
+          = new jalview.appletgui.CutAndPasteTransfer(false, null);\r
+      Frame frame = new Frame();\r
+      frame.add(cap);\r
+\r
+      jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", 550,\r
+                                       600);\r
+      cap.setText(\r
+          StructureSelectionManager.getStructureSelectionManager().printMapping(\r
+              pdbentry.getFile())\r
+          );\r
+    }\r
+    else\r
+    {\r
+      allChainsSelected = true;\r
+      for (int i = 0; i < chainMenu.getItemCount(); i++)\r
+      {\r
+        if (chainMenu.getItem(i) instanceof CheckboxMenuItem)\r
+          ( (CheckboxMenuItem) chainMenu.getItem(i)).setState(true);\r
+      }\r
+      centerViewer();\r
+      allChainsSelected = false;\r
+    }\r
+  }\r
+\r
+  public void itemStateChanged(ItemEvent evt)\r
+  {\r
+    if (!allChainsSelected)\r
+      centerViewer();\r
+  }\r
+\r
+  public void keyPressed(KeyEvent evt)\r
+  {\r
+    if (evt.getKeyCode() == KeyEvent.VK_ENTER\r
+        && scriptWindow.isVisible())\r
+    {\r
+      viewer.evalString(inputLine.getText());\r
+\r
+      history.append("\n"+inputLine.getText());\r
+\r
+      inputLine.setText("");\r
+    }\r
+\r
+  }\r
+\r
+  public void keyTyped(KeyEvent evt)\r
+  {  }\r
+\r
+  public void keyReleased(KeyEvent evt){}\r
+\r
+  //////////////////////////////////\r
+  ///StructureListener\r
+  public String getPdbFile()\r
+  {\r
+    return "???";\r
+  }\r
+\r
+\r
+\r
+  String lastMessage;\r
+  public void mouseOverStructure(int atomIndex, String strInfo)\r
+  {\r
+      int pdbResNum = Integer.parseInt(\r
+          strInfo.substring(strInfo.indexOf("]")+ 1, strInfo.indexOf(":")));\r
+\r
+      String chainId = strInfo.substring\r
+          (strInfo.indexOf(":"), strInfo.indexOf("."));\r
+\r
+      if (chainId != null)\r
+        chainId = chainId.substring(1, chainId.length());\r
+      else\r
+      {\r
+        chainId = " ";\r
+      }\r
+\r
+      if (lastMessage == null || !lastMessage.equals(strInfo))\r
+        ssm.mouseOverStructure(pdbResNum, chainId, pdbentry.getFile());\r
+\r
+      lastMessage = strInfo;\r
+  }\r
+\r
+  StringBuffer resetLastRes = new StringBuffer();\r
+  StringBuffer eval = new StringBuffer();\r
+\r
+  public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile)\r
+  {\r
+    if (!pdbfile.equals(pdbentry.getFile()))\r
+      return;\r
+\r
+    if (resetLastRes.length() > 0)\r
+    {\r
+      viewer.evalStringQuiet(resetLastRes.toString());\r
+    }\r
+\r
+    eval.setLength(0);\r
+    eval.append("select " + pdbResNum);\r
+\r
+    resetLastRes.setLength(0);\r
+    resetLastRes.append("select " + pdbResNum);\r
+\r
+    if (!chain.equals(" "))\r
+    {\r
+      eval.append(":" + chain);\r
+      resetLastRes.append(":" + chain);\r
+    }\r
+\r
+    eval.append(";color gold;wireframe 100");\r
+\r
+    Color col = new Color(viewer.getAtomArgb(atomIndex));\r
+\r
+    resetLastRes.append(";color["\r
+                        + col.getRed() + ","\r
+                        + col.getGreen() + ","\r
+                        + col.getBlue() + "];wireframe 0");\r
+\r
+    viewer.evalStringQuiet(eval.toString());\r
+\r
+  }\r
+\r
+  public void updateColours(Object source)\r
+  {\r
+    colourBySequence( (AlignmentPanel) source);\r
+  }\r
+\r
+//End StructureListener\r
+////////////////////////////\r
+\r
+  FeatureRenderer fr;\r
+  public void colourBySequence(AlignmentPanel ap)\r
+  {\r
+    StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());\r
+\r
+    if (mapping.length < 1)\r
+      return;\r
+\r
+    SequenceRenderer sr = ap.seqPanel.seqCanvas.getSequenceRenderer();\r
+\r
+    boolean showFeatures = false;\r
+    if (ap.av.showSequenceFeatures)\r
+    {\r
+      showFeatures = true;\r
+      if (fr == null)\r
+      {\r
+        fr = new jalview.appletgui.FeatureRenderer(ap.av);\r
+      }\r
+\r
+      fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());\r
+    }\r
+\r
+    StringBuffer command = new StringBuffer();\r
+\r
+    for (int s = 0; s < sequence.length; s++)\r
+    {\r
+      for (int m = 0; m < mapping.length; m++)\r
+      {\r
+        if (mapping[m].getSequence() == sequence[s])\r
+        {\r
+          for (int r = 0; r < sequence[s].getLength(); r++)\r
+          {\r
+            int pos = mapping[m].getPDBResNum(\r
+                sequence[s].findPosition(r));\r
+\r
+            if (pos < 1)\r
+              continue;\r
+\r
+            command.append(";select " + pos);\r
+\r
+            if (!mapping[m].getChain().equals(" "))\r
+            {\r
+              command.append(":" + mapping[m].getChain());\r
+            }\r
+\r
+            Color col = sr.getResidueBoxColour(sequence[s], r);\r
+\r
+            if (showFeatures)\r
+              col = fr.findFeatureColour(col, sequence[s], r);\r
+\r
+            command.append("; color ["\r
+                           + col.getRed() + ","\r
+                           + col.getGreen() + ","\r
+                           + col.getBlue() + "]");\r
+\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    viewer.evalStringQuiet(command.toString());\r
+  }\r
+\r
+  /////////////////////////////////\r
+  //JmolStatusListener\r
+\r
+  public String eval(String strEval)\r
+  {\r
+   // System.out.println(strEval);\r
+   //"# 'eval' is implemented only for the applet.";\r
+    return null;\r
+  }\r
+\r
+  public void createImage(String file, String type, int quality)\r
+  {\r
+    System.out.println("JMOL CREATE IMAGE");\r
+  }\r
+\r
+  public void setCallbackFunction(String callbackType,\r
+                                  String callbackFunction)\r
+  {}\r
+\r
+  public void notifyFileLoaded(String fullPathName, String fileName,\r
+                               String modelName, Object clientFile,\r
+                               String errorMsg)\r
+  {\r
+    if(errorMsg!=null)\r
+    {\r
+      fileLoadingError = errorMsg;\r
+      repaint();\r
+      return;\r
+    }\r
+\r
+    fileLoadingError = null;\r
+\r
+    if (fileName != null)\r
+    {\r
+      //FILE LOADED OK\r
+      jmolpopup.updateComputedMenus();\r
+            viewer.evalStringQuiet(\r
+          "select backbone;restrict;cartoon;wireframe off;spacefill off");\r
+\r
+      ssm = StructureSelectionManager.getStructureSelectionManager();\r
+\r
+      MCview.PDBfile pdb;\r
+      if (loadedInline)\r
+      {\r
+        pdb = ssm.setMapping(sequence,\r
+                                pdbentry.getFile(),\r
+                                AppletFormatAdapter.PASTE);\r
+        pdbentry.setFile("INLINE"+pdb.id);\r
+\r
+      }\r
+      else\r
+      {\r
+         pdb = ssm.setMapping(sequence,\r
+                              pdbentry.getFile(),\r
+                              AppletFormatAdapter.URL);\r
+      }\r
+\r
+      pdbentry.setId(pdb.id);\r
+\r
+      ssm.addStructureViewerListener(this);\r
+\r
+      Vector chains = new Vector();\r
+      for (int i = 0; i < pdb.chains.size(); i++)\r
+      {\r
+        chains.addElement( ( (MCview.PDBChain) pdb.chains.elementAt(i)).id);\r
+      }\r
+      setChainMenuItems(chains);\r
+\r
+      colourBySequence(ap);\r
+\r
+      StringBuffer title = new StringBuffer(sequence[0].getName() + ":" +\r
+                                            pdbentry.getId());\r
+\r
+      if (pdbentry.getProperty() != null)\r
+      {\r
+        if (pdbentry.getProperty().get("method") != null)\r
+        {\r
+          title.append(" Method: ");\r
+          title.append(pdbentry.getProperty().get("method"));\r
+        }\r
+        if (pdbentry.getProperty().get("chains") != null)\r
+        {\r
+          title.append(" Chain:");\r
+          title.append(pdbentry.getProperty().get("chains"));\r
+        }\r
+      }\r
+\r
+      this.setTitle(title.toString());\r
+\r
+    }\r
+    else\r
+      return;\r
+  }\r
+\r
+  public void notifyFrameChanged(int frameNo)\r
+  {\r
+    boolean isAnimationRunning = (frameNo <= -2);\r
+  }\r
+\r
+  public void notifyScriptStart(String statusMessage, String additionalInfo)\r
+  {}\r
+\r
+  public void sendConsoleEcho(String strEcho)\r
+  {\r
+  //  if (scriptWindow != null)\r
+   //   scriptWindow.sendConsoleEcho(strEcho);\r
+  }\r
+\r
+  public void sendConsoleMessage(String strStatus)\r
+  {\r
+   // if (scriptWindow != null)\r
+   //   scriptWindow.sendConsoleMessage(strStatus);\r
+  }\r
+\r
+  public void notifyScriptTermination(String strStatus, int msWalltime)\r
+  {\r
+  //  if (scriptWindow != null)\r
+  //    scriptWindow.notifyScriptTermination(strStatus, msWalltime);\r
+  }\r
+\r
+  public void handlePopupMenu(int x, int y)\r
+  {\r
+    jmolpopup.show(x, y);\r
+  }\r
+\r
+  public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)\r
+  {\r
+    notifyAtomPicked(iatom, strMeasure);\r
+  }\r
+\r
+  public void notifyNewDefaultModeMeasurement(int count, String strInfo)\r
+  {}\r
+\r
+  public void notifyAtomPicked(int atomIndex, String strInfo)\r
+  {\r
+   // if (scriptWindow != null)\r
+    {\r
+   //   scriptWindow.sendConsoleMessage(strInfo);\r
+   //   scriptWindow.sendConsoleMessage("\n");\r
+    }\r
+  }\r
+\r
+  public void notifyAtomHovered(int atomIndex, String strInfo)\r
+  {\r
+    mouseOverStructure(atomIndex, strInfo);\r
+  }\r
+\r
+  public void sendSyncScript(String script, String appletName)\r
+  {}\r
+\r
+  public void showUrl(String url)\r
+  {}\r
+\r
+  public void showConsole(boolean showConsole)\r
+  {\r
+    if (scriptWindow == null)\r
+    {\r
+      scriptWindow = new Panel(new BorderLayout());\r
+      inputLine = new TextField();\r
+      history = new TextArea(5, 40);\r
+      scriptWindow.add(history, BorderLayout.CENTER);\r
+      scriptWindow.add(inputLine, BorderLayout.SOUTH);\r
+      add(scriptWindow, BorderLayout.SOUTH);\r
+      scriptWindow.setVisible(false);\r
+      history.setEditable(false);\r
+      inputLine.addKeyListener(this);\r
+    }\r
+\r
+    scriptWindow.setVisible(!scriptWindow.isVisible());\r
+    validate();\r
+  }\r
+\r
+  public float functionXY(String functionName, int x, int y)\r
+  {\r
+    return 0;\r
+  }\r
+\r
+  ///End JmolStatusListener\r
+  ///////////////////////////////\r
+\r
+\r
+  class RenderPanel\r
+      extends Panel\r
+  {\r
+    Dimension currentSize = new Dimension();\r
+    Rectangle rectClip = new Rectangle();\r
+\r
+    public void update(Graphics g) {\r
+      paint(g);\r
+    }\r
+    public void paint(Graphics g)\r
+    {\r
+      currentSize = this.getSize();\r
+      rectClip = g.getClipBounds();\r
+\r
+      if (viewer == null)\r
+      {\r
+        g.setColor(Color.black);\r
+        g.fillRect(0, 0, currentSize.width, currentSize.height);\r
+        g.setColor(Color.white);\r
+        g.setFont(new Font("Verdana", Font.BOLD, 14));\r
+        g.drawString("Retrieving PDB data....", 20, currentSize.height / 2);\r
+      }\r
+      else\r
+      {\r
+        viewer.renderScreenImage(g, currentSize, rectClip);\r
+      }\r
+    }\r
+  }\r
+\r
+}\r
diff --git a/src/jalview/commands/SlideSequencesCommand.java b/src/jalview/commands/SlideSequencesCommand.java
new file mode 100644 (file)
index 0000000..21385ad
--- /dev/null
@@ -0,0 +1,93 @@
+\r
+/*\r
+* Jalview - A Sequence Alignment Editor and Viewer\r
+* Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+*\r
+* This program is free software; you can redistribute it and/or\r
+* modify it under the terms of the GNU General Public License\r
+* as published by the Free Software Foundation; either version 2\r
+* of the License, or (at your option) any later version.\r
+*\r
+* This program is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with this program; if not, write to the Free Software\r
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+*/\r
+\r
+package jalview.commands;\r
+\r
+import jalview.datamodel.*;\r
+\r
+public class SlideSequencesCommand extends EditCommand\r
+{\r
+  boolean gapsInsertedBegin = false;\r
+\r
+  public SlideSequencesCommand(String description,\r
+                               SequenceI[] seqsLeft,\r
+                               SequenceI[] seqsRight,\r
+                               int slideSize,\r
+                               char gapChar)\r
+  {\r
+    this.description = description;\r
+\r
+    int lSize = seqsLeft.length;\r
+    gapsInsertedBegin = false;\r
+    int i, j;\r
+    for (i = 0; i < lSize; i++)\r
+    {\r
+      for (j = 0; j < slideSize; j++)\r
+        if (!jalview.util.Comparison.isGap(seqsLeft[i].getCharAt(j)))\r
+        {\r
+          gapsInsertedBegin = true;\r
+          break;\r
+        }\r
+    }\r
+\r
+    if (!gapsInsertedBegin)\r
+      edits = new Edit[]\r
+          {  new Edit(DELETE_GAP, seqsLeft, 0, slideSize, gapChar)};\r
+    else\r
+      edits = new Edit[]\r
+          {  new Edit(INSERT_GAP, seqsRight, 0, slideSize, gapChar)};\r
+\r
+    performEdit(0);\r
+  }\r
+\r
+  public boolean getGapsInsertedBegin()\r
+  {\r
+    return gapsInsertedBegin;\r
+  }\r
+\r
+  public boolean appendSlideCommand(SlideSequencesCommand command)\r
+  {\r
+    boolean same = false;\r
+\r
+    if(command.edits[0].seqs.length==edits[0].seqs.length)\r
+    {\r
+      same = true;\r
+      for (int i = 0; i < command.edits[0].seqs.length; i++)\r
+      {\r
+        if (edits[0].seqs[i] != command.edits[0].seqs[i])\r
+        {\r
+          same = false;\r
+        }\r
+      }\r
+    }\r
+\r
+    if(same)\r
+    {\r
+      Edit[] temp = new Edit[command.edits.length + 1];\r
+      System.arraycopy(command.edits, 0, temp, 0, command.edits.length);\r
+      command.edits = temp;\r
+      command.edits[command.edits.length - 1] = edits[0];\r
+    }\r
+\r
+    return same;\r
+  }\r
+}\r
+\r
+\r
diff --git a/src/jalview/gui/AppJMol.java b/src/jalview/gui/AppJMol.java
new file mode 100644 (file)
index 0000000..7b17d68
--- /dev/null
@@ -0,0 +1,665 @@
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
+package jalview.gui;\r
+\r
+import java.util.regex.*;\r
+import java.util.*;\r
+import java.awt.*;\r
+import javax.swing.*;\r
+import javax.swing.event.*;\r
+import java.awt.event.*;\r
+import java.io.*;\r
+\r
+import jalview.jbgui.GStructureViewer;\r
+import jalview.datamodel.*;\r
+import jalview.gui.*;\r
+import jalview.structure.*;\r
+import jalview.datamodel.PDBEntry;\r
+import jalview.io.*;\r
+\r
+import org.jmol.api.*;\r
+import org.jmol.adapter.smarter.SmarterJmolAdapter;\r
+import org.jmol.popup.*;\r
+\r
+\r
+public class AppJMol\r
+    extends GStructureViewer\r
+    implements StructureListener, JmolStatusListener, Runnable\r
+\r
+{\r
+  JmolViewer viewer;\r
+  JmolPopup jmolpopup;\r
+  ScriptWindow scriptWindow;\r
+  PDBEntry pdbentry;\r
+  SequenceI[] sequence;\r
+  StructureSelectionManager ssm;\r
+  RenderPanel renderPanel;\r
+  AlignmentPanel ap;\r
+  String fileLoadingError;\r
+\r
+  public AppJMol(PDBEntry pdbentry, SequenceI[] seq, AlignmentPanel ap)\r
+  {\r
+    //////////////////////////////////\r
+    //Is the pdb file already loaded?\r
+    String alreadyMapped = StructureSelectionManager\r
+        .getStructureSelectionManager()\r
+        .alreadyMappedToFile(pdbentry.getId());\r
+    if (alreadyMapped != null)\r
+    {\r
+      int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,\r
+          pdbentry.getId() + " is already displayed."\r
+          + "\nDo you want to map sequences to the visible structure?",\r
+          "Map Sequences to Visible Window: " + pdbentry.getId(),\r
+          JOptionPane.YES_NO_OPTION);\r
+\r
+      if (option == JOptionPane.YES_OPTION)\r
+      {\r
+        StructureSelectionManager.getStructureSelectionManager()\r
+            .setMapping(seq, alreadyMapped, AppletFormatAdapter.FILE);\r
+        return;\r
+      }\r
+    }\r
+    ///////////////////////////////////\r
+\r
+    this.ap = ap;\r
+    this.pdbentry = pdbentry;\r
+    this.sequence = seq;\r
+\r
+    renderPanel = new RenderPanel();\r
+    this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);\r
+\r
+    jalview.gui.Desktop.addInternalFrame(this, "Loading File", 400, 400);\r
+\r
+    if (pdbentry.getFile() != null)\r
+    {\r
+      initJmol();\r
+    }\r
+    else\r
+    {\r
+      Thread worker = new Thread(this);\r
+      worker.start();\r
+    }\r
+\r
+    this.addInternalFrameListener(new InternalFrameAdapter()\r
+    {\r
+      public void internalFrameClosing(InternalFrameEvent internalFrameEvent)\r
+      {\r
+        closeViewer();\r
+      }\r
+    });\r
+  }\r
+\r
+  void initJmol()\r
+  {\r
+    StringBuffer title = new StringBuffer(sequence[0].getName() + ":" +\r
+                                          pdbentry.getId());\r
+\r
+    if (pdbentry.getProperty() != null)\r
+    {\r
+      if (pdbentry.getProperty().get("method") != null)\r
+      {\r
+        title.append(" Method: ");\r
+        title.append(pdbentry.getProperty().get("method"));\r
+      }\r
+      if (pdbentry.getProperty().get("chains") != null)\r
+      {\r
+        title.append(" Chain:");\r
+        title.append(pdbentry.getProperty().get("chains"));\r
+      }\r
+    }\r
+\r
+    this.setTitle(title.toString());\r
+\r
+    viewer = org.jmol.api.JmolViewer.allocateViewer(renderPanel,\r
+        new SmarterJmolAdapter());\r
+\r
+    viewer.setAppletContext("", null, null, "");\r
+\r
+    viewer.setJmolStatusListener(this);\r
+\r
+    scriptWindow = new ScriptWindow(viewer);\r
+\r
+    jmolpopup = JmolPopup.newJmolPopup(viewer);\r
+\r
+    viewer.openFile(pdbentry.getFile());\r
+\r
+  }\r
+\r
+\r
+  void setChainMenuItems(Vector chains)\r
+  {\r
+    chainMenu.removeAll();\r
+\r
+    JMenuItem menuItem = new JMenuItem("All");\r
+    menuItem.addActionListener(new ActionListener()\r
+        {\r
+          public void actionPerformed(ActionEvent evt)\r
+          {\r
+            allChainsSelected = true;\r
+            for(int i=0; i<chainMenu.getItemCount(); i++)\r
+            {\r
+              if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)\r
+                ( (JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);\r
+            }\r
+            centerViewer();\r
+            allChainsSelected = false;\r
+          }\r
+        });\r
+\r
+    chainMenu.add(menuItem);\r
+\r
+    for (int c = 0; c < chains.size(); c++)\r
+    {\r
+      menuItem = new JCheckBoxMenuItem(chains.elementAt(c).toString(), true);\r
+      menuItem.addItemListener(new ItemListener()\r
+      {\r
+        public void itemStateChanged(ItemEvent evt)\r
+        {\r
+          if (!allChainsSelected)\r
+            centerViewer();\r
+        }\r
+      });\r
+\r
+      chainMenu.add(menuItem);\r
+    }\r
+  }\r
+\r
+  boolean allChainsSelected = false;\r
+  void centerViewer()\r
+  {\r
+    StringBuffer cmd = new StringBuffer();\r
+    for(int i=0; i<chainMenu.getItemCount(); i++)\r
+    {\r
+      if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)\r
+      {\r
+       JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);\r
+       if(item.isSelected())\r
+         cmd.append(":"+item.getText()+" or ");\r
+      }\r
+    }\r
+\r
+    if (cmd.length() > 0)\r
+      cmd.setLength(cmd.length() - 4);\r
+\r
+    viewer.evalStringQuiet("select *;restrict "\r
+                      +cmd+";cartoon;center "+cmd);\r
+  }\r
+\r
+  void closeViewer()\r
+  {\r
+    viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE);\r
+    viewer.evalStringQuiet("zap");\r
+    viewer.setJmolStatusListener(null);\r
+    viewer = null;\r
+\r
+    //We'll need to find out what other\r
+    // listeners need to be shut down in Jmol\r
+    StructureSelectionManager\r
+        .getStructureSelectionManager()\r
+        .removeStructureViewerListener(this, pdbentry.getFile());\r
+  }\r
+\r
+  public void run()\r
+  {\r
+    try\r
+    {\r
+      EBIFetchClient ebi = new EBIFetchClient();\r
+      String query = "pdb:" + pdbentry.getId();\r
+      pdbentry.setFile(ebi.fetchDataAsFile(query, "default", "raw")\r
+                       .getAbsolutePath());\r
+      initJmol();\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+    }\r
+  }\r
+\r
+  public void pdbFile_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+    JalviewFileChooser chooser = new JalviewFileChooser(\r
+        jalview.bin.Cache.getProperty(\r
+            "LAST_DIRECTORY"));\r
+\r
+    chooser.setFileView(new JalviewFileView());\r
+    chooser.setDialogTitle("Save PDB File");\r
+    chooser.setToolTipText("Save");\r
+\r
+    int value = chooser.showSaveDialog(this);\r
+\r
+    if (value == JalviewFileChooser.APPROVE_OPTION)\r
+    {\r
+      try\r
+      {\r
+        BufferedReader in = new BufferedReader(new FileReader(pdbentry.getFile()));\r
+        File outFile = chooser.getSelectedFile();\r
+\r
+        PrintWriter out = new PrintWriter(new FileOutputStream(outFile));\r
+        String data;\r
+        while ( (data = in.readLine()) != null)\r
+        {\r
+          if (\r
+              ! (data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1)\r
+              )\r
+          {\r
+            out.println(data);\r
+          }\r
+        }\r
+        out.close();\r
+      }\r
+      catch (Exception ex)\r
+      {\r
+        ex.printStackTrace();\r
+      }\r
+    }\r
+  }\r
+\r
+  public void viewMapping_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+    jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();\r
+    jalview.gui.Desktop.addInternalFrame(cap, "PDB - Sequence Mapping", 550,\r
+                                         600);\r
+    cap.setText(\r
+        StructureSelectionManager.getStructureSelectionManager().printMapping(\r
+            pdbentry.getFile())\r
+        );\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param e DOCUMENT ME!\r
+   */\r
+  public void eps_actionPerformed(ActionEvent e)\r
+  {\r
+    makePDBImage(jalview.util.ImageMaker.EPS);\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param e DOCUMENT ME!\r
+   */\r
+  public void png_actionPerformed(ActionEvent e)\r
+  {\r
+    makePDBImage(jalview.util.ImageMaker.PNG);\r
+  }\r
+\r
+  void makePDBImage(int type)\r
+  {\r
+    int width = getWidth();\r
+    int height = getHeight();\r
+\r
+    jalview.util.ImageMaker im;\r
+\r
+    if (type == jalview.util.ImageMaker.PNG)\r
+    {\r
+      im = new jalview.util.ImageMaker(this,\r
+                                       jalview.util.ImageMaker.PNG,\r
+                                       "Make PNG image from view",\r
+                                       width, height,\r
+                                       null, null);\r
+    }\r
+    else\r
+    {\r
+      im = new jalview.util.ImageMaker(this,\r
+                                       jalview.util.ImageMaker.EPS,\r
+                                       "Make EPS file from view",\r
+                                       width, height,\r
+                                       null, this.getTitle());\r
+    }\r
+\r
+    if (im.getGraphics() != null)\r
+    {\r
+      Rectangle rect = new Rectangle(width, height);\r
+      viewer.renderScreenImage(im.getGraphics(),\r
+                               rect.getSize(), rect);\r
+      im.writeImage();\r
+    }\r
+  }\r
+\r
+  //////////////////////////////////\r
+  ///StructureListener\r
+  public String getPdbFile()\r
+  {\r
+    return pdbentry.getFile();\r
+  }\r
+\r
+  Pattern pattern = Pattern.compile(\r
+      "\\[(.*)\\]([0-9]+)(:[a-zA-Z]*)?\\.([a-zA-Z]+)(/[0-9]*)?"\r
+      );\r
+\r
+  String lastMessage;\r
+  public void mouseOverStructure(int atomIndex, String strInfo)\r
+  {\r
+    Matcher matcher = pattern.matcher(strInfo);\r
+    matcher.find();\r
+    matcher.group(1);\r
+    int pdbResNum = Integer.parseInt(matcher.group(2));\r
+    String chainId = matcher.group(3);\r
+\r
+    if (chainId != null)\r
+      chainId = chainId.substring(1, chainId.length());\r
+    else\r
+    {\r
+      chainId = " ";\r
+    }\r
+\r
+    if (lastMessage == null || !lastMessage.equals(strInfo))\r
+      ssm.mouseOverStructure(pdbResNum, chainId, pdbentry.getFile());\r
+\r
+    lastMessage = strInfo;\r
+  }\r
+\r
+  StringBuffer resetLastRes = new StringBuffer();\r
+  StringBuffer eval = new StringBuffer();\r
+\r
+  public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile)\r
+  {\r
+    if (!pdbfile.equals(pdbentry.getFile()))\r
+      return;\r
+\r
+    if (resetLastRes.length() > 0)\r
+    {\r
+      viewer.evalStringQuiet(resetLastRes.toString());\r
+    }\r
+\r
+    eval.setLength(0);\r
+    eval.append("select " + pdbResNum);\r
+\r
+    resetLastRes.setLength(0);\r
+    resetLastRes.append("select " + pdbResNum);\r
+\r
+    if (!chain.equals(" "))\r
+    {\r
+      eval.append(":" + chain);\r
+      resetLastRes.append(":" + chain);\r
+    }\r
+\r
+    eval.append(";color gold;wireframe 100");\r
+\r
+    Color col = new Color(viewer.getAtomArgb(atomIndex));\r
+\r
+    resetLastRes.append(";color["\r
+                        + col.getRed() + ","\r
+                        + col.getGreen() + ","\r
+                        + col.getBlue() + "];wireframe 0");\r
+\r
+    viewer.evalStringQuiet(eval.toString());\r
+\r
+  }\r
+\r
+  public void updateColours(Object source)\r
+  {\r
+    colourBySequence( (AlignmentPanel) source);\r
+  }\r
+\r
+//End StructureListener\r
+////////////////////////////\r
+\r
+  FeatureRenderer fr;\r
+  public void colourBySequence(AlignmentPanel ap)\r
+  {\r
+    StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());\r
+\r
+    if (mapping.length < 1)\r
+      return;\r
+\r
+    SequenceRenderer sr = ap.seqPanel.seqCanvas.getSequenceRenderer();\r
+\r
+    boolean showFeatures = false;\r
+    if (ap.av.showSequenceFeatures)\r
+    {\r
+      showFeatures = true;\r
+      if (fr == null)\r
+      {\r
+        fr = new jalview.gui.FeatureRenderer(ap.av);\r
+      }\r
+\r
+      fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());\r
+    }\r
+\r
+    StringBuffer command = new StringBuffer();\r
+\r
+    int lastPos = -1;\r
+    for (int s = 0; s < sequence.length; s++)\r
+    {\r
+      for (int m = 0; m < mapping.length; m++)\r
+      {\r
+        if (mapping[m].getSequence() == sequence[s])\r
+        {\r
+          for (int r = 0; r < sequence[s].getLength(); r++)\r
+          {\r
+            int pos = mapping[m].getPDBResNum(\r
+                sequence[s].findPosition(r));\r
+\r
+            if (pos < 1 || pos==lastPos)\r
+              continue;\r
+\r
+            lastPos = pos;\r
+\r
+            command.append(";select " + pos);\r
+\r
+            if (!mapping[m].getChain().equals(" "))\r
+            {\r
+              command.append(":" + mapping[m].getChain());\r
+            }\r
+\r
+            Color col = sr.getResidueBoxColour(sequence[s], r);\r
+\r
+            if (showFeatures)\r
+              col = fr.findFeatureColour(col, sequence[s], r);\r
+\r
+            command.append("; color ["\r
+                           + col.getRed() + ","\r
+                           + col.getGreen() + ","\r
+                           + col.getBlue() + "]");\r
+\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    viewer.evalStringQuiet(command.toString());\r
+  }\r
+\r
+  /////////////////////////////////\r
+  //JmolStatusListener\r
+\r
+  public String eval(String strEval)\r
+  {\r
+   // System.out.println(strEval);\r
+   //"# 'eval' is implemented only for the applet.";\r
+    return null;\r
+  }\r
+\r
+  public void createImage(String file, String type, int quality)\r
+  {\r
+    System.out.println("JMOL CREATE IMAGE");\r
+  }\r
+\r
+  public void setCallbackFunction(String callbackType,\r
+                                  String callbackFunction)\r
+  {}\r
+\r
+  public void notifyFileLoaded(String fullPathName, String fileName,\r
+                               String modelName, Object clientFile,\r
+                               String errorMsg)\r
+  {\r
+    if(errorMsg!=null)\r
+    {\r
+      fileLoadingError = errorMsg;\r
+      repaint();\r
+      return;\r
+    }\r
+\r
+    fileLoadingError = null;\r
+\r
+    if (fileName != null)\r
+    {\r
+\r
+      //FILE LOADED OK\r
+      ssm = StructureSelectionManager.getStructureSelectionManager();\r
+      MCview.PDBfile pdbFile = ssm.setMapping(sequence, pdbentry.getFile(), AppletFormatAdapter.FILE);\r
+      ssm.addStructureViewerListener(this);\r
+\r
+      Vector chains = new Vector();\r
+      for(int i=0; i<pdbFile.chains.size(); i++)\r
+      {\r
+        chains.addElement(((MCview.PDBChain)pdbFile.chains.elementAt(i)).id);\r
+      }\r
+      setChainMenuItems(chains);\r
+\r
+      jmolpopup.updateComputedMenus();\r
+      viewer.evalStringQuiet(\r
+          "select backbone;restrict;cartoon;wireframe off;spacefill off");\r
+\r
+      colourBySequence(ap);\r
+    }\r
+    else\r
+      return;\r
+  }\r
+\r
+  public void notifyFrameChanged(int frameNo)\r
+  {\r
+    boolean isAnimationRunning = (frameNo <= -2);\r
+  }\r
+\r
+  public void notifyScriptStart(String statusMessage, String additionalInfo)\r
+  {}\r
+\r
+  public void sendConsoleEcho(String strEcho)\r
+  {\r
+    if (scriptWindow != null)\r
+      scriptWindow.sendConsoleEcho(strEcho);\r
+  }\r
+\r
+  public void sendConsoleMessage(String strStatus)\r
+  {\r
+    if (scriptWindow != null)\r
+      scriptWindow.sendConsoleMessage(strStatus);\r
+  }\r
+\r
+  public void notifyScriptTermination(String strStatus, int msWalltime)\r
+  {\r
+    if (scriptWindow != null)\r
+      scriptWindow.notifyScriptTermination(strStatus, msWalltime);\r
+  }\r
+\r
+  public void handlePopupMenu(int x, int y)\r
+  {\r
+    jmolpopup.show(x, y);\r
+  }\r
+\r
+  public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)\r
+  {\r
+    notifyAtomPicked(iatom, strMeasure);\r
+  }\r
+\r
+  public void notifyNewDefaultModeMeasurement(int count, String strInfo)\r
+  {}\r
+\r
+  public void notifyAtomPicked(int atomIndex, String strInfo)\r
+  {\r
+    if (scriptWindow != null)\r
+    {\r
+      scriptWindow.sendConsoleMessage(strInfo);\r
+      scriptWindow.sendConsoleMessage("\n");\r
+    }\r
+  }\r
+\r
+  public void notifyAtomHovered(int atomIndex, String strInfo)\r
+  {\r
+    mouseOverStructure(atomIndex, strInfo);\r
+  }\r
+\r
+  public void sendSyncScript(String script, String appletName)\r
+  {}\r
+\r
+  public void showUrl(String url)\r
+  {}\r
+\r
+  public void showConsole(boolean showConsole)\r
+  {\r
+    final String title = "Jmol Script Window for: "+this.getTitle();\r
+    if (scriptWindow == null)\r
+      return;\r
+    if (showConsole)\r
+    {\r
+      javax.swing.SwingUtilities.invokeLater(new Runnable()\r
+      {\r
+        public void run()\r
+        {\r
+          jalview.gui.Desktop.addInternalFrame(scriptWindow,\r
+                                               title,\r
+                                               400,\r
+                                               300);\r
+        }\r
+      });\r
+\r
+    }\r
+    else\r
+      scriptWindow.setVisible(false);\r
+  }\r
+\r
+  public float functionXY(String functionName, int x, int y)\r
+  {\r
+    return 0;\r
+  }\r
+\r
+  ///End JmolStatusListener\r
+  ///////////////////////////////\r
+\r
+\r
+  class RenderPanel\r
+      extends JPanel\r
+  {\r
+    final Dimension currentSize = new Dimension();\r
+    final Rectangle rectClip = new Rectangle();\r
+\r
+    public void paintComponent(Graphics g)\r
+    {\r
+      getSize(currentSize);\r
+      g.getClipBounds(rectClip);\r
+\r
+      if (viewer == null)\r
+      {\r
+        g.setColor(Color.black);\r
+        g.fillRect(0, 0, currentSize.width, currentSize.height);\r
+        g.setColor(Color.white);\r
+        g.setFont(new Font("Verdana", Font.BOLD, 14));\r
+        g.drawString("Retrieving PDB data....", 20, currentSize.height / 2);\r
+      }\r
+      else if(fileLoadingError!=null)\r
+      {\r
+        g.setColor(Color.black);\r
+        g.fillRect(0, 0, currentSize.width, currentSize.height);\r
+        g.setColor(Color.white);\r
+        g.setFont(new Font("Verdana", Font.BOLD, 14));\r
+        g.drawString("Error loading file..." + pdbentry.getId(), 20,\r
+                     currentSize.height / 2);\r
+      }\r
+      else\r
+      {\r
+        viewer.renderScreenImage(g, currentSize, rectClip);\r
+      }\r
+    }\r
+  }\r
+\r
+}\r
diff --git a/src/jalview/gui/ScriptWindow.java b/src/jalview/gui/ScriptWindow.java
new file mode 100644 (file)
index 0000000..a3a3f42
--- /dev/null
@@ -0,0 +1,619 @@
+/* $RCSfile$\r
+ * $Author$\r
+ * $Date$\r
+ * $Revision$\r
+ *\r
+ * Copyright (C) 2002-2005  The Jmol Development Team\r
+ *\r
+ * Contact: jmol-developers@lists.sf.net\r
+ *\r
+ *  This library is free software; you can redistribute it and/or\r
+ *  modify it under the terms of the GNU Lesser General Public\r
+ *  License as published by the Free Software Foundation; either\r
+ *  version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ *  This library is distributed in the hope that it will be useful,\r
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+ *  Lesser General Public License for more details.\r
+ *\r
+ *  You should have received a copy of the GNU Lesser General Public\r
+ *  License along with this library; if not, write to the Free Software\r
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\r
+\r
+ *\r
+ * Modified and added to Jalview by A Waterhouse to extend JInternalFrame\r
+ *\r
+\r
+ */\r
+package jalview.gui;\r
+\r
+import org.jmol.api.*;\r
+\r
+import java.awt.*;\r
+import java.awt.event.*;\r
+import javax.swing.*;\r
+import javax.swing.text.*;\r
+import java.util.Vector;\r
+\r
+import org.jmol.i18n.GT;\r
+import org.jmol.util.Logger;\r
+import org.jmol.util.CommandHistory;\r
+\r
+public final class ScriptWindow extends JInternalFrame\r
+    implements ActionListener, EnterListener{\r
+\r
+  private ConsoleTextPane console;\r
+  private JButton closeButton;\r
+  private JButton runButton;\r
+  private JButton haltButton;\r
+  private JButton clearButton;\r
+  private JButton historyButton;\r
+  private JButton stateButton;\r
+  private JButton helpButton;\r
+  JmolViewer viewer;\r
+\r
+  public ScriptWindow(JmolViewer viewer)\r
+  {\r
+    this.viewer = viewer;\r
+\r
+    getContentPane().setLayout(new BorderLayout());\r
+\r
+    console = new ConsoleTextPane(this);\r
+\r
+\r
+    console.setPrompt();\r
+    getContentPane().add(new JScrollPane(console)\r
+                         , BorderLayout.CENTER);\r
+\r
+    JPanel buttonPanel = new JPanel();\r
+    getContentPane().add(buttonPanel, BorderLayout.SOUTH);\r
+\r
+    runButton = new JButton(GT._("Run"));\r
+    runButton.addActionListener(this);\r
+    buttonPanel.add(runButton);\r
+\r
+    haltButton = new JButton(GT._("Halt"));\r
+    haltButton.addActionListener(this);\r
+    buttonPanel.add(haltButton);\r
+    haltButton.setEnabled(false);\r
+\r
+    clearButton = new JButton(GT._("Clear"));\r
+    clearButton.addActionListener(this);\r
+    buttonPanel.add(clearButton);\r
+\r
+    historyButton = new JButton(GT._("History"));\r
+    historyButton.addActionListener(this);\r
+    buttonPanel.add(historyButton);\r
+\r
+    stateButton = new JButton(GT._("State"));\r
+    stateButton.addActionListener(this);\r
+    buttonPanel.add(stateButton);\r
+\r
+    helpButton = new JButton(GT._("Help"));\r
+    helpButton.addActionListener(this);\r
+    buttonPanel.add(helpButton);\r
+\r
+    closeButton = new JButton(GT._("Close"));\r
+    closeButton.addActionListener(this);\r
+    buttonPanel.add(closeButton);\r
+\r
+  }\r
+\r
+  public void sendConsoleEcho(String strEcho) {\r
+    if (strEcho != null && !isError) {\r
+\r
+      console.outputEcho(strEcho);\r
+\r
+    }\r
+    setError(false);\r
+  }\r
+\r
+  boolean isError = false;\r
+  void setError(boolean TF) {\r
+    isError = TF;\r
+    //if (isError)\r
+      //console.recallCommand(true);\r
+  }\r
+\r
+  public void sendConsoleMessage(String strStatus) {\r
+    if (strStatus == null) {\r
+      console.clearContent();\r
+      console.outputStatus("");\r
+    } else if (strStatus.indexOf("ERROR:") >= 0) {\r
+      console.outputError(strStatus);\r
+      isError = true;\r
+    } else if (!isError) {\r
+      console.outputStatus(strStatus);\r
+    }\r
+  }\r
+\r
+  public void notifyScriptTermination(String strMsg, int msWalltime) {\r
+    if (strMsg != null && strMsg.indexOf("ERROR") >= 0) {\r
+      console.outputError(strMsg);\r
+    }\r
+    runButton.setEnabled(true);\r
+    haltButton.setEnabled(false);\r
+  }\r
+\r
+  public void enterPressed() {\r
+    runButton.doClick(100);\r
+    //    executeCommand();\r
+  }\r
+\r
+\r
+  class ExecuteCommandThread extends Thread {\r
+\r
+    String strCommand;\r
+    ExecuteCommandThread (String command) {\r
+      strCommand = command;\r
+    }\r
+\r
+    public void run() {\r
+      try {\r
+        executeCommand(strCommand);\r
+      } catch (Exception ie) {\r
+        Logger.debug("execution command interrupted!"+ie);\r
+      }\r
+    }\r
+  }\r
+\r
+  ExecuteCommandThread execThread;\r
+  void executeCommandAsThread(){\r
+    String strCommand = console.getCommandString().trim();\r
+    if (strCommand.length() > 0) {\r
+      execThread = new ExecuteCommandThread(strCommand);\r
+      execThread.start();\r
+    }\r
+  }\r
+\r
+  void executeCommand(String strCommand) {\r
+    boolean doWait;\r
+    setError(false);\r
+    console.appendNewline();\r
+    console.setPrompt();\r
+    if (strCommand.length() > 0) {\r
+      String strErrorMessage = null;\r
+      doWait = (strCommand.indexOf("WAIT ") == 0);\r
+      if (doWait) { //for testing, mainly\r
+        // demonstrates using the statusManager system.\r
+        runButton.setEnabled(false);\r
+        haltButton.setEnabled(true);\r
+\r
+        Vector info = (Vector) viewer\r
+            .scriptWaitStatus(strCommand.substring(5),\r
+                "+fileLoaded,+scriptStarted,+scriptStatus,+scriptEcho,+scriptTerminated");\r
+        runButton.setEnabled(true);\r
+        haltButton.setEnabled(false);\r
+        /*\r
+         * info = [ statusRecortSet0, statusRecortSet1, statusRecortSet2, ...]\r
+         * statusRecordSet = [ statusRecord0, statusRecord1, statusRecord2, ...]\r
+         * statusRecord = [int msgPtr, String statusName, int intInfo, String msg]\r
+         */\r
+        for (int i = 0; i < info.size(); i++) {\r
+          Vector statusRecordSet = (Vector) info.get(i);\r
+          for (int j = 0; j < statusRecordSet.size(); j++) {\r
+            Vector statusRecord = (Vector) statusRecordSet.get(j);\r
+            Logger.info("msg#=" + statusRecord.get(0) + " "\r
+                + statusRecord.get(1) + " intInfo=" + statusRecord.get(2)\r
+                + " stringInfo=" + statusRecord.get(3));\r
+          }\r
+        }\r
+        console.appendNewline();\r
+      } else {\r
+        boolean isScriptExecuting = viewer.isScriptExecuting();\r
+        if (viewer.checkHalt(strCommand))\r
+          strErrorMessage = (isScriptExecuting ? "string execution halted with " + strCommand : "no script was executing");\r
+        else\r
+          strErrorMessage = "";//viewer.scriptCheck(strCommand);\r
+        //the problem is that scriptCheck is synchronized, so these might get backed up.\r
+        if (strErrorMessage != null && strErrorMessage.length() > 0) {\r
+          console.outputError(strErrorMessage);\r
+        } else {\r
+          //runButton.setEnabled(false);\r
+          haltButton.setEnabled(true);\r
+          viewer.script(strCommand);\r
+        }\r
+      }\r
+    }\r
+    console.grabFocus();\r
+  }\r
+\r
+  public void actionPerformed(ActionEvent e) {\r
+    Object source = e.getSource();\r
+    if (source == closeButton) {\r
+      hide();\r
+    } else if (source == runButton) {\r
+      executeCommandAsThread();\r
+    } else if (source == clearButton) {\r
+      console.clearContent();\r
+    } else if (source == historyButton) {\r
+      console.clearContent(viewer.getSetHistory(Integer.MAX_VALUE));\r
+    } else if (source == stateButton) {\r
+      console.clearContent(viewer.getStateInfo());\r
+    } else if (source == haltButton) {\r
+      viewer.haltScriptExecution();\r
+    } else if (source == helpButton) {\r
+        try{\r
+          jalview.util.BrowserLauncher.openURL(\r
+              "http://jmol.sourceforge.net/docs/JmolUserGuide/ch04.html");\r
+        }catch(Exception ex){}\r
+\r
+    }\r
+    console.grabFocus(); // always grab the focus (e.g., after clear)\r
+  }\r
+}\r
+\r
+class ConsoleTextPane extends JTextPane {\r
+\r
+  ConsoleDocument consoleDoc;\r
+  EnterListener enterListener;\r
+  JmolViewer viewer;\r
+\r
+  ConsoleTextPane(ScriptWindow scriptWindow) {\r
+    super(new ConsoleDocument());\r
+    consoleDoc = (ConsoleDocument)getDocument();\r
+    consoleDoc.setConsoleTextPane(this);\r
+    this.enterListener = (EnterListener) scriptWindow;\r
+    this.viewer = scriptWindow.viewer;\r
+  }\r
+\r
+  public String getCommandString() {\r
+    String cmd = consoleDoc.getCommandString();\r
+    return cmd;\r
+  }\r
+\r
+  public void setPrompt() {\r
+    consoleDoc.setPrompt();\r
+  }\r
+\r
+  public void appendNewline() {\r
+    consoleDoc.appendNewline();\r
+  }\r
+\r
+  public void outputError(String strError) {\r
+    consoleDoc.outputError(strError);\r
+  }\r
+\r
+  public void outputErrorForeground(String strError) {\r
+    consoleDoc.outputErrorForeground(strError);\r
+  }\r
+\r
+  public void outputEcho(String strEcho) {\r
+    consoleDoc.outputEcho(strEcho);\r
+  }\r
+\r
+  public void outputStatus(String strStatus) {\r
+    consoleDoc.outputStatus(strStatus);\r
+  }\r
+\r
+  public void enterPressed() {\r
+    if (enterListener != null)\r
+      enterListener.enterPressed();\r
+  }\r
+\r
+  public void clearContent() {\r
+    clearContent(null);\r
+  }\r
+  public void clearContent(String text) {\r
+    consoleDoc.clearContent();\r
+    if (text != null)\r
+      consoleDoc.outputEcho(text);\r
+    setPrompt();\r
+  }\r
+\r
+   /* (non-Javadoc)\r
+    * @see java.awt.Component#processKeyEvent(java.awt.event.KeyEvent)\r
+    */\r
+\r
+   /**\r
+    * Custom key event processing for command 0 implementation.\r
+    *\r
+    * Captures key up and key down strokes to call command history\r
+    * and redefines the same events with control down to allow\r
+    * caret vertical shift.\r
+    *\r
+    * @see java.awt.Component#processKeyEvent(java.awt.event.KeyEvent)\r
+    */\r
+   protected void processKeyEvent(KeyEvent ke)\r
+   {\r
+      // Id Control key is down, captures events does command\r
+      // history recall and inhibits caret vertical shift.\r
+      if (ke.getKeyCode() == KeyEvent.VK_UP\r
+         && ke.getID() == KeyEvent.KEY_PRESSED\r
+         && !ke.isControlDown())\r
+      {\r
+         recallCommand(true);\r
+      }\r
+      else if (\r
+         ke.getKeyCode() == KeyEvent.VK_DOWN\r
+            && ke.getID() == KeyEvent.KEY_PRESSED\r
+            && !ke.isControlDown())\r
+      {\r
+         recallCommand(false);\r
+      }\r
+      // If Control key is down, redefines the event as if it\r
+      // where a key up or key down stroke without modifiers.\r
+      // This allows to move the caret up and down\r
+      // with no command history recall.\r
+      else if (\r
+         (ke.getKeyCode() == KeyEvent.VK_DOWN\r
+            || ke.getKeyCode() == KeyEvent.VK_UP)\r
+            && ke.getID() == KeyEvent.KEY_PRESSED\r
+            && ke.isControlDown())\r
+      {\r
+         super\r
+            .processKeyEvent(new KeyEvent(\r
+               (Component) ke.getSource(),\r
+               ke.getID(),\r
+               ke.getWhen(),\r
+               0,         // No modifiers\r
+               ke.getKeyCode(),\r
+               ke.getKeyChar(),\r
+               ke.getKeyLocation()));\r
+      }\r
+      // Standard processing for other events.\r
+      else\r
+      {\r
+         super.processKeyEvent(ke);\r
+         //check command for compiler-identifyable syntax issues\r
+         //this may have to be taken out if people start complaining\r
+         //that only some of the commands are being checked\r
+         //that is -- that the script itself is not being fully checked\r
+\r
+         //not perfect -- help here?\r
+         if (ke.getID() == KeyEvent.KEY_RELEASED\r
+             && (ke.getKeyCode() > KeyEvent.VK_DOWN) || ke.getKeyCode() == KeyEvent.VK_BACK_SPACE)\r
+           checkCommand();\r
+      }\r
+   }\r
+\r
+   /**\r
+   * Recall command history.\r
+   *\r
+   * @param up - history up or down\r
+   */\r
+   void recallCommand(boolean up) {\r
+     String cmd = viewer.getSetHistory(up ? -1 : 1);\r
+    if (cmd == null) {\r
+      return;\r
+    }\r
+    try {\r
+      if (cmd.endsWith(CommandHistory.ERROR_FLAG)) {\r
+        cmd = cmd.substring(0, cmd.indexOf(CommandHistory.ERROR_FLAG));\r
+        consoleDoc.replaceCommand(cmd, true);\r
+      } else {\r
+        consoleDoc.replaceCommand(cmd, false);\r
+      }\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+   void checkCommand() {\r
+    String strCommand = consoleDoc.getCommandString();\r
+    if (strCommand.length() == 0)\r
+      return;\r
+    consoleDoc\r
+        .colorCommand(viewer.scriptCheck(strCommand) == null ? consoleDoc.attUserInput\r
+            : consoleDoc.attError);\r
+  }\r
+\r
+\r
+}\r
+\r
+class ConsoleDocument extends DefaultStyledDocument {\r
+\r
+  ConsoleTextPane consoleTextPane;\r
+\r
+  SimpleAttributeSet attError;\r
+  SimpleAttributeSet attEcho;\r
+  SimpleAttributeSet attPrompt;\r
+  SimpleAttributeSet attUserInput;\r
+  SimpleAttributeSet attStatus;\r
+\r
+  ConsoleDocument() {\r
+    super();\r
+\r
+    attError = new SimpleAttributeSet();\r
+    StyleConstants.setForeground(attError, Color.red);\r
+\r
+    attPrompt = new SimpleAttributeSet();\r
+    StyleConstants.setForeground(attPrompt, Color.magenta);\r
+\r
+    attUserInput = new SimpleAttributeSet();\r
+    StyleConstants.setForeground(attUserInput, Color.black);\r
+\r
+    attEcho = new SimpleAttributeSet();\r
+    StyleConstants.setForeground(attEcho, Color.blue);\r
+    StyleConstants.setBold(attEcho, true);\r
+\r
+    attStatus = new SimpleAttributeSet();\r
+    StyleConstants.setForeground(attStatus, Color.black);\r
+    StyleConstants.setItalic(attStatus, true);\r
+  }\r
+\r
+  void setConsoleTextPane(ConsoleTextPane consoleTextPane) {\r
+    this.consoleTextPane = consoleTextPane;\r
+  }\r
+\r
+  Position positionBeforePrompt; // starts at 0, so first time isn't tracked (at least on Mac OS X)\r
+  Position positionAfterPrompt;  // immediately after $, so this will track\r
+  int offsetAfterPrompt;         // only still needed for the insertString override and replaceCommand\r
+\r
+  /**\r
+   * Removes all content of the script window, and add a new prompt.\r
+   */\r
+  void clearContent() {\r
+      try {\r
+          super.remove(0, getLength());\r
+      } catch (BadLocationException exception) {\r
+          System.out.println("Could not clear script window content: " + exception.getMessage());\r
+      }\r
+  }\r
+\r
+  void setPrompt() {\r
+    try {\r
+      super.insertString(getLength(), "$ ", attPrompt);\r
+      setOffsetPositions();\r
+      consoleTextPane.setCaretPosition(offsetAfterPrompt);\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+  void setOffsetPositions() {\r
+    try {\r
+      offsetAfterPrompt = getLength();\r
+      positionBeforePrompt = createPosition(offsetAfterPrompt - 2);\r
+      // after prompt should be immediately after $ otherwise tracks the end\r
+      // of the line (and no command will be found) at least on Mac OS X it did.\r
+      positionAfterPrompt = createPosition(offsetAfterPrompt - 1);\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+  void setNoPrompt() {\r
+    try {\r
+      offsetAfterPrompt = getLength();\r
+      positionAfterPrompt = positionBeforePrompt = createPosition(offsetAfterPrompt);\r
+      consoleTextPane.setCaretPosition(offsetAfterPrompt);\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+  // it looks like the positionBeforePrompt does not track when it started out as 0\r
+  // and a insertString at location 0 occurs. It may be better to track the\r
+  // position after the prompt in stead\r
+  void outputBeforePrompt(String str, SimpleAttributeSet attribute) {\r
+    try {\r
+      int pt = consoleTextPane.getCaretPosition();\r
+      Position caretPosition = createPosition(pt);\r
+      pt = positionBeforePrompt.getOffset();\r
+      super.insertString(pt, str+"\n", attribute);\r
+      setOffsetPositions();\r
+      pt = caretPosition.getOffset();\r
+      consoleTextPane.setCaretPosition(pt);\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+  void outputError(String strError) {\r
+    outputBeforePrompt(strError, attError);\r
+  }\r
+\r
+  void outputErrorForeground(String strError) {\r
+    try {\r
+      super.insertString(getLength(), strError+"\n", attError);\r
+      consoleTextPane.setCaretPosition(getLength());\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+\r
+    }\r
+  }\r
+\r
+  void outputEcho(String strEcho) {\r
+    outputBeforePrompt(strEcho, attEcho);\r
+  }\r
+\r
+  void outputStatus(String strStatus) {\r
+    outputBeforePrompt(strStatus, attStatus);\r
+  }\r
+\r
+  void appendNewline() {\r
+    try {\r
+      super.insertString(getLength(), "\n", attUserInput);\r
+      consoleTextPane.setCaretPosition(getLength());\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+  // override the insertString to make sure everything typed ends up at the end\r
+  // or in the 'command line' using the proper font, and the newline is processed.\r
+  public void insertString(int offs, String str, AttributeSet a)\r
+    throws BadLocationException {\r
+    int ichNewline = str.indexOf('\n');\r
+    if (ichNewline > 0)\r
+      str = str.substring(0, ichNewline);\r
+    if (ichNewline != 0) {\r
+      if (offs < offsetAfterPrompt) {\r
+        offs = getLength();\r
+      }\r
+      super.insertString(offs, str, a == attError ? a : attUserInput);\r
+      consoleTextPane.setCaretPosition(offs+str.length());\r
+    }\r
+    if (ichNewline >= 0) {\r
+      consoleTextPane.enterPressed();\r
+    }\r
+  }\r
+\r
+  String getCommandString() {\r
+    String strCommand = "";\r
+    try {\r
+      int cmdStart = positionAfterPrompt.getOffset();\r
+      strCommand =  getText(cmdStart, getLength() - cmdStart);\r
+      while (strCommand.length() > 0 && strCommand.charAt(0) == ' ')\r
+        strCommand = strCommand.substring(1);\r
+    } catch (BadLocationException e) {\r
+      e.printStackTrace();\r
+    }\r
+    return strCommand;\r
+  }\r
+\r
+  public void remove(int offs, int len)\r
+    throws BadLocationException {\r
+    if (offs < offsetAfterPrompt) {\r
+      len -= offsetAfterPrompt - offs;\r
+      if (len <= 0)\r
+        return;\r
+      offs = offsetAfterPrompt;\r
+    }\r
+    super.remove(offs, len);\r
+//    consoleTextPane.setCaretPosition(offs);\r
+  }\r
+\r
+  public void replace(int offs, int length, String str, AttributeSet attrs)\r
+    throws BadLocationException {\r
+    if (offs < offsetAfterPrompt) {\r
+      if (offs + length < offsetAfterPrompt) {\r
+        offs = getLength();\r
+        length = 0;\r
+      } else {\r
+        length -= offsetAfterPrompt - offs;\r
+        offs = offsetAfterPrompt;\r
+      }\r
+    }\r
+    super.replace(offs, length, str, attrs);\r
+//    consoleTextPane.setCaretPosition(offs + str.length());\r
+  }\r
+\r
+   /**\r
+   * Replaces current command on script.\r
+   *\r
+   * @param newCommand new command value\r
+   * @param isError    true to set error color  ends with #??\r
+   *\r
+   * @throws BadLocationException\r
+   */\r
+  void replaceCommand(String newCommand, boolean isError) throws BadLocationException {\r
+    if (positionAfterPrompt == positionBeforePrompt)\r
+      return;\r
+    replace(offsetAfterPrompt, getLength() - offsetAfterPrompt, newCommand,\r
+        isError ? attError : attUserInput);\r
+  }\r
+\r
+  void colorCommand(SimpleAttributeSet att) {\r
+    if (positionAfterPrompt == positionBeforePrompt)\r
+      return;\r
+    setCharacterAttributes(offsetAfterPrompt, getLength() - offsetAfterPrompt, att, true);\r
+  }\r
+}\r
+\r
+interface EnterListener {\r
+  public void enterPressed();\r
+}\r
+\r
diff --git a/src/jalview/jbgui/GStructureViewer.java b/src/jalview/jbgui/GStructureViewer.java
new file mode 100644 (file)
index 0000000..d60e5fa
--- /dev/null
@@ -0,0 +1,120 @@
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
+\r
+package jalview.jbgui;\r
+\r
+import javax.swing.*;\r
+import java.awt.event.ActionListener;\r
+import java.awt.event.ActionEvent;\r
+\r
+public class GStructureViewer  extends JInternalFrame\r
+{\r
+  public GStructureViewer()\r
+  {\r
+    try\r
+    {\r
+      jbInit();\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+    }\r
+  }\r
+\r
+  private void jbInit()\r
+      throws Exception\r
+  {\r
+    this.setJMenuBar(menuBar);\r
+    fileMenu.setText("File");\r
+    savemenu.setActionCommand("Save Image");\r
+    savemenu.setText("Save As");\r
+    pdbFile.setText("PDB File");\r
+    pdbFile.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent actionEvent)\r
+      {\r
+        pdbFile_actionPerformed(actionEvent);\r
+      }\r
+    });\r
+    png.setText("PNG");\r
+    png.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent actionEvent)\r
+      {\r
+        png_actionPerformed(actionEvent);\r
+      }\r
+    });\r
+    eps.setText("EPS");\r
+    eps.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent actionEvent)\r
+      {\r
+        eps_actionPerformed(actionEvent);\r
+      }\r
+    });\r
+    viewMapping.setText("View Mapping");\r
+    viewMapping.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent actionEvent)\r
+      {\r
+        viewMapping_actionPerformed(actionEvent);\r
+      }\r
+    });\r
+    viewMenu.setText("View");\r
+    chainMenu.setText("Show Chain");\r
+    menuBar.add(fileMenu);\r
+    menuBar.add(viewMenu);\r
+    fileMenu.add(savemenu);\r
+    fileMenu.add(viewMapping);\r
+    savemenu.add(pdbFile);\r
+    savemenu.add(png);\r
+    savemenu.add(eps);\r
+    viewMenu.add(chainMenu);\r
+  }\r
+\r
+  JMenuBar menuBar = new JMenuBar();\r
+  JMenu fileMenu = new JMenu();\r
+  JMenu savemenu = new JMenu();\r
+  JMenuItem pdbFile = new JMenuItem();\r
+  JMenuItem png = new JMenuItem();\r
+  JMenuItem eps = new JMenuItem();\r
+  JMenuItem viewMapping = new JMenuItem();\r
+  JMenu viewMenu = new JMenu();\r
+  protected JMenu chainMenu = new JMenu();\r
+  JMenu jMenu1 = new JMenu();\r
+  public void pdbFile_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+\r
+  }\r
+\r
+  public void png_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+\r
+  }\r
+\r
+  public void eps_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+\r
+  }\r
+\r
+  public void viewMapping_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+\r
+  }\r
+}\r