X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=2a804ad6ea1abdb60f50a4ce0132ad1abbc17cce;hb=b58a17a47d215b541be4d8057eb88072c599087e;hp=382ccda0352e535dcac82bcadadb36dcd7881c1f;hpb=8a3c31b03ed98321d1d450b658d26d50a7aa0ae6;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java old mode 100755 new mode 100644 index 382ccda..2a804ad --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1,33 +1,40 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) - * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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. + * 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; +import jalview.commands.EditCommand.Action; import jalview.commands.OrderCommand; import jalview.commands.RemoveGapColCommand; import jalview.commands.RemoveGapsCommand; @@ -76,13 +83,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; @@ -114,6 +121,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; @@ -134,7 +142,7 @@ import javax.swing.SwingUtilities; * @version $Revision$ */ public class AlignFrame extends GAlignFrame implements DropTargetListener, - IProgressIndicator + IProgressIndicator, AlignViewControllerGuiI { /** DOCUMENT ME!! */ @@ -146,9 +154,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public AlignmentPanel alignPanel; AlignViewport viewport; - + public AlignViewControllerI avc; - Vector alignPanels = new Vector(); @@ -257,21 +264,23 @@ 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 + * Make a new AlignFrame from existing alignmentPanels * * @param ap * AlignmentPanel @@ -292,7 +301,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ void init() { - avc = new jalview.controller.AlignViewController(viewport, alignPanel); + avc = new jalview.controller.AlignViewController(this, viewport, + alignPanel); if (viewport.getAlignmentConservationAnnotation() == null) { BLOSUM62Colour.setEnabled(false); @@ -324,6 +334,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, setMenusFromViewport(viewport); buildSortByAnnotationScoresMenu(); + buildTreeMenu(); + if (viewport.wrapAlignment) { wrapMenuItem_actionPerformed(null); @@ -335,7 +347,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } addKeyListener(); - + } /** @@ -366,7 +378,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt .getKeyCode() <= KeyEvent.VK_NUMPAD9)) && Character.isDigit(evt.getKeyChar())) + { alignPanel.seqPanel.numberPressed(evt.getKeyChar()); + } switch (evt.getKeyCode()) { @@ -378,32 +392,48 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, case KeyEvent.VK_DOWN: if (evt.isAltDown() || !viewport.cursorMode) + { moveSelectedSequences(false); + } if (viewport.cursorMode) + { alignPanel.seqPanel.moveCursor(0, 1); + } break; case KeyEvent.VK_UP: if (evt.isAltDown() || !viewport.cursorMode) + { moveSelectedSequences(true); + } if (viewport.cursorMode) + { alignPanel.seqPanel.moveCursor(0, -1); + } break; case KeyEvent.VK_LEFT: if (evt.isAltDown() || !viewport.cursorMode) + { slideSequences(false, alignPanel.seqPanel.getKeyboardNo1()); + } else + { alignPanel.seqPanel.moveCursor(-1, 0); + } break; case KeyEvent.VK_RIGHT: if (evt.isAltDown() || !viewport.cursorMode) + { slideSequences(true, alignPanel.seqPanel.getKeyboardNo1()); + } else + { alignPanel.seqPanel.moveCursor(1, 0); + } break; case KeyEvent.VK_SPACE: @@ -481,8 +511,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; @@ -494,14 +525,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, case KeyEvent.VK_F1: try { - ClassLoader cl = jalview.gui.Desktop.class.getClassLoader(); - java.net.URL url = javax.help.HelpSet.findHelpSet(cl, - "help/help"); - javax.help.HelpSet hs = new javax.help.HelpSet(cl, url); - - javax.help.HelpBroker hb = hs.createHelpBroker(); - hb.setCurrentID("home"); - hb.setDisplayed(true); + Help.showHelpWindow(); } catch (Exception ex) { ex.printStackTrace(); @@ -546,14 +570,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { case KeyEvent.VK_LEFT: if (evt.isAltDown() || !viewport.cursorMode) + { viewport.firePropertyChange("alignment", null, viewport .getAlignment().getSequences()); + } break; case KeyEvent.VK_RIGHT: if (evt.isAltDown() || !viewport.cursorMode) + { viewport.firePropertyChange("alignment", null, viewport .getAlignment().getSequences()); + } break; } } @@ -563,7 +591,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void addAlignmentPanel(final AlignmentPanel ap, boolean newPanel) { ap.alignFrame = this; - avc = new jalview.controller.AlignViewController(viewport, alignPanel); + avc = new jalview.controller.AlignViewController(this, viewport, + alignPanel); alignPanels.addElement(ap); @@ -717,6 +746,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, scaleLeft.setVisible(av.wrapAlignment); scaleRight.setVisible(av.wrapAlignment); annotationPanelMenuItem.setState(av.showAnnotation); + /* + * Show/hide annotations only enabled if annotation panel is shown + */ + showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState()); + hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState()); + showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState()); + hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState()); viewBoxesMenuItem.setSelected(av.showBoxes); viewTextMenuItem.setSelected(av.showText); showNonconservedMenuItem.setSelected(av.getShowUnconserved()); @@ -807,14 +843,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { if (progressBarHandlers == null || !progressBars.contains(new Long(id))) { - throw new Error( - "call setProgressBar before registering the progress bar's handler."); + throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler")); } progressBarHandlers.put(new Long(id), handler); 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() { @@ -823,10 +859,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void actionPerformed(ActionEvent e) { handler.cancelActivity(id); - us.setProgressBar( - "Cancelled " - + ((JLabel) progressPanel.getComponent(0)) - .getText(), id); + us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id); } }); progressPanel.add(cancel, BorderLayout.EAST); @@ -847,6 +880,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 */ @@ -983,8 +1022,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, currentFileFormat, false); chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Save Alignment to file"); - chooser.setToolTipText("Save"); + chooser.setDialogTitle(MessageManager.getString("label.save_alignment_to_file")); + chooser.setToolTipText(MessageManager.getString("action.save")); int value = chooser.showSaveDialog(this); @@ -993,9 +1032,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; } @@ -1031,8 +1075,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 @@ -1053,9 +1098,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); @@ -1085,8 +1131,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; @@ -1097,8 +1145,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; @@ -1135,9 +1186,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); @@ -1155,8 +1207,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); @@ -1208,6 +1261,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, alignPanel.makeEPS(f); } + public void createSVG(File f) + { + alignPanel.makeSVG(f); + } @Override public void pageSetup_actionPerformed(ActionEvent e) { @@ -1252,8 +1309,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); @@ -1352,26 +1411,30 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (viewport.historyList.size() > 0) { undoMenuItem.setEnabled(true); - CommandI command = (CommandI) viewport.historyList.peek(); - undoMenuItem.setText("Undo " + command.getDescription()); + CommandI command = viewport.historyList.peek(); + 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) { redoMenuItem.setEnabled(true); - CommandI command = (CommandI) viewport.redoList.peek(); - redoMenuItem.setText("Redo " + command.getDescription()); + CommandI command = viewport.redoList.peek(); + redoMenuItem.setText(MessageManager.formatMessage( + "label.redo_command", new String[] + { command.getDescription() })); } else { redoMenuItem.setEnabled(false); - redoMenuItem.setText("Redo"); + redoMenuItem.setText(MessageManager.getString("action.redo")); } } @@ -1424,8 +1487,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, protected void undoMenuItem_actionPerformed(ActionEvent e) { if (viewport.historyList.empty()) + { return; - CommandI command = (CommandI) viewport.historyList.pop(); + } + CommandI command = viewport.historyList.pop(); viewport.redoList.push(command); command.undoCommand(getViewAlignments()); @@ -1464,7 +1529,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - CommandI command = (CommandI) viewport.redoList.pop(); + CommandI command = viewport.redoList.pop(); viewport.historyList.push(command); command.doCommand(getViewAlignments()); @@ -1577,37 +1642,53 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, for (int i = 0; i < viewport.getAlignment().getHeight(); i++) { if (!sg.contains(viewport.getAlignment().getSequenceAt(i))) + { invertGroup.add(viewport.getAlignment().getSequenceAt(i)); + } } SequenceI[] seqs1 = sg.toArray(new SequenceI[0]); SequenceI[] seqs2 = new SequenceI[invertGroup.size()]; for (int i = 0; i < invertGroup.size(); i++) + { seqs2[i] = (SequenceI) invertGroup.elementAt(i); + } SlideSequencesCommand ssc; if (right) + { ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, size, viewport.getGapCharacter()); + } else + { ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, size, viewport.getGapCharacter()); + } int groupAdjustment = 0; if (ssc.getGapsInsertedBegin() && right) { if (viewport.cursorMode) + { alignPanel.seqPanel.moveCursor(size, 0); + } else + { groupAdjustment = size; + } } else if (!ssc.getGapsInsertedBegin() && !right) { if (viewport.cursorMode) + { alignPanel.seqPanel.moveCursor(-size, 0); + } else + { groupAdjustment = -size; + } } if (groupAdjustment != 0) @@ -1628,7 +1709,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } if (!appendHistoryItem) + { addHistoryItem(ssc); + } repaint(); } @@ -1699,7 +1782,9 @@ 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() })); } /** @@ -1906,7 +1991,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // ///// // ADD HISTORY ITEM // - addHistoryItem(new EditCommand("Add sequences", EditCommand.PASTE, + addHistoryItem(new EditCommand( + MessageManager.getString("label.add_sequences"), + Action.PASTE, sequences, 0, alignment.getWidth(), alignment)); } // Add any annotations attached to sequences @@ -1961,7 +2048,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { AlignmentAnnotation sann[] = sequences[i].getAnnotation(); if (sann == null) + { continue; + } for (int avnum = 0; avnum < alview.length; avnum++) { if (alview[avnum] != alignment) @@ -2058,6 +2147,60 @@ 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! * @@ -2087,17 +2230,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - Vector seqs = new Vector(); + List seqs = new ArrayList(sg.getSize()); SequenceI seq; for (int i = 0; i < sg.getSize(); i++) { seq = sg.getSequenceAt(i); - seqs.addElement(seq); + seqs.add(seq); } - // If the cut affects all sequences, remove highlighted columns + // If the cut affects all sequences, warn, remove highlighted columns if (sg.getSize() == viewport.getAlignment().getHeight()) { + int confirm = JOptionPane.showConfirmDialog(this, + MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ + MessageManager.getString("label.delete_all"), // $NON-NLS-1$ + JOptionPane.OK_CANCEL_OPTION); + + if (confirm == JOptionPane.CANCEL_OPTION + || confirm == JOptionPane.CLOSED_OPTION) + { + return; + } viewport.getColumnSelection().removeElements(sg.getStartRes(), sg.getEndRes() + 1); } @@ -2105,14 +2258,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, SequenceI[] cut = new SequenceI[seqs.size()]; for (int i = 0; i < seqs.size(); i++) { - cut[i] = (SequenceI) seqs.elementAt(i); + cut[i] = seqs.get(i); } /* * //ADD HISTORY ITEM */ - addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut, - sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1, + addHistoryItem(new EditCommand( + MessageManager.getString("label.cut_sequences"), Action.CUT, + cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1, viewport.getAlignment())); viewport.setSelectionGroup(null); @@ -2141,7 +2295,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override protected void deleteGroups_actionPerformed(ActionEvent e) { - if (avc.deleteGroups()) { + if (avc.deleteGroups()) + { PaintRefresher.Refresh(this, viewport.getSequenceSetId()); alignPanel.updateAnnotation(); alignPanel.paintAlignment(true); @@ -2299,7 +2454,9 @@ 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); @@ -2347,8 +2504,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 @@ -2511,7 +2669,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, boolean addFirstIndex = false; if (viewTitle == null || viewTitle.trim().length() == 0) { - viewTitle = "View"; + viewTitle = MessageManager.getString("action.view"); addFirstIndex = true; } else @@ -2542,6 +2700,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, newap.av.viewName = newViewName; addAlignmentPanel(newap, true); + newap.alignmentChanged(); if (alignPanels.size() == 2) { @@ -2937,16 +3096,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * DOCUMENT ME! + * Action on toggle of the 'Show annotations' menu item. This shows or hides + * the annotations panel as a whole. + * + * The options to show/hide all annotations should be enabled when the panel + * is shown, and disabled when the panel is hidden. * * @param e - * DOCUMENT ME! */ @Override public void annotationPanelMenuItem_actionPerformed(ActionEvent e) { - viewport.setShowAnnotation(annotationPanelMenuItem.isSelected()); - alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected()); + final boolean setVisible = annotationPanelMenuItem.isSelected(); + viewport.setShowAnnotation(setVisible); + alignPanel.setAnnotationVisible(setVisible); + this.showAllSeqAnnotations.setEnabled(setVisible); + this.hideAllSeqAnnotations.setEnabled(setVisible); + this.showAllAlAnnotations.setEnabled(setVisible); + this.hideAllAlAnnotations.setEnabled(setVisible); } @Override @@ -2956,12 +3123,15 @@ 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); } /** @@ -2981,8 +3151,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() @@ -3178,10 +3349,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background"); - cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus()); - - viewport.setGlobalColourScheme(cs); } else { @@ -3367,7 +3535,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @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); } @@ -3416,8 +3585,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) { @@ -3568,15 +3739,18 @@ 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); } } @@ -3594,11 +3768,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; } @@ -3699,8 +3876,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 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; } @@ -3714,10 +3894,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 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; @@ -3735,10 +3915,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; @@ -3775,7 +3955,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void addSortByOrderMenuItem(String title, final AlignmentOrder order) { - final JMenuItem item = new JMenuItem("by " + title); + final JMenuItem item = new JMenuItem(MessageManager.formatMessage("action.by_title_param", new String[]{title})); sort.add(item); item.addActionListener(new java.awt.event.ActionListener() { @@ -3891,6 +4071,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 @@ -3972,6 +4184,21 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ msa = viewport.getAlignmentView(true); } + else if (viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() == 1) + { + int option = JOptionPane + .showConfirmDialog( +this, + "More than one sequece group selection is required for this Job, click \n'Cancel' to edit your selection or 'Ok' to submit the entire sequence.", + "Invalid selection", + JOptionPane.OK_CANCEL_OPTION); + if (option == JOptionPane.OK_OPTION) + { + msa = viewport.getAlignmentView(false); + } + + } else { /* @@ -4035,8 +4262,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); @@ -4051,14 +4279,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); } } @@ -4163,7 +4397,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void run() { - final List legacyItems=new ArrayList(); + final List legacyItems = new ArrayList(); try { System.err.println("Building ws menu again " @@ -4186,6 +4420,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, final JMenu seqsrchmenu = new JMenu("Sequence Database Search"); final JMenu analymenu = new JMenu("Analysis"); final JMenu dismenu = new JMenu("Protein Disorder"); + // final JMenu msawsmenu = new + // JMenu(MessageManager.getString("label.alignment")); + // final JMenu secstrmenu = new + // JMenu(MessageManager.getString("label.secondary_structure_prediction")); + // final JMenu seqsrchmenu = new + // JMenu(MessageManager.getString("label.sequence_database_search")); + // final JMenu analymenu = new + // JMenu(MessageManager.getString("label.analysis")); + // final JMenu dismenu = new + // JMenu(MessageManager.getString("label.protein_disorder")); // JAL-940 - only show secondary structure prediction services from // the legacy server if (// Cache.getDefault("SHOW_JWS1_SERVICES", true) @@ -4196,7 +4440,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // be // stored or retrieved from elsewhere // No MSAWS used any more: - // Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS"); + // Vector msaws = null; // (Vector) + // Discoverer.services.get("MsaWS"); Vector secstrpr = (Vector) Discoverer.services .get("SecStrPred"); if (secstrpr != null) @@ -4208,17 +4453,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, .get(i); jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer .getServiceClient(sh); - int p=secstrmenu.getItemCount(); + int p = secstrmenu.getItemCount(); impl.attachWSMenuEntry(secstrmenu, me); - int q=secstrmenu.getItemCount(); - for (int litm=p;litmDo 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; @@ -4901,7 +5168,8 @@ 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 { @@ -4910,9 +5178,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, JOptionPane .showMessageDialog( Desktop.desktop, - tcf.getWarningMessage() == null ? "Check that the file matches sequence IDs in the alignment." + tcf.getWarningMessage() == null ? MessageManager + .getString("label.check_file_matches_sequence_ids_alignment") : tcf.getWarningMessage(), - "Problem reading T-COFFEE score file", + MessageManager + .getString("label.problem_reading_tcoffee_score_file"), JOptionPane.WARNING_MESSAGE); } } @@ -5030,7 +5300,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) @@ -5125,12 +5396,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() { @@ -5222,9 +5513,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } }); - fetchr.setToolTipText("" - + JvSwingUtils.wrapTooltip("Retrieve from " - + src.getDbName()) + ""); + fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage("label.fetch_retrieve_from", new String[]{src.getDbName()}))); dfetch.add(fetchr); comp++; } @@ -5234,8 +5523,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 @@ -5256,15 +5546,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } }); - fetchr.setToolTipText("" - + JvSwingUtils.wrapTooltip("Retrieve from all " - + otherdb.size() + " sources in " - + src.getDbSource() + "
First is :" - + src.getDbName()) + ""); + fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage("label.fetch_retrieve_from_all_sources", new String[]{Integer.valueOf(otherdb.size()).toString(), src.getDbSource(), src.getDbName()}))); dfetch.add(fetchr); comp++; // and then build the rest of the individual menus - ifetch = new JMenu("Sources from " + src.getDbSource()); + ifetch = new JMenu(MessageManager.formatMessage("label.source_from_db_source", new String[]{src.getDbSource()})); icomp = 0; String imname = null; int i = 0; @@ -5277,7 +5563,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 0, 10) + "..." : dbname; if (imname == null) { - imname = "from '" + sname + "'"; + imname = MessageManager.formatMessage("label.from_msname", new String[]{sname}); } fetchr = new JMenuItem(msname); final DbSourceProxy[] dassrc = @@ -5304,13 +5590,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, }); fetchr.setToolTipText("" - + JvSwingUtils.wrapTooltip("Retrieve from " - + dbname) + ""); + + MessageManager.formatMessage("label.fetch_retrieve_from", new String[]{dbname})); ifetch.add(fetchr); ++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; @@ -5322,7 +5608,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; @@ -5460,13 +5747,32 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override protected void makeGrpsFromSelection_actionPerformed(ActionEvent e) { - if (avc.makeGroupsFromSelection()) { + if (avc.makeGroupsFromSelection()) + { 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 * @@ -5477,8 +5783,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (!viewport.getSequenceSetId().equals( alignmentPanel.av.getSequenceSetId())) { - throw new Error( - "Implementation error: cannot show a view from another alignment in an AlignFrame."); + throw new Error(MessageManager.getString("error.implementation_error_cannot_show_view_alignment_frame")); } if (tabbedPane != null & alignPanels.indexOf(alignmentPanel) != tabbedPane @@ -5487,6 +5792,45 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel)); } } + + /** + * Action on selection of menu options to Show or Hide annotations. + * + * @param visible + * @param forSequences + * update sequence-related annotations + * @param forAlignment + * update non-sequence-related annotations + */ + @Override + protected void setAnnotationsVisibility(boolean visible, + boolean forSequences, boolean forAlignment) + { + for (AlignmentAnnotation aa : alignPanel.getAlignment() + .getAlignmentAnnotation()) + { + boolean apply = (aa.sequenceRef == null && forAlignment) + || (aa.sequenceRef != null && forSequences); + if (apply) + { + aa.visible = visible; + } + } + alignPanel.validateAnnotationDimensions(false); + alignPanel.alignmentChanged(); + } + + /** + * Store selected annotation sort order for the view and repaint. + */ + @Override + protected void sortAnnotations_actionPerformed() + { + this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder()); + this.alignPanel.av + .setShowAutocalculatedAbove(isShowAutoCalculatedAbove()); + alignPanel.paintAlignment(true); + } } class PrintThread extends Thread