X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAppletJmol.java;h=c9f275b56d87ef1c7c2dac1c8be98b96198ed1ad;hb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;hp=f54717d8393be239f94a2fecf57a1cae09ecfe5a;hpb=a7ea1ba47dae32481aa6390a29cef6c7c5a403c4;p=jalview.git diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index f54717d..c9f275b 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -20,6 +20,23 @@ */ package jalview.appletgui; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; +import jalview.io.AppletFormatAdapter; +import jalview.io.FileParse; +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; @@ -31,7 +48,6 @@ import java.awt.Menu; import java.awt.MenuBar; import java.awt.MenuItem; import java.awt.Panel; -import java.awt.Rectangle; import java.awt.TextArea; import java.awt.TextField; import java.awt.event.ActionEvent; @@ -44,25 +60,9 @@ 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; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.io.AppletFormatAdapter; -import jalview.io.FileParse; -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; - public class AppletJmol extends EmbmenuFrame implements // StructureListener, KeyListener, ActionListener, ItemListener @@ -130,7 +130,8 @@ public class AppletJmol extends EmbmenuFrame implements AlignmentPanel ap; - ArrayList _aps = new ArrayList(); + List _aps = new ArrayList(); // remove? never + // added to String fileLoadingError; @@ -178,10 +179,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) { @@ -280,7 +279,7 @@ public class AppletJmol extends EmbmenuFrame implements dispose(); return; } - jmb.newJmolPopup(true, "Jmol", true); + // jmb.newJmolPopup(true, "Jmol", true); this.addWindowListener(new WindowAdapter() { @@ -346,7 +345,9 @@ public class AppletJmol extends EmbmenuFrame implements } if (freader == null) { - throw new Exception(MessageManager.getString("exception.invalid_datasource_couldnt_obtain_reader")); + throw new Exception( + MessageManager + .getString("exception.invalid_datasource_couldnt_obtain_reader")); } jmb.viewer.openReader(pdbentry.getFile(), pdbentry.getId(), freader); @@ -370,7 +371,7 @@ public class AppletJmol extends EmbmenuFrame implements jmb.loadInline(string); } - void setChainMenuItems(Vector chains) + void setChainMenuItems(Vector chains) { chainMenu.removeAll(); @@ -380,10 +381,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); } @@ -393,9 +393,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) @@ -547,7 +545,7 @@ public class AppletJmol extends EmbmenuFrame implements else if (evt.getSource() == seqColour) { setEnabled(seqColour); - jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap); + jmb.colourBySequence(ap); } else if (!allChainsSelected) { @@ -560,7 +558,7 @@ public class AppletJmol extends EmbmenuFrame implements if (evt.getKeyCode() == KeyEvent.VK_ENTER && scriptWindow.isVisible()) { jmb.eval(inputLine.getText()); - history.append("\n$ " + inputLine.getText()); + addToHistory("$ " + inputLine.getText()); inputLine.setText(""); } @@ -576,8 +574,8 @@ public class AppletJmol extends EmbmenuFrame implements public void updateColours(Object source) { - AlignmentPanel ap = (AlignmentPanel) source; - jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap); + AlignmentPanel panel = (AlignmentPanel) source; + jmb.colourBySequence(panel); } public void updateTitleAndMenus() @@ -588,7 +586,7 @@ public class AppletJmol extends EmbmenuFrame implements return; } setChainMenuItems(jmb.chainNames); - jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap); + jmb.colourBySequence(ap); setTitle(jmb.getViewerTitle()); } @@ -643,8 +641,6 @@ public class AppletJmol extends EmbmenuFrame implements { Dimension currentSize = new Dimension(); - Rectangle rectClip = new Rectangle(); - public void update(Graphics g) { paint(g); @@ -653,7 +649,6 @@ public class AppletJmol extends EmbmenuFrame implements public void paint(Graphics g) { currentSize = this.getSize(); - rectClip = g.getClipBounds(); if (jmb.viewer == null) { @@ -666,7 +661,8 @@ public class AppletJmol extends EmbmenuFrame implements } else { - jmb.viewer.renderScreenImage(g, currentSize, rectClip); + jmb.viewer.renderScreenImage(g, currentSize.width, + currentSize.height); } } } @@ -698,11 +694,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); + } + } }