X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=49486130b5c19cd0d61bd6f83e98580db34421f6;hb=281872ba376cdbbf4cc000ae8dc96958acae6177;hp=9e5c4fba334e129a7a482a3aeae77283ef9e1e6e;hpb=d6509fcf3a8cc90616e18cb22cec97f85c722bb8;p=jalview.git diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 9e5c4fb..4948613 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1,18 +1,18 @@ /* * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle - * + * * 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 + * 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. - * - * 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 + * + * 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 . */ package jalview.appletgui; @@ -103,7 +103,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis int DEFAULT_HEIGHT = 500; String jalviewServletURL; - + public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet, String title, boolean embedded) { @@ -233,7 +233,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * Load a features file onto the alignment - * + * * @param file file URL, content, or other resolvable path * @param type is protocol for accessing data referred to by file */ @@ -242,19 +242,19 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis { return parseFeaturesFile(file, type, true); } - + /** * Load a features file onto the alignment - * + * * @param file file URL, content, or other resolvable path * @param type is protocol for accessing data referred to by file * @param autoenabledisplay when true, display features flag will be automatically enabled if features are loaded * @return true if data parsed as a features file */ public boolean parseFeaturesFile(String file, String type, boolean autoenabledisplay) - { + { // TODO: test if importing a features file onto an alignment which already has features with links overwrites the original links. - + Hashtable featureLinks = new Hashtable(); boolean featuresFile = false; try @@ -289,6 +289,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis return featuresFile; } + @Override public void keyPressed(KeyEvent evt) { if (viewport.cursorMode @@ -302,8 +303,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis { case 27: // escape key deselectAllSequenceMenuItem_actionPerformed(); - - alignPanel.alabels.cancelDrag(); + + alignPanel.alabels.cancelDrag(); break; case KeyEvent.VK_X: if (evt.isControlDown() || evt.isMetaDown()) @@ -550,7 +551,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * called by key handler and the hide all/show all menu items - * + * * @param toggleSeqs * @param toggleCols */ @@ -615,14 +616,17 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis } } + @Override public void keyReleased(KeyEvent evt) { } + @Override public void keyTyped(KeyEvent evt) { } + @Override public void itemStateChanged(ItemEvent evt) { if (evt.getSource() == displayNonconservedMenuItem) @@ -739,6 +743,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis this.alignPanel.annotationPanel.repaint(); } + @Override public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); @@ -1112,7 +1117,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300); } - + public String outputAnnotations(boolean displayTextbox) { String annotation = new AnnotationFile().printAnnotations( @@ -1174,7 +1179,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis features = "# No features visible - paste some and import them here."; frimport=true; } - + CutAndPasteTransfer cap = new CutAndPasteTransfer(frimport, this); if (frimport) { @@ -1353,7 +1358,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * TODO: JAL-1104 * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1382,7 +1387,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * TODO: JAL-1104 * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1457,48 +1462,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis { return; } - - if (up) - { - for (int i = 1; i < viewport.getAlignment().getHeight(); i++) - { - SequenceI seq = viewport.getAlignment().getSequenceAt(i); - if (!sg.getSequences(null).contains(seq)) - { - continue; - } - - SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1); - if (sg.getSequences(null).contains(temp)) - { - continue; - } - - viewport.getAlignment().getSequences().setElementAt(temp, i); - viewport.getAlignment().getSequences().setElementAt(seq, i - 1); - } - } - else - { - for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--) - { - SequenceI seq = viewport.getAlignment().getSequenceAt(i); - if (!sg.getSequences(viewport.getHiddenRepSequences()).contains(seq)) - { - continue; - } - - SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1); - if (sg.getSequences(viewport.getHiddenRepSequences()).contains(temp)) - { - continue; - } - - viewport.getAlignment().getSequences().setElementAt(temp, i); - viewport.getAlignment().getSequences().setElementAt(seq, i + 1); - } - } - + viewport.getAlignment().moveSelectedSequencesByOne(sg, up ? null : viewport.getHiddenRepSequences(), up); alignPanel.paintAlignment(true); } @@ -1535,7 +1499,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis SequenceI[] seqs2 = invertGroup.toArray(new SequenceI[invertGroup.size()]); for (int i = 0; i < invertGroup.size(); i++) - seqs2[i] = (SequenceI) invertGroup.elementAt(i); + seqs2[i] = invertGroup.elementAt(i); SlideSequencesCommand ssc; if (right) @@ -1827,7 +1791,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * group consensus toggled - * + * */ protected void showGroupConsensus_actionPerformed() { @@ -1847,7 +1811,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt * .event.ActionEvent) @@ -1859,7 +1823,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis } /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt * .event.ActionEvent) @@ -2110,7 +2074,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * create a new view derived from the current view - * + * * @param viewtitle * @return frame for the new view */ @@ -2183,7 +2147,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis } /** - * + * * @return list of feature groups on the view */ public String[] getFeatureGroups() @@ -2199,7 +2163,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * get sequence feature groups that are hidden or shown - * + * * @param visible * true is visible * @return list @@ -2217,7 +2181,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * Change the display state for the given feature groups - * + * * @param groups * list of group strings * @param state @@ -2288,6 +2252,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis final AlignmentPanel ap=alignPanel; frame.addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { if (ap!=null) { @@ -2344,7 +2309,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis cs.setConsensus(viewport.getSequenceConsensusHash()); - } + } viewport.setGlobalColourScheme(cs); @@ -2571,7 +2536,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * sort the alignment using the given treePanel - * + * * @param treePanel * tree used to sort view * @param title @@ -2592,7 +2557,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * Do any automatic reordering of the alignment and add the necessary bits to * the menu structure for the new tree - * + * * @param treePanel * @param title */ @@ -2603,14 +2568,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis sortByTreeMenu.add(item); item.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(ActionEvent evt) { sortByTree(treePanel, title); // treePanel.getTitle()); } }); - + treePanel.addWindowListener(new WindowAdapter() { + @Override public void windowOpened(WindowEvent e) { if (viewport.sortByTree) @@ -2620,6 +2587,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis super.windowOpened(e); } + @Override public void windowClosing(WindowEvent e) { sortByTreeMenu.remove(item); @@ -2663,6 +2631,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis this.builddate = builddate; } + @Override public void paint(Graphics g) { g.setColor(Color.white); @@ -2732,7 +2701,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis MenuItem loadTree = new MenuItem("Load Associated Tree ..."); MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ..."); - + MenuItem outputFeatures = new MenuItem("Export Features ..."); MenuItem outputAnnotations = new MenuItem("Export Annotations ..."); @@ -2807,13 +2776,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis MenuItem purinePyrimidineColour = new MenuItem(); MenuItem RNAHelixColour = new MenuItem(); - + MenuItem userDefinedColour = new MenuItem(); MenuItem PIDColour = new MenuItem(); MenuItem BLOSUM62Colour = new MenuItem(); - + MenuItem tcoffeeColour = new MenuItem(); MenuItem njTreeBlosumMenuItem = new MenuItem(); @@ -2901,7 +2870,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis CheckboxMenuItem seqLimits = new CheckboxMenuItem(); CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem(); - + CheckboxMenuItem followMouseOverFlag = new CheckboxMenuItem(); Menu autoAnnMenu=new Menu(); CheckboxMenuItem showSequenceLogo= new CheckboxMenuItem(); @@ -2926,6 +2895,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis item.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(ActionEvent e) { outputText_actionPerformed(e); @@ -3126,7 +3096,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis applyAutoAnnotationSettings.setLabel("Apply to all groups"); applyAutoAnnotationSettings.setState(true); autoAnnMenu.setLabel("Autocalculated Annotation"); - + invertColSel.addActionListener(this); showColumns.addActionListener(this); showSeqs.addActionListener(this); @@ -3156,7 +3126,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis fileMenu.add(inputText); fileMenu.add(loadTree); fileMenu.add(loadAnnotations); - + fileMenu.addSeparator(); fileMenu.add(outputTextboxMenu); fileMenu.add(outputFeatures); @@ -3314,7 +3284,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis * Attach the alignFrame panels after embedding menus, if necessary. This used * to be called setEmbedded, but is now creates the dropdown menus in a * platform independent manner to avoid OSX/Mac menu appendage daftness. - * + * * @param reallyEmbedded * true to attach the view to the applet area on the page rather than * in a new window @@ -3342,14 +3312,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis final AlignFrame me = this; viewport.applet.addFocusListener(new FocusListener() { - + @Override public void focusLost(FocusEvent e) { if (me.viewport.applet.currentAlignFrame==me) { me.viewport.applet.currentAlignFrame = null; }} - + @Override public void focusGained(FocusEvent e) { @@ -3384,7 +3354,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis * structures in the original jmol window. Note This method doesn't work * without an additional javascript library to exchange messages between the * distinct applets. See http://issues.jalview.org/browse/JAL-621 - * + * * @param viewer * JmolViewer instance * @param sequenceIds @@ -3449,7 +3419,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis } /** * bind a pdb file to a sequence in the current view - * + * * @param sequenceId * - sequenceId within the dataset. * @param pdbEntryString @@ -3621,7 +3591,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis /** * modify the current selection, providing the user has not made a selection already. - * @param sel - sequences from this alignment + * @param sel - sequences from this alignment * @param csel - columns to be selected on the alignment */ public void select(SequenceGroup sel, ColumnSelection csel) @@ -3631,15 +3601,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis public void scrollTo(int row, int column) { - alignPanel.seqPanel.scrollTo(row, column); + alignPanel.seqPanel.scrollTo(row, column); } public void scrollToRow(int row) { - alignPanel.seqPanel.scrollToRow(row); + alignPanel.seqPanel.scrollToRow(row); } public void scrollToColumn(int column) { - alignPanel.seqPanel.scrollToColumn(column); + alignPanel.seqPanel.scrollToColumn(column); } /** * @return the alignments unique ID. @@ -3647,13 +3617,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis public String getSequenceSetId() { return viewport.getSequenceSetId(); } - - + + /** - * Load the (T-Coffee) score file from the specified url - * + * Load the (T-Coffee) score file from the specified url + * * @param source File/URL/T-COFFEE score file contents - * @throws IOException + * @throws IOException * @return true if alignment was annotated with data from source */ public boolean loadScoreFile( String source ) throws IOException { @@ -3665,17 +3635,17 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis System.err.println("Origin was:\n"+source); return false; } - + /* * check that the score matrix matches the alignment dimensions */ - AlignmentI aln; + AlignmentI aln; if( (aln=viewport.getAlignment()) != null && (aln.getHeight() != file.getHeight() || aln.getWidth() != file.getWidth()) ) { // TODO: raise a dialog box here rather than bomb out. System.err.println("The scores matrix does not match the alignment dimensions"); - + } - + // TODO add parameter to indicate if matching should be done if (file.annotateAlignment(alignPanel.getAlignment(), false)) { @@ -3692,6 +3662,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis } return false; } - - + + }