X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=41685169e7ce5a0e028ea3dc0cf4720e74d15324;hb=51cf18a50c67ce904cde4a869e434d06b209394a;hp=8396e6a80d109b87b368ab3296b1a04e3c9aa8d5;hpb=071ecbceb65b4207d9ce866ffc0aa31d200d35ef;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java old mode 100755 new mode 100644 index 8396e6a..4168516 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1,29 +1,36 @@ /* - * 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 - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 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. - * - * 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 + * 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 * 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.gui; import jalview.analysis.AAFrequency; import jalview.analysis.AlignmentSorter; +import jalview.analysis.AlignmentUtils; import jalview.analysis.Conservation; import jalview.analysis.CrossRef; import jalview.analysis.NJTree; import jalview.analysis.ParseProperties; import jalview.analysis.SequenceIdMatcher; +import jalview.api.AlignViewControllerGuiI; +import jalview.api.AlignViewControllerI; +import jalview.api.analysis.ScoreModelI; import jalview.bin.Cache; import jalview.commands.CommandI; import jalview.commands.EditCommand; @@ -75,12 +82,13 @@ import jalview.schemes.TaylorColourScheme; import jalview.schemes.TurnColourScheme; import jalview.schemes.UserColourScheme; import jalview.schemes.ZappoColourScheme; +import jalview.util.MessageManager; import jalview.ws.jws1.Discoverer; import jalview.ws.jws2.Jws2Discoverer; +import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.seqfetcher.DbSourceProxy; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Component; import java.awt.GridLayout; import java.awt.Rectangle; @@ -112,6 +120,7 @@ import java.util.List; import java.util.Vector; import javax.swing.JButton; +import javax.swing.JCheckBoxMenuItem; import javax.swing.JEditorPane; import javax.swing.JInternalFrame; import javax.swing.JLabel; @@ -127,12 +136,12 @@ import javax.swing.SwingUtilities; /** * DOCUMENT ME! - * + * * @author $author$ * @version $Revision$ */ public class AlignFrame extends GAlignFrame implements DropTargetListener, - IProgressIndicator + IProgressIndicator, AlignViewControllerGuiI { /** DOCUMENT ME!! */ @@ -145,6 +154,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignViewport viewport; + public AlignViewControllerI avc; + Vector alignPanels = new Vector(); /** @@ -159,7 +170,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Creates a new AlignFrame object with specific width and height. - * + * * @param al * @param width * @param height @@ -172,7 +183,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Creates a new AlignFrame object with specific width, height and * sequenceSetId - * + * * @param al * @param width * @param height @@ -187,7 +198,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Creates a new AlignFrame object with specific width, height and * sequenceSetId - * + * * @param al * @param width * @param height @@ -202,7 +213,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * new alignment window with hidden columns - * + * * @param al * AlignmentI * @param hiddenColumns @@ -221,7 +232,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Create alignment frame for al with hiddenColumns, a specific width and * height, and specific sequenceId - * + * * @param al * @param hiddenColumns * @param width @@ -238,7 +249,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Create alignment frame for al with hiddenColumns, a specific width and * height, and specific sequenceId - * + * * @param al * @param hiddenColumns * @param width @@ -252,22 +263,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, int width, int height, String sequenceSetId, String viewId) { setSize(width, height); - viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId); - - alignPanel = new AlignmentPanel(this, viewport); if (al.getDataset() == null) { al.setDataset(null); } + viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId); + + alignPanel = new AlignmentPanel(this, viewport); + + addAlignmentPanel(alignPanel, true); init(); } /** * Make a new AlignFrame from exisiting alignmentPanels - * + * * @param ap * AlignmentPanel * @param av @@ -287,6 +300,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ void init() { + avc = new jalview.controller.AlignViewController(this, viewport, + alignPanel); if (viewport.getAlignmentConservationAnnotation() == null) { BLOSUM62Colour.setEnabled(false); @@ -318,6 +333,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, setMenusFromViewport(viewport); buildSortByAnnotationScoresMenu(); + buildTreeMenu(); + buildShowHideAnnotationMenus(); + if (viewport.wrapAlignment) { wrapMenuItem_actionPerformed(null); @@ -335,7 +353,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Change the filename and format for the alignment, and enable the 'reload' * button functionality. - * + * * @param file * valid filename * @param format @@ -475,8 +493,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, case KeyEvent.VK_F2: viewport.cursorMode = !viewport.cursorMode; - statusBar.setText("Keyboard editing mode is " - + (viewport.cursorMode ? "on" : "off")); + statusBar.setText(MessageManager.formatMessage( + "label.keyboard_editing_mode", new String[] + { (viewport.cursorMode ? "on" : "off") })); if (viewport.cursorMode) { alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; @@ -557,6 +576,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void addAlignmentPanel(final AlignmentPanel ap, boolean newPanel) { ap.alignFrame = this; + avc = new jalview.controller.AlignViewController(this, viewport, + alignPanel); alignPanels.addElement(ap); @@ -691,7 +712,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Need to call this method when tabs are selected for multiple views, or when * loading from Jalview2XML.java - * + * * @param av * AlignViewport */ @@ -734,16 +755,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, rnahelicesColour .setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour); setShowProductsEnabled(); - updateEditMenuBar(); } + // methods for implementing IProgressIndicator // need to refactor to a reusable stub class Hashtable progressBars, progressBarHandlers; /* * (non-Javadoc) - * + * * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long) */ @Override @@ -807,7 +828,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, final JPanel progressPanel = (JPanel) progressBars.get(new Long(id)); if (handler.canCancel()) { - JButton cancel = new JButton("Cancel"); + JButton cancel = new JButton( + MessageManager.getString("action.cancel")); final IProgressIndicator us = this; cancel.addActionListener(new ActionListener() { @@ -827,7 +849,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * + * * @return true if any progress bars are still active */ @Override @@ -840,6 +862,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return false; } + @Override + public void setStatus(String text) + { + statusBar.setText(text); + }; + /* * Added so Castor Mapping file can obtain Jalview Version */ @@ -880,7 +908,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, for (int i = 0; i < frames.length; i++) { if (frames[i] instanceof AlignFrame && frames[i] != this - && ((AlignFrame) frames[i]).fileName!=null && ((AlignFrame) frames[i]).fileName.equals(fileName)) + && ((AlignFrame) frames[i]).fileName != null + && ((AlignFrame) frames[i]).fileName.equals(fileName)) { try { @@ -961,7 +990,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -976,7 +1005,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Save Alignment to file"); - chooser.setToolTipText("Save"); + chooser.setToolTipText(MessageManager.getString("action.save")); int value = chooser.showSaveDialog(this); @@ -985,9 +1014,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, currentFileFormat = chooser.getSelectedFormat(); if (currentFileFormat == null) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "You must select a file format before saving!", - "File format not specified", JOptionPane.WARNING_MESSAGE); + JOptionPane + .showInternalMessageDialog( + Desktop.desktop, + MessageManager + .getString("label.select_file_format_before_saving"), + MessageManager + .getString("label.file_format_not_specified"), + JOptionPane.WARNING_MESSAGE); value = chooser.showSaveDialog(this); return; } @@ -1023,8 +1057,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, success = new Jalview2XML().SaveAlignment(this, file, shortName); - statusBar.setText("Successfully saved to file: " + fileName + " in " - + format + " format."); + statusBar.setText(MessageManager.formatMessage( + "label.successfully_saved_to_file_in_format", new String[] + { fileName, format })); } else @@ -1045,9 +1080,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, int reply = JOptionPane .showInternalConfirmDialog( Desktop.desktop, - "The Alignment contains hidden columns." - + "\nDo you want to save only the visible alignment?", - "Save / Omit Hidden Columns", + MessageManager + .getString("label.alignment_contains_hidden_columns"), + MessageManager + .getString("action.save_omit_hidden_columns"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); @@ -1057,8 +1093,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } FormatAdapter f = new FormatAdapter(); - String output = f.formatSequences( - format, + String output = f.formatSequences(format, viewport.getAlignment(), // class cast exceptions will // occur in the distant future omitHidden, f.getCacheSuffixDefault(format), @@ -1078,8 +1113,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, out.print(output); out.close(); this.setTitle(file); - statusBar.setText("Successfully saved to file: " + fileName - + " in " + format + " format."); + statusBar.setText(MessageManager.formatMessage( + "label.successfully_saved_to_file_in_format", + new String[] + { fileName, format })); } catch (Exception ex) { success = false; @@ -1090,8 +1127,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (!success) { - JOptionPane.showInternalMessageDialog(this, "Couldn't save file: " - + fileName, "Error Saving File", JOptionPane.WARNING_MESSAGE); + JOptionPane.showInternalMessageDialog(this, MessageManager + .formatMessage("label.couldnt_save_file", new String[] + { fileName }), MessageManager + .getString("label.error_saving_file"), + JOptionPane.WARNING_MESSAGE); } return success; @@ -1114,7 +1154,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1128,9 +1168,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, int reply = JOptionPane .showInternalConfirmDialog( Desktop.desktop, - "The Alignment contains hidden columns." - + "\nDo you want to output only the visible alignment?", - "Save / Omit Hidden Columns", + MessageManager + .getString("label.alignment_contains_hidden_columns"), + MessageManager + .getString("action.save_omit_hidden_columns"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); @@ -1148,8 +1189,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), viewport.getAlignment(), omitHidden, viewport.getColumnSelection())); - Desktop.addInternalFrame(cap, - "Alignment output - " + e.getActionCommand(), 600, 500); + Desktop.addInternalFrame(cap, MessageManager.formatMessage( + "label.alignment_output_command", new String[] + { e.getActionCommand() }), 600, 500); } catch (OutOfMemoryError oom) { new OOMWarning("Outputting alignment as " + e.getActionCommand(), oom); @@ -1160,7 +1202,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1179,7 +1221,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1191,7 +1233,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1210,7 +1252,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1245,8 +1287,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, JalviewFileChooser chooser = new JalviewFileChooser( jalview.bin.Cache.getProperty("LAST_DIRECTORY")); chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Load Jalview Annotations or Features File"); - chooser.setToolTipText("Load Jalview Annotations / Features file"); + chooser.setDialogTitle(MessageManager + .getString("label.load_jalview_annotations")); + chooser.setToolTipText(MessageManager + .getString("label.load_jalview_annotations")); int value = chooser.showOpenDialog(null); @@ -1262,7 +1306,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Close the current view or all views in the alignment frame. If the frame * only contains one view then the alignment will be removed from memory. - * + * * @param closeAllTabs */ @Override @@ -1308,7 +1352,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * close alignPanel2 and shuffle tabs appropriately. - * + * * @param alignPanel2 */ public void closeView(AlignmentPanel alignPanel2) @@ -1346,12 +1390,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { undoMenuItem.setEnabled(true); CommandI command = (CommandI) viewport.historyList.peek(); - undoMenuItem.setText("Undo " + command.getDescription()); + undoMenuItem.setText(MessageManager.formatMessage( + "label.undo_command", new String[] + { command.getDescription() })); } else { undoMenuItem.setEnabled(false); - undoMenuItem.setText("Undo"); + undoMenuItem.setText(MessageManager.getString("action.undo")); } if (viewport.redoList.size() > 0) @@ -1359,12 +1405,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, redoMenuItem.setEnabled(true); CommandI command = (CommandI) viewport.redoList.peek(); - redoMenuItem.setText("Redo " + command.getDescription()); + redoMenuItem.setText(MessageManager.formatMessage( + "label.redo_command", new String[] + { command.getDescription() })); } else { redoMenuItem.setEnabled(false); - redoMenuItem.setText("Redo"); + redoMenuItem.setText(MessageManager.getString("action.redo")); } } @@ -1384,7 +1432,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * + * * @return alignment objects for all views */ AlignmentI[] getViewAlignments() @@ -1409,7 +1457,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1445,7 +1493,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1527,7 +1575,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param up * DOCUMENT ME! */ @@ -1539,7 +1587,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { return; } - viewport.getAlignment().moveSelectedSequencesByOne(sg, viewport.getHiddenRepSequences(), up); + viewport.getAlignment().moveSelectedSequencesByOne(sg, + viewport.getHiddenRepSequences(), up); alignPanel.paintAlignment(true); } @@ -1627,7 +1676,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1691,12 +1740,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, Desktop.jalviewClipboard = new Object[] { seqs, viewport.getAlignment().getDataset(), hiddenColumns }; - statusBar.setText("Copied " + seqs.length + " sequences to clipboard."); + statusBar.setText(MessageManager.formatMessage( + "label.copied_sequences_to_clipboard", new String[] + { Integer.valueOf(seqs.length).toString() })); } /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1708,7 +1759,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -1720,7 +1771,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Paste contents of Jalview clipboard - * + * * @param newAlignment * true to paste to a new alignment, otherwise add to this. */ @@ -1781,8 +1832,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } int alwidth = 0; - ArrayList newGraphGroups=new ArrayList(); - int fgroup=-1; + ArrayList newGraphGroups = new ArrayList(); + int fgroup = -1; if (newAlignment) { @@ -1850,13 +1901,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { newDs.clear(); // tidy up } - if (alignment.getAlignmentAnnotation()!=null) + if (alignment.getAlignmentAnnotation() != null) { - for (AlignmentAnnotation alan:alignment.getAlignmentAnnotation()) + for (AlignmentAnnotation alan : alignment + .getAlignmentAnnotation()) { - if (alan.graphGroup>fgroup) + if (alan.graphGroup > fgroup) { - fgroup=alan.graphGroup; + fgroup = alan.graphGroup; } } } @@ -1870,17 +1922,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (alann[i].sequenceRef == null && !alann[i].autoCalculated) { AlignmentAnnotation newann = new AlignmentAnnotation(alann[i]); - if (newann.graphGroup>-1) + if (newann.graphGroup > -1) { - if (newGraphGroups.size()<=newann.graphGroup || newGraphGroups.get(newann.graphGroup)==null) + if (newGraphGroups.size() <= newann.graphGroup + || newGraphGroups.get(newann.graphGroup) == null) { - for (int q=newGraphGroups.size();q<=newann.graphGroup; q++) + for (int q = newGraphGroups.size(); q <= newann.graphGroup; q++) { newGraphGroups.add(q, null); } - newGraphGroups.set(newann.graphGroup,new Integer(++fgroup)); + newGraphGroups.set(newann.graphGroup, new Integer( + ++fgroup)); } - newann.graphGroup = newGraphGroups.get(newann.graphGroup).intValue(); + newann.graphGroup = newGraphGroups.get(newann.graphGroup) + .intValue(); } newann.padAnnotation(alwidth); @@ -1906,22 +1961,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, for (int a = 0; a < sequences[i].getAnnotation().length; a++) { annotationAdded = true; - newann=sequences[i].getAnnotation()[a]; + newann = sequences[i].getAnnotation()[a]; newann.adjustForAlignment(); newann.padAnnotation(alwidth); - if (newann.graphGroup>-1) + if (newann.graphGroup > -1) { - if (newann.graphGroup>-1) + if (newann.graphGroup > -1) { - if (newGraphGroups.size()<=newann.graphGroup || newGraphGroups.get(newann.graphGroup)==null) + if (newGraphGroups.size() <= newann.graphGroup + || newGraphGroups.get(newann.graphGroup) == null) { - for (int q=newGraphGroups.size();q<=newann.graphGroup; q++) + for (int q = newGraphGroups.size(); q <= newann.graphGroup; q++) { newGraphGroups.add(q, null); } - newGraphGroups.set(newann.graphGroup,new Integer(++fgroup)); + newGraphGroups.set(newann.graphGroup, new Integer( + ++fgroup)); } - newann.graphGroup = newGraphGroups.get(newann.graphGroup).intValue(); + newann.graphGroup = newGraphGroups.get(newann.graphGroup) + .intValue(); } } alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation @@ -1963,7 +2021,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, newann.padAnnotation(avwidth); alview[avnum].addAnnotation(newann); // annotation was // duplicated earlier - // TODO JAL-1145 graphGroups are not updated for sequence annotation added to several views. This may cause strangeness + // TODO JAL-1145 graphGroups are not updated for sequence + // annotation added to several views. This may cause + // strangeness alview[avnum].setAnnotationIndex(newann, a); } } @@ -1973,10 +2033,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } viewport.firePropertyChange("alignment", null, alignment.getSequences()); - if (alignPanels!=null ) {for (AlignmentPanel ap:((Vector)alignPanels)) + if (alignPanels != null) + { + for (AlignmentPanel ap : ((Vector) alignPanels)) + { + ap.validateAnnotationDimensions(false); + } + } + else { - ap.validateAnnotationDimensions(false); - }} else { alignPanel.validateAnnotationDimensions(false);} + alignPanel.validateAnnotationDimensions(false); + } } else @@ -2034,9 +2101,63 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } + @Override + protected void expand_newalign(ActionEvent e) + { + try + { + AlignmentI alignment = AlignmentUtils.expandContext(getViewport() + .getAlignment(), -1); + AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, + DEFAULT_HEIGHT); + String newtitle = new String("Flanking alignment"); + + if (Desktop.jalviewClipboard != null + && Desktop.jalviewClipboard[2] != null) + { + Vector hc = (Vector) Desktop.jalviewClipboard[2]; + for (int i = 0; i < hc.size(); i++) + { + int[] region = (int[]) hc.elementAt(i); + af.viewport.hideColumns(region[0], region[1]); + } + } + + // >>>This is a fix for the moment, until a better solution is + // found!!<<< + af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer() + .transferSettings( + alignPanel.seqPanel.seqCanvas.getFeatureRenderer()); + + // TODO: maintain provenance of an alignment, rather than just make the + // title a concatenation of operations. + { + if (title.startsWith("Copied sequences")) + { + newtitle = title; + } + else + { + newtitle = newtitle.concat("- from " + title); + } + } + + Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH, DEFAULT_HEIGHT); + + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Exception whilst pasting: " + ex); + // could be anything being pasted in here + } catch (OutOfMemoryError oom) + { + new OOMWarning("Viewing flanking region of alignment", oom); + } + } + /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2049,7 +2170,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2110,24 +2231,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @Override protected void deleteGroups_actionPerformed(ActionEvent e) { - viewport.getAlignment().deleteAllGroups(); - viewport.sequenceColours = null; - viewport.setSelectionGroup(null); - PaintRefresher.Refresh(this, viewport.getSequenceSetId()); - alignPanel.updateAnnotation(); - alignPanel.paintAlignment(true); + if (avc.deleteGroups()) + { + PaintRefresher.Refresh(this, viewport.getSequenceSetId()); + alignPanel.updateAnnotation(); + alignPanel.paintAlignment(true); + } } /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2150,7 +2271,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2174,7 +2295,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2210,7 +2331,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2222,7 +2343,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2276,11 +2397,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.getSelectionGroup()); } - statusBar.setText("Removed " + trimRegion.getSize() + " columns."); + statusBar.setText(MessageManager.formatMessage( + "label.removed_columns", new String[] + { Integer.valueOf(trimRegion.getSize()).toString() })); addHistoryItem(trimRegion); - for (SequenceGroup sg :viewport.getAlignment().getGroups()) + for (SequenceGroup sg : viewport.getAlignment().getGroups()) { if ((trimLeft && !sg.adjustForRemoveLeft(column)) || (!trimLeft && !sg.adjustForRemoveRight(column))) @@ -2296,7 +2419,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2324,8 +2447,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, addHistoryItem(removeGapCols); - statusBar.setText("Removed " + removeGapCols.getSize() - + " empty columns."); + statusBar.setText(MessageManager.formatMessage( + "label.removed_empty_columns", new String[] + { Integer.valueOf(removeGapCols.getSize()).toString() })); // This is to maintain viewport position on first residue // of first sequence @@ -2344,7 +2468,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2383,7 +2507,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2407,7 +2531,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2424,7 +2548,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * + * * @param copyAnnotation * if true then duplicate all annnotation, groups and settings * @return new alignment panel, already displayed. @@ -2435,7 +2559,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * + * * @param viewTitle * title of newly created view * @return new alignment panel, already displayed. @@ -2446,7 +2570,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * + * * @param viewTitle * title of newly created view * @param copyAnnotation @@ -2519,6 +2643,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, newap.av.viewName = newViewName; addAlignmentPanel(newap, true); + newap.alignmentChanged(); if (alignPanels.size() == 2) { @@ -2542,7 +2667,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2554,7 +2679,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2584,7 +2709,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed() */ @Override @@ -2599,7 +2724,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2612,7 +2737,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2648,7 +2773,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * called by key handler and the hide all/show all menu items - * + * * @param toggleSeqs * @param toggleCols */ @@ -2718,7 +2843,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt. * event.ActionEvent) @@ -2731,7 +2856,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event * .ActionEvent) @@ -2748,7 +2873,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event. * ActionEvent) @@ -2777,7 +2902,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2790,7 +2915,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2803,7 +2928,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2816,7 +2941,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2829,7 +2954,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2842,7 +2967,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2874,7 +2999,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Set or clear 'Show Sequence Features' - * + * * @param evt * DOCUMENT ME! */ @@ -2891,7 +3016,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Set or clear 'Show Sequence Features' - * + * * @param evt * DOCUMENT ME! */ @@ -2915,7 +3040,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2933,17 +3058,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, editPane.setEditable(false); StringBuffer contents = new AlignmentProperties(viewport.getAlignment()) .formatAsHtml(); - editPane.setText("" + contents.toString() + ""); + editPane.setText(MessageManager.formatMessage("label.html_content", + new String[] + { contents.toString() })); JInternalFrame frame = new JInternalFrame(); frame.getContentPane().add(new JScrollPane(editPane)); - Desktop.instance.addInternalFrame(frame, "Alignment Properties: " - + getTitle(), 500, 400); + Desktop.instance.addInternalFrame(frame, MessageManager.formatMessage( + "label.alignment_properties", new String[] + { getTitle() }), 500, 400); } /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2958,8 +3086,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, JInternalFrame frame = new JInternalFrame(); OverviewPanel overview = new OverviewPanel(alignPanel); frame.setContentPane(overview); - Desktop.addInternalFrame(frame, "Overview " + this.getTitle(), - frame.getWidth(), frame.getHeight()); + Desktop.addInternalFrame(frame, MessageManager.formatMessage( + "label.overview_params", new String[] + { this.getTitle() }), frame.getWidth(), frame.getHeight()); frame.pack(); frame.setLayer(JLayeredPane.PALETTE_LAYER); frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() @@ -2983,7 +3112,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -2995,19 +3124,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @Override public void clustalColour_actionPerformed(ActionEvent e) { - changeColour(new ClustalxColourScheme(viewport.getAlignment(), viewport.getHiddenRepSequences())); + changeColour(new ClustalxColourScheme(viewport.getAlignment(), + viewport.getHiddenRepSequences())); } /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3019,7 +3149,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3031,7 +3161,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3043,7 +3173,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3055,7 +3185,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3067,7 +3197,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3079,7 +3209,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3091,7 +3221,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3127,7 +3257,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3139,7 +3269,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param cs * DOCUMENT ME! */ @@ -3154,10 +3284,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background"); - cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus()); - - viewport.setGlobalColourScheme(cs); } else { @@ -3193,8 +3320,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (viewport.getColourAppliesToAllGroups()) { - - for (SequenceGroup sg:viewport.getAlignment().getGroups()) + for (SequenceGroup sg : viewport.getAlignment().getGroups()) { if (cs == null) { @@ -3204,8 +3330,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (cs instanceof ClustalxColourScheme) { - sg.cs = new ClustalxColourScheme(sg, viewport - .getHiddenRepSequences()); + sg.cs = new ClustalxColourScheme(sg, + viewport.getHiddenRepSequences()); } else if (cs instanceof UserColourScheme) { @@ -3263,7 +3389,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3281,7 +3407,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3299,7 +3425,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3318,7 +3444,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3337,14 +3463,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @Override public void userDefinedColour_actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("User Defined...")) + if (e.getActionCommand().equals( + MessageManager.getString("action.user_defined"))) { new UserDefinedColours(alignPanel, null); } @@ -3393,8 +3520,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, int option = JOptionPane.showInternalConfirmDialog( jalview.gui.Desktop.desktop, - "Remove from default list?", - "Remove user defined colour", + MessageManager + .getString("label.remove_from_default_list"), + MessageManager + .getString("label.remove_user_defined_colour"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { @@ -3433,7 +3562,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3445,7 +3574,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3457,7 +3586,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3474,7 +3603,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3490,7 +3619,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3506,7 +3635,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3523,7 +3652,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3535,7 +3664,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3545,21 +3674,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if ((viewport.getSelectionGroup() == null) || (viewport.getSelectionGroup().getSize() < 2)) { - JOptionPane.showInternalMessageDialog(this, - "You must select at least 2 sequences.", "Invalid Selection", + JOptionPane.showInternalMessageDialog(this, MessageManager + .getString("label.you_must_select_least_two_sequences"), + MessageManager.getString("label.invalid_selection"), JOptionPane.WARNING_MESSAGE); } else { JInternalFrame frame = new JInternalFrame(); frame.setContentPane(new PairwiseAlignPanel(viewport)); - Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500); + Desktop.addInternalFrame(frame, + MessageManager.getString("action.pairwise_alignment"), 600, + 500); } } /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3571,11 +3703,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .getSelectionGroup().getSize() > 0)) || (viewport.getAlignment().getHeight() < 4)) { - JOptionPane.showInternalMessageDialog(this, - "Principal component analysis must take\n" - + "at least 4 input sequences.", - "Sequence selection insufficient", - JOptionPane.WARNING_MESSAGE); + JOptionPane + .showInternalMessageDialog( + this, + MessageManager + .getString("label.principal_component_analysis_must_take_least_four_input_sequences"), + MessageManager + .getString("label.sequence_selection_insufficient"), + JOptionPane.WARNING_MESSAGE); return; } @@ -3608,7 +3743,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3620,7 +3755,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3632,7 +3767,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3644,7 +3779,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -3656,7 +3791,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param type * DOCUMENT ME! * @param pwType @@ -3668,33 +3803,36 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { TreePanel tp; - if (viewport.getSelectionGroup() != null) + if (viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() > 0) { if (viewport.getSelectionGroup().getSize() < 3) { JOptionPane .showMessageDialog( Desktop.desktop, - "You need to have more than two sequences selected to build a tree!", - "Not enough sequences", JOptionPane.WARNING_MESSAGE); + MessageManager + .getString("label.you_need_more_two_sequences_selected_build_tree"), + MessageManager + .getString("label.not_enough_sequences"), + JOptionPane.WARNING_MESSAGE); return; } SequenceGroup sg = viewport.getSelectionGroup(); /* Decide if the selection is a column region */ - for (SequenceI _s:sg.getSequences()) + for (SequenceI _s : sg.getSequences()) { - if (_s.getLength() < sg - .getEndRes()) + if (_s.getLength() < sg.getEndRes()) { JOptionPane .showMessageDialog( Desktop.desktop, - "The selected region to create a tree may\nonly contain residues or gaps.\n" - + "Try using the Pad function in the edit menu,\n" - + "or one of the multiple sequence alignment web services.", - "Sequences in selection are not aligned", + MessageManager + .getString("label.selected_region_to_tree_may_only_contain_residues_or_gaps"), + MessageManager + .getString("label.sequences_selection_not_aligned"), JOptionPane.WARNING_MESSAGE); return; @@ -3712,10 +3850,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, JOptionPane .showMessageDialog( Desktop.desktop, - "The sequences must be aligned before creating a tree.\n" - + "Try using the Pad function in the edit menu,\n" - + "or one of the multiple sequence alignment web services.", - "Sequences not aligned", + MessageManager + .getString("label.sequences_must_be_aligned_before_creating_tree"), + MessageManager + .getString("label.sequences_not_aligned"), JOptionPane.WARNING_MESSAGE); return; @@ -3743,7 +3881,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param title * DOCUMENT ME! * @param order @@ -3775,7 +3913,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Add a new sort by annotation score menu item - * + * * @param sort * the menu to add the option to * @param scoreLabel @@ -3812,7 +3950,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * search the alignment and rebuild the sort by annotation score submenu the * last alignment annotation vector hash is stored to minimize cost of * rebuilding in subsequence calls. - * + * */ @Override public void buildSortByAnnotationScoresMenu() @@ -3828,7 +3966,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // almost certainly a quicker way to do this - but we keep it simple Hashtable scoreSorts = new Hashtable(); AlignmentAnnotation aann[]; - for (SequenceI sqa:viewport.getAlignment().getSequences()) + for (SequenceI sqa : viewport.getAlignment().getSequences()) { aann = sqa.getAnnotation(); for (int i = 0; aann != null && i < aann.length; i++) @@ -3859,7 +3997,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * call. Listeners are added to remove the menu item when the treePanel is * closed, and adjust the tree leaf to sequence mapping when the alignment is * modified. - * + * * @param treePanel * Displayed tree window. * @param title @@ -3868,6 +4006,38 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void buildTreeMenu() { + calculateTree.removeAll(); + // build the calculate menu + + for (final String type : new String[] + { "NJ", "AV" }) + { + String treecalcnm = MessageManager.getString("label.tree_calc_" + + type.toLowerCase()); + for (final Object pwtype : ResidueProperties.scoreMatrices.keySet()) + { + JMenuItem tm = new JMenuItem(); + ScoreModelI sm = ResidueProperties.scoreMatrices.get(pwtype); + if (sm.isProtein() == !viewport.getAlignment().isNucleotide()) + { + String smn = MessageManager.getStringOrReturn( + "label.score_model_", sm.getName()); + final String title = MessageManager.formatMessage( + "label.treecalc_title", treecalcnm, smn); + tm.setText(title);// + tm.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + NewTreePanel(type, (String) pwtype, title); + } + }); + calculateTree.add(tm); + } + + } + } sortByTreeMenu.removeAll(); Vector comps = (Vector) PaintRefresher.components.get(viewport @@ -3928,7 +4098,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Work out whether the whole set of sequences or just the selected set will * be submitted for multiple alignment. - * + * */ public jalview.datamodel.AlignmentView gatherSequencesForAlignment() { @@ -3943,7 +4113,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * SequenceGroup seqs = viewport.getSelectionGroup(); int sz; msa = new * SequenceI[sz = seqs.getSize(false)]; - * + * * for (int i = 0; i < sz; i++) { msa[i] = (SequenceI) * seqs.getSequenceAt(i); } */ @@ -3953,9 +4123,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { /* * Vector seqs = viewport.getAlignment().getSequences(); - * + * * if (seqs.size() > 1) { msa = new SequenceI[seqs.size()]; - * + * * for (int i = 0; i < seqs.size(); i++) { msa[i] = (SequenceI) * seqs.elementAt(i); } } */ @@ -4001,7 +4171,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * DOCUMENT ME! - * + * * @param e * DOCUMENT ME! */ @@ -4012,8 +4182,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, JalviewFileChooser chooser = new JalviewFileChooser( jalview.bin.Cache.getProperty("LAST_DIRECTORY")); chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Select a newick-like tree file"); - chooser.setToolTipText("Load a tree file"); + chooser.setDialogTitle(MessageManager + .getString("label.select_newick_like_tree_file")); + chooser.setToolTipText(MessageManager.getString("label.load_tree_file")); int value = chooser.showOpenDialog(null); @@ -4028,14 +4199,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree()); } catch (Exception ex) { - JOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(), - "Problem reading tree file", JOptionPane.WARNING_MESSAGE); + JOptionPane + .showMessageDialog( + Desktop.desktop, + ex.getMessage(), + MessageManager + .getString("label.problem_reading_tree_file"), + JOptionPane.WARNING_MESSAGE); ex.printStackTrace(); } if (fin != null && fin.hasWarningMessage()) { - JOptionPane.showMessageDialog(Desktop.desktop, - fin.getWarningMessage(), "Possible problem with tree file", + JOptionPane.showMessageDialog(Desktop.desktop, fin + .getWarningMessage(), MessageManager + .getString("label.possible_problem_with_tree_file"), JOptionPane.WARNING_MESSAGE); } } @@ -4067,7 +4244,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Add a treeviewer for the tree extracted from a newick file object to the * current alignment view - * + * * @param nf * the tree * @param title @@ -4118,7 +4295,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * Generates menu items and listener event actions for web service clients - * + * */ public void BuildWebServiceMenu() { @@ -4140,6 +4317,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void run() { + final List legacyItems = new ArrayList(); try { System.err.println("Building ws menu again " @@ -4171,28 +4349,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // TODO: refactor to allow list of AbstractName/Handler bindings to // be // stored or retrieved from elsewhere - Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS"); + // No MSAWS used any more: + // Vector msaws = null; // (Vector) + // Discoverer.services.get("MsaWS"); Vector secstrpr = (Vector) Discoverer.services .get("SecStrPred"); - Vector seqsrch = null; // (Vector) - // Discoverer.services.get("SeqSearch"); - // TODO: move GUI generation code onto service implementation - so a - // client instance attaches itself to the GUI with method call like - // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance, - // alignframe) - if (msaws != null) - { - // Add any Multiple Sequence Alignment Services - for (int i = 0, j = msaws.size(); i < j; i++) - { - final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws - .get(i); - jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer - .getServiceClient(sh); - impl.attachWSMenuEntry(msawsmenu, me); - - } - } if (secstrpr != null) { // Add any secondary structure prediction services @@ -4202,19 +4363,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .get(i); jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer .getServiceClient(sh); + int p = secstrmenu.getItemCount(); impl.attachWSMenuEntry(secstrmenu, me); - } - } - if (seqsrch != null) - { - // Add any sequence search services - for (int i = 0, j = seqsrch.size(); i < j; i++) - { - final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch - .elementAt(i); - jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer - .getServiceClient(sh); - impl.attachWSMenuEntry(seqsrchmenu, me); + int q = secstrmenu.getItemCount(); + for (int litm = p; litm < q; litm++) + { + legacyItems.add(secstrmenu.getItem(litm)); + } } } } @@ -4225,12 +4380,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, wsmenu.add(secstrmenu); wsmenu.add(dismenu); wsmenu.add(analymenu); - // final ArrayList submens=new ArrayList(); - // submens.add(msawsmenu); - // submens.add(secstrmenu); - // submens.add(dismenu); - // submens.add(analymenu); - // No search services yet // wsmenu.add(seqsrchmenu); @@ -4255,6 +4404,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, webService.add(me.webServiceNoServices); } // TODO: move into separate menu builder class. + boolean new_sspred = false; if (Cache.getDefault("SHOW_JWS2_SERVICES", true)) { Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer(); @@ -4263,6 +4413,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (jws2servs.hasServices()) { jws2servs.attachWSMenuEntry(webService, me); + for (Jws2Instance sv : jws2servs.getServices()) + { + if (sv.description.toLowerCase().contains("jpred")) + { + for (JMenuItem jmi : legacyItems) + { + jmi.setVisible(false); + } + } + } + } if (jws2servs.isRunning()) { @@ -4273,7 +4434,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } } - build_urlServiceMenu(me.webService); build_fetchdbmenu(webService); for (JMenu item : wsmenu) @@ -4289,7 +4449,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } catch (Exception e) { - Cache.log.debug("Exception during web service menu building process.",e); + Cache.log + .debug("Exception during web service menu building process.", + e); } ; } @@ -4307,7 +4469,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * construct any groupURL type service menu entries. - * + * * @param webService */ private void build_urlServiceMenu(JMenu webService) @@ -4317,12 +4479,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final * AlignFrame af = this; testAlView.addActionListener(new ActionListener() { - * + * * @Override public void actionPerformed(ActionEvent e) { * jalview.datamodel.AlignmentView * .testSelectionViews(af.viewport.getAlignment(), * af.viewport.getColumnSelection(), af.viewport.selectionGroup); } - * + * * }); webService.add(testAlView); */ // TODO: refactor to RestClient discoverer and merge menu entries for @@ -4337,24 +4499,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, JvSwingUtils.findOrCreateMenu(webService, client.getAction()), this); } - - if (Cache.getDefault("SHOW_ENFIN_SERVICES", true)) - { - jalview.ws.EnfinEnvision2OneWay.getInstance().attachWSMenuEntry( - webService, this); - } } /* * public void vamsasStore_actionPerformed(ActionEvent e) { JalviewFileChooser * chooser = new JalviewFileChooser(jalview.bin.Cache. * getProperty("LAST_DIRECTORY")); - * + * * chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Export * to Vamsas file"); chooser.setToolTipText("Export"); - * + * * int value = chooser.showSaveDialog(this); - * + * * if (value == JalviewFileChooser.APPROVE_OPTION) { * jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport); * //vs.store(chooser.getSelectedFile().getAbsolutePath() ); vs.storeJalview( @@ -4362,7 +4518,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ /** * prototype of an automatically enabled/disabled analysis function - * + * */ protected void setShowProductsEnabled() { @@ -4382,7 +4538,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * search selection for sequence xRef products and build the show products * menu. - * + * * @param selection * @param dataset * @return true if showProducts menu should be enabled. @@ -4553,14 +4709,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, JOptionPane .showMessageDialog( Desktop.desktop, - "Please select at least three bases in at least one sequence in order to perform a cDNA translation.", - "Translation Failed", JOptionPane.WARNING_MESSAGE); + MessageManager + .getString("label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation"), + MessageManager.getString("label.translation_failed"), + JOptionPane.WARNING_MESSAGE); } else { AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT); - Desktop.addInternalFrame(af, "Translation of " + this.getTitle(), - DEFAULT_WIDTH, DEFAULT_HEIGHT); + Desktop.addInternalFrame(af, MessageManager.formatMessage( + "label.translation_of_params", new String[] + { this.getTitle() }), DEFAULT_WIDTH, DEFAULT_HEIGHT); } } @@ -4583,27 +4742,42 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } catch (Exception ex) { al = null; - jalview.bin.Cache.log.debug("Exception during translation.", ex); + jalview.bin.Cache.log.error( + "Exception during translation. Please report this !", ex); + JOptionPane + .showMessageDialog( + Desktop.desktop, + MessageManager + .getString("label.error_when_translating_sequences_submit_bug_report"), + MessageManager + .getString("label.implementation_error") + + MessageManager + .getString("translation_failed"), + JOptionPane.ERROR_MESSAGE); + return; } if (al == null) { JOptionPane .showMessageDialog( Desktop.desktop, - "Please select at least three bases in at least one sequence in order to perform a cDNA translation.", - "Translation Failed", JOptionPane.WARNING_MESSAGE); + MessageManager + .getString("label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation"), + MessageManager.getString("label.translation_failed"), + JOptionPane.WARNING_MESSAGE); } else { AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT); - Desktop.addInternalFrame(af, "Translation of " + this.getTitle(), - DEFAULT_WIDTH, DEFAULT_HEIGHT); + Desktop.addInternalFrame(af, MessageManager.formatMessage( + "label.translation_of_params", new String[] + { this.getTitle() }), DEFAULT_WIDTH, DEFAULT_HEIGHT); } } /** * Try to load a features file onto the alignment. - * + * * @param file * contents or path to retrieve file * @param type @@ -4790,10 +4964,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, || JOptionPane .showConfirmDialog( this, - "Do you want to automatically associate the " - + filesmatched.size() - + " PDB files with sequences in the alignment that have the same name ?", - "Automatically Associate PDB files by name", + MessageManager + .formatMessage( + "label.automatically_associate_pdb_files_with_sequences_same_name", + new String[] + { Integer.valueOf( + filesmatched + .size()) + .toString() }), + MessageManager + .getString("label.automatically_associate_pdb_files_by_name"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { @@ -4826,10 +5006,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane .showConfirmDialog( this, - "Do you want to ignore the " - + filesnotmatched.size() - + " files whose names did not match any sequence IDs ?", - "Ignore unmatched dropped files ?", + MessageManager + .formatMessage( + "label.ignore_unmatched_dropped_files_info", + new String[] + { Integer.valueOf( + filesnotmatched + .size()) + .toString() }), + MessageManager + .getString("label.ignore_unmatched_dropped_files"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) { return; @@ -4852,7 +5038,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * it's and Annotation file, then a JNet file, and finally a features file. If * all are false then the user may have dropped an alignment file onto this * AlignFrame. - * + * * @param file * either a filename or a URL string. */ @@ -4889,15 +5075,22 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, changeColour(new TCoffeeColourScheme(viewport.getAlignment())); isAnnotation = true; statusBar - .setText("Successfully pasted T-Coffee scores to alignment."); + .setText(MessageManager + .getString("label.successfully_pasted_tcoffee_scores_to_alignment")); } else { - // some problem - if no warning its probable that the ID matching process didn't work - JOptionPane.showMessageDialog(Desktop.desktop, - tcf.getWarningMessage()==null ? "Check that the file matches sequence IDs in the alignment." : tcf.getWarningMessage(), - "Problem reading T-COFFEE score file", - JOptionPane.WARNING_MESSAGE); + // some problem - if no warning its probable that the ID matching + // process didn't work + JOptionPane + .showMessageDialog( + Desktop.desktop, + tcf.getWarningMessage() == null ? MessageManager + .getString("label.check_file_matches_sequence_ids_alignment") + : tcf.getWarningMessage(), + MessageManager + .getString("label.problem_reading_tcoffee_score_file"), + JOptionPane.WARNING_MESSAGE); } } else @@ -4906,7 +5099,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } catch (Exception x) { - Cache.log.debug("Exception when processing data source as T-COFFEE score file",x); + Cache.log + .debug("Exception when processing data source as T-COFFEE score file", + x); tcf = null; } if (tcf == null) @@ -4930,7 +5125,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { /* * if (format.equalsIgnoreCase("PDB")) { - * + * * String pdbfn = ""; // try to match up filename with sequence id * try { if (protocol == jalview.io.FormatAdapter.FILE) { File fl = * new File(file); pdbfn = fl.getName(); } else if (protocol == @@ -4975,13 +5170,22 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } catch (Exception ex) { ex.printStackTrace(); - } - catch (OutOfMemoryError oom) + } catch (OutOfMemoryError oom) { - try { + try + { System.gc(); - } catch (Exception x){}; - new OOMWarning("loading data "+(protocol!=null ? (protocol.equals(FormatAdapter.PASTE) ? "from clipboard." : "using "+protocol+" from "+file) : ".")+(format!=null ? "(parsing as '"+format+"' file)" :""), oom, Desktop.desktop); + } catch (Exception x) + { + } + ; + new OOMWarning( + "loading data " + + (protocol != null ? (protocol.equals(FormatAdapter.PASTE) ? "from clipboard." + : "using " + protocol + " from " + file) + : ".") + + (format != null ? "(parsing as '" + format + + "' file)" : ""), oom, Desktop.desktop); } } @@ -4992,6 +5196,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { alignPanel = (AlignmentPanel) alignPanels.elementAt(index); viewport = alignPanel.av; + avc.setViewportAndAlignmentPanel(viewport, alignPanel); setMenusFromViewport(viewport); } } @@ -5002,7 +5207,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (SwingUtilities.isRightMouseButton(e)) { String reply = JOptionPane.showInternalInputDialog(this, - "Enter View Name", "Edit View Name", + MessageManager.getString("label.enter_view_name"), + MessageManager.getString("label.enter_view_name"), JOptionPane.QUESTION_MESSAGE); if (reply != null) @@ -5039,7 +5245,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent * ) @@ -5052,7 +5258,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event. * ActionEvent) */ @@ -5065,7 +5271,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * find the viewport amongst the tabs in this alignment frame and close that * tab - * + * * @param av */ public boolean closeView(AlignViewport av) @@ -5097,12 +5303,32 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // TODO We probably want to store a sequence database checklist in // preferences and have checkboxes.. rather than individual sources selected // here - final JMenu rfetch = new JMenu("Fetch DB References"); - rfetch.setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences"); + final JMenu rfetch = new JMenu( + MessageManager.getString("action.fetch_db_references")); + rfetch.setToolTipText(MessageManager + .getString("label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences")); webService.add(rfetch); - JMenuItem fetchr = new JMenuItem("Standard Databases"); - fetchr.setToolTipText("Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources"); + final JCheckBoxMenuItem trimrs = new JCheckBoxMenuItem( + MessageManager.getString("option.trim_retrieved_seqs")); + trimrs.setToolTipText(MessageManager + .getString("label.trim_retrieved_sequences")); + trimrs.setSelected(Cache.getDefault("TRIM_FETCHED_DATASET_SEQS", true)); + trimrs.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + trimrs.setSelected(trimrs.isSelected()); + Cache.setProperty("TRIM_FETCHED_DATASET_SEQS", + Boolean.valueOf(trimrs.isSelected()).toString()); + }; + }); + rfetch.add(trimrs); + JMenuItem fetchr = new JMenuItem( + MessageManager.getString("label.standard_databases")); + fetchr.setToolTipText(MessageManager + .getString("label.fetch_embl_uniprot")); fetchr.addActionListener(new ActionListener() { @@ -5206,8 +5432,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .toArray(new DbSourceProxy[0]); // fetch all entry DbSourceProxy src = otherdb.get(0); - fetchr = new JMenuItem("Fetch All '" + src.getDbSource() - + "'"); + fetchr = new JMenuItem(MessageManager.formatMessage( + "label.fetch_all_param", new String[] + { src.getDbSource() })); fetchr.addActionListener(new ActionListener() { @Override @@ -5282,7 +5509,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, ++i; if (++icomp >= mcomp || i == (otherdb.size())) { - ifetch.setText(imname + " to '" + sname + "'"); + ifetch.setText(MessageManager.formatMessage( + "label.source_to_target", imname, sname)); dfetch.add(ifetch); ifetch = new JMenu(); imname = null; @@ -5294,7 +5522,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, ++dbi; if (comp >= mcomp || dbi >= (dbclasses.length)) { - dfetch.setText(mname + " to '" + dbclass + "'"); + dfetch.setText(MessageManager.formatMessage( + "label.source_to_target", mname, dbclass)); rfetch.add(dfetch); dfetch = new JMenu(); mname = null; @@ -5338,7 +5567,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java. * awt.event.ActionEvent) @@ -5352,7 +5581,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event * .ActionEvent) @@ -5367,7 +5596,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt * .event.ActionEvent) @@ -5381,7 +5610,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt * .event.ActionEvent) @@ -5395,7 +5624,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt * .event.ActionEvent) @@ -5424,7 +5653,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * (non-Javadoc) - * + * * @see * jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt * .event.ActionEvent) @@ -5432,39 +5661,35 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override protected void makeGrpsFromSelection_actionPerformed(ActionEvent e) { - if (viewport.getSelectionGroup() != null) + if (avc.makeGroupsFromSelection()) { - SequenceGroup[] gps = jalview.analysis.Grouping.makeGroupsFrom( - viewport.getSequenceSelection(), - viewport.getAlignmentView(true).getSequenceStrings( - viewport.getGapCharacter()), viewport.getAlignment() - .getGroups()); - viewport.getAlignment().deleteAllGroups(); - viewport.sequenceColours = null; - viewport.setSelectionGroup(null); - // set view properties for each group - for (int g = 0; g < gps.length; g++) - { - gps[g].setShowNonconserved(viewport.getShowUnconserved()); - gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo()); - viewport.getAlignment().addGroup(gps[g]); - Color col = new Color((int) (Math.random() * 255), - (int) (Math.random() * 255), (int) (Math.random() * 255)); - col = col.brighter(); - for (SequenceI s:gps[g].getSequences()) - viewport.setSequenceColour( - s, col) - ; - } PaintRefresher.Refresh(this, viewport.getSequenceSetId()); alignPanel.updateAnnotation(); alignPanel.paintAlignment(true); } } + @Override + protected void createGroup_actionPerformed(ActionEvent e) + { + if (avc.createGroup()) + { + alignPanel.alignmentChanged(); + } + } + + @Override + protected void unGroup_actionPerformed(ActionEvent e) + { + if (avc.unGroup()) + { + alignPanel.alignmentChanged(); + } + } + /** * make the given alignmentPanel the currently selected tab - * + * * @param alignmentPanel */ public void setDisplayedView(AlignmentPanel alignmentPanel) @@ -5482,6 +5707,95 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel)); } } + + /** + * On menu option, open a panel to allow choice of annotation types to + * show/hide. + */ + @Override + protected void chooseAnnotations_actionPerformed() + { + new AnnotationChooser(this.alignPanel); + } + + /** + * Get a list of unique annotation types for the alignment, optionally + * restricted to sequence-specific annotations. + */ + protected List getAnnotationTypes(boolean sequenceSpecificOnly) + { + // TODO move this to an AlignmentUtils class or similar + List types = new ArrayList(); + for (AlignmentAnnotation aa : alignPanel.getAlignment() + .getAlignmentAnnotation()) + { + if (sequenceSpecificOnly && aa.sequenceRef == null) + { + continue; + } + String type = aa.label; + if (!types.contains(type)) + { + types.add(type); + } + } + return types; + } + + /** + * Action on selection of an annotation type to Show or Hide. + * + * @param type + * @param doShow + */ + @Override + protected void showHideAnnotation_actionPerformed(String type, boolean doShow) + { + for (AlignmentAnnotation aa : alignPanel.getAlignment() + .getAlignmentAnnotation()) + { + if (type.equals(aa.label)) + { + aa.visible = doShow; + } + } + this.alignPanel.paintAlignment(true); + } + + /** + * Dynamically build the list of annotation types to show or hide. + */ + @Override + protected void buildShowHideAnnotationMenus() + { + showAnnotations.removeAll(); + hideAnnotations.removeAll(); + + List types = getAnnotationTypes(false); + for (final String type : types) + { + final JMenuItem showitem = new JMenuItem(type); + showitem.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + showHideAnnotation_actionPerformed(type, true); + } + }); + showAnnotations.add(showitem); + final JMenuItem hideitem = new JMenuItem(type); + hideitem.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + showHideAnnotation_actionPerformed(type, false); + } + }); + hideAnnotations.add(hideitem); + } + } } class PrintThread extends Thread