X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fappletgui%2FAppletJmol.java;h=83747212e0f858b38ac3d96e4053472d592f29b5;hb=d82ec00f14199ef0ce21bd5bc70a59142b7c4b07;hp=b88bb94c1b6bd39b31d18abdb195c191294d5b17;hpb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;p=jalview.git
diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java
index b88bb94..8374721 100644
--- a/src/jalview/appletgui/AppletJmol.java
+++ b/src/jalview/appletgui/AppletJmol.java
@@ -1,38 +1,72 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.appletgui;
-import java.util.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import jalview.api.SequenceStructureBinding;
-import jalview.datamodel.*;
-import jalview.structure.*;
-import jalview.io.*;
-
-import jalview.schemes.*;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.FileParse;
+import jalview.io.StructureFile;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
+import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
+import java.awt.BorderLayout;
+import java.awt.CheckboxMenuItem;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.WindowAdapter;
+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
// StructureListener,
- KeyListener, ActionListener, ItemListener, SequenceStructureBinding
+ KeyListener, ActionListener, ItemListener
{
Menu fileMenu = new Menu(MessageManager.getString("action.file"));
@@ -45,35 +79,47 @@ public class AppletJmol extends EmbmenuFrame implements
Menu helpMenu = new Menu(MessageManager.getString("action.help"));
- MenuItem mappingMenuItem = new MenuItem(MessageManager.getString("label.view_mapping"));
+ MenuItem mappingMenuItem = new MenuItem(
+ MessageManager.getString("label.view_mapping"));
- CheckboxMenuItem seqColour = new CheckboxMenuItem(MessageManager.getString("action.by_sequence"), true);
+ CheckboxMenuItem seqColour = new CheckboxMenuItem(
+ MessageManager.getString("action.by_sequence"), true);
- CheckboxMenuItem jmolColour = new CheckboxMenuItem(MessageManager.getString("action.using_jmol"), false);
+ CheckboxMenuItem jmolColour = new CheckboxMenuItem(
+ MessageManager.getString("action.using_jmol"), false);
MenuItem chain = new MenuItem(MessageManager.getString("action.by_chain"));
- MenuItem charge = new MenuItem(MessageManager.getString("label.charge_cysteine"));
+ MenuItem charge = new MenuItem(
+ MessageManager.getString("label.charge_cysteine"));
MenuItem zappo = new MenuItem(MessageManager.getString("label.zappo"));
MenuItem taylor = new MenuItem(MessageManager.getString("label.taylor"));
- MenuItem hydro = new MenuItem(MessageManager.getString("label.hydrophobicity"));
+ MenuItem hydro = new MenuItem(
+ MessageManager.getString("label.hydrophobicity"));
- MenuItem helix = new MenuItem(MessageManager.getString("label.helix_propensity"));
+ MenuItem helix = new MenuItem(
+ MessageManager.getString("label.helix_propensity"));
- MenuItem strand = new MenuItem(MessageManager.getString("label.strand_propensity"));
+ MenuItem strand = new MenuItem(
+ MessageManager.getString("label.strand_propensity"));
- MenuItem turn = new MenuItem(MessageManager.getString("label.turn_propensity"));
+ MenuItem turn = new MenuItem(
+ MessageManager.getString("label.turn_propensity"));
- MenuItem buried = new MenuItem(MessageManager.getString("label.buried_index"));
+ MenuItem buried = new MenuItem(
+ MessageManager.getString("label.buried_index"));
- MenuItem purinepyrimidine = new MenuItem(MessageManager.getString("label.purine_pyrimidine"));
+ MenuItem purinepyrimidine = new MenuItem(
+ MessageManager.getString("label.purine_pyrimidine"));
- MenuItem user = new MenuItem(MessageManager.getString("label.user_defined_colours"));
+ MenuItem user = new MenuItem(
+ MessageManager.getString("label.user_defined_colours"));
- MenuItem jmolHelp = new MenuItem(MessageManager.getString("label.jmol_help"));
+ MenuItem jmolHelp = new MenuItem(
+ MessageManager.getString("label.jmol_help"));
Panel scriptWindow;
@@ -85,7 +131,8 @@ public class AppletJmol extends EmbmenuFrame implements
AlignmentPanel ap;
- ArrayList _aps = new ArrayList();
+ List _aps = new ArrayList(); // remove? never
+ // added to
String fileLoadingError;
@@ -125,7 +172,7 @@ public class AppletJmol extends EmbmenuFrame implements
String[][] boundchains, boolean align, AlignmentPanel ap,
String protocol)
{
- throw new Error("Not yet implemented.");
+ throw new Error(MessageManager.getString("error.not_yet_implemented"));
}
public AppletJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
@@ -133,10 +180,8 @@ public class AppletJmol extends EmbmenuFrame implements
{
this.ap = ap;
jmb = new AppletJmolBinding(this, ap.getStructureSelectionManager(),
- new PDBEntry[]
- { pdbentry }, new SequenceI[][]
- { seq }, new String[][]
- { chains }, protocol);
+ new PDBEntry[] { pdbentry }, new SequenceI[][] { seq },
+ new String[][] { chains }, protocol);
jmb.setColourBySequence(true);
if (pdbentry.getId() == null || pdbentry.getId().length() < 1)
{
@@ -160,7 +205,7 @@ public class AppletJmol extends EmbmenuFrame implements
String alreadyMapped = StructureSelectionManager
.getStructureSelectionManager(ap.av.applet)
.alreadyMappedToFile(pdbentry.getId());
- MCview.PDBfile reader = null;
+ StructureFile reader = null;
if (alreadyMapped != null)
{
reader = StructureSelectionManager.getStructureSelectionManager(
@@ -235,10 +280,11 @@ public class AppletJmol extends EmbmenuFrame implements
dispose();
return;
}
- jmb.newJmolPopup(true, "Jmol", true);
+ // jmb.newJmolPopup(true, "Jmol", true);
this.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowClosing(WindowEvent evt)
{
closeViewer();
@@ -302,7 +348,8 @@ public class AppletJmol extends EmbmenuFrame implements
if (freader == null)
{
throw new Exception(
- "Invalid datasource. Could not obtain Reader.");
+ MessageManager
+ .getString("exception.invalid_datasource_couldnt_obtain_reader"));
}
jmb.viewer.openReader(pdbentry.getFile(), pdbentry.getId(),
freader);
@@ -326,7 +373,7 @@ public class AppletJmol extends EmbmenuFrame implements
jmb.loadInline(string);
}
- void setChainMenuItems(Vector chains)
+ void setChainMenuItems(Vector chains)
{
chainMenu.removeAll();
@@ -336,10 +383,9 @@ public class AppletJmol extends EmbmenuFrame implements
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);
}
@@ -349,9 +395,7 @@ public class AppletJmol extends EmbmenuFrame implements
void centerViewer()
{
- Vector toshow = new Vector();
- String lbl;
- int mlength, p, mnum;
+ Vector toshow = new Vector();
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof CheckboxMenuItem)
@@ -373,6 +417,7 @@ public class AppletJmol extends EmbmenuFrame implements
this.setVisible(false);
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == mappingMenuItem)
@@ -385,12 +430,7 @@ public class AppletJmol extends EmbmenuFrame implements
StringBuffer sb = new StringBuffer();
try
{
- for (int s = 0; s < jmb.pdbentry.length; s++)
- {
- sb.append(jmb.printMapping(jmb.pdbentry[s].getFile()));
- sb.append("\n");
- }
- cap.setText(sb.toString());
+ cap.setText(jmb.printMappings());
} catch (OutOfMemoryError ex)
{
frame.dispose();
@@ -398,8 +438,9 @@ public class AppletJmol extends EmbmenuFrame implements
.println("Out of memory when trying to create dialog box with sequence-structure mapping.");
return;
}
- jalview.bin.JalviewLite.addFrame(frame, MessageManager.getString("label.pdb_sequence_mapping"),
- 550, 600);
+ jalview.bin.JalviewLite.addFrame(frame,
+ MessageManager.getString("label.pdb_sequence_mapping"), 550,
+ 600);
}
else if (evt.getSource() == charge)
{
@@ -474,7 +515,9 @@ public class AppletJmol extends EmbmenuFrame implements
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof CheckboxMenuItem)
+ {
((CheckboxMenuItem) chainMenu.getItem(i)).setState(true);
+ }
}
centerViewer();
@@ -495,6 +538,7 @@ public class AppletJmol extends EmbmenuFrame implements
jmb.setColourBySequence(itm == seqColour);
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == jmolColour)
@@ -505,35 +549,40 @@ public class AppletJmol extends EmbmenuFrame implements
else if (evt.getSource() == seqColour)
{
setEnabled(seqColour);
- jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap);
+ jmb.colourBySequence(ap);
}
else if (!allChainsSelected)
+ {
centerViewer();
+ }
}
+ @Override
public void keyPressed(KeyEvent evt)
{
if (evt.getKeyCode() == KeyEvent.VK_ENTER && scriptWindow.isVisible())
{
jmb.eval(inputLine.getText());
- history.append("\n$ " + inputLine.getText());
+ addToHistory("$ " + inputLine.getText());
inputLine.setText("");
}
}
+ @Override
public void keyTyped(KeyEvent evt)
{
}
+ @Override
public void keyReleased(KeyEvent evt)
{
}
public void updateColours(Object source)
{
- AlignmentPanel ap = (AlignmentPanel) source;
- jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap);
+ AlignmentPanel panel = (AlignmentPanel) source;
+ jmb.colourBySequence(panel);
}
public void updateTitleAndMenus()
@@ -544,7 +593,7 @@ public class AppletJmol extends EmbmenuFrame implements
return;
}
setChainMenuItems(jmb.chainNames);
- jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap);
+ jmb.colourBySequence(ap);
setTitle(jmb.getViewerTitle());
}
@@ -599,17 +648,16 @@ public class AppletJmol extends EmbmenuFrame implements
{
Dimension currentSize = new Dimension();
- Rectangle rectClip = new Rectangle();
-
+ @Override
public void update(Graphics g)
{
paint(g);
}
+ @Override
public void paint(Graphics g)
{
currentSize = this.getSize();
- rectClip = g.getClipBounds();
if (jmb.viewer == null)
{
@@ -617,11 +665,13 @@ public class AppletJmol extends EmbmenuFrame implements
g.fillRect(0, 0, currentSize.width, currentSize.height);
g.setColor(Color.white);
g.setFont(new Font("Verdana", Font.BOLD, 14));
- g.drawString(MessageManager.getString("label.retrieving_pdb_data"), 20, currentSize.height / 2);
+ g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
+ 20, currentSize.height / 2);
}
else
{
- jmb.viewer.renderScreenImage(g, currentSize, rectClip);
+ jmb.viewer.renderScreenImage(g, currentSize.width,
+ currentSize.height);
}
}
}
@@ -653,11 +703,25 @@ public class AppletJmol extends EmbmenuFrame implements
{
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;
}
+
+ /**
+ * Append the given text to the history object
+ *
+ * @param text
+ */
+ public void addToHistory(String text)
+ {
+ // actually currently never initialised
+ if (history != null)
+ {
+ history.append("\n" + text);
+ }
+ }
}