X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=afd1d04b56b77879752a0dc649e4c33725009001;hb=61a4ffb7cfd54b95c16bd78c14f4e86d2a7b037e;hp=6d8fe6d15765b408912d55fc3e16a51c9306074f;hpb=9c37999eb4b461a5c7a94e10ac39583c1c29200a;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 6d8fe6d..afd1d04 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -30,10 +30,12 @@ import jalview.analysis.ParseProperties; import jalview.analysis.SequenceIdMatcher; import jalview.api.AlignViewControllerGuiI; import jalview.api.AlignViewControllerI; +import jalview.api.AlignmentViewPanel; 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; @@ -114,6 +116,7 @@ import java.beans.PropertyChangeEvent; import java.io.File; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; @@ -279,7 +282,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * Make a new AlignFrame from exisiting alignmentPanels + * Make a new AlignFrame from existing alignmentPanels * * @param ap * AlignmentPanel @@ -746,10 +749,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, scaleRight.setVisible(av.wrapAlignment); annotationPanelMenuItem.setState(av.showAnnotation); /* - * Show/hide all annotations only enabled if annotation panel is shown + * Show/hide annotations only enabled if annotation panel is shown */ - showAllAnnotations.setEnabled(annotationPanelMenuItem.getState()); - hideAllAnnotations.setEnabled(annotationPanelMenuItem.getState()); + 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()); @@ -1258,6 +1263,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) { @@ -1404,7 +1413,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (viewport.historyList.size() > 0) { undoMenuItem.setEnabled(true); - CommandI command = (CommandI) viewport.historyList.peek(); + CommandI command = viewport.historyList.peek(); undoMenuItem.setText(MessageManager.formatMessage( "label.undo_command", new String[] { command.getDescription() })); @@ -1419,7 +1428,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { redoMenuItem.setEnabled(true); - CommandI command = (CommandI) viewport.redoList.peek(); + CommandI command = viewport.redoList.peek(); redoMenuItem.setText(MessageManager.formatMessage( "label.redo_command", new String[] { command.getDescription() })); @@ -1483,7 +1492,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { return; } - CommandI command = (CommandI) viewport.historyList.pop(); + CommandI command = viewport.historyList.pop(); viewport.redoList.push(command); command.undoCommand(getViewAlignments()); @@ -1522,7 +1531,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()); @@ -1984,7 +1993,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // ///// // ADD HISTORY ITEM // - addHistoryItem(new EditCommand(MessageManager.getString("label.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 @@ -2255,8 +2266,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * //ADD HISTORY ITEM */ - addHistoryItem(new EditCommand(MessageManager.getString("label.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); @@ -3100,8 +3112,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, final boolean setVisible = annotationPanelMenuItem.isSelected(); viewport.setShowAnnotation(setVisible); alignPanel.setAnnotationVisible(setVisible); - this.showAllAnnotations.setEnabled(setVisible); - this.hideAllAnnotations.setEnabled(setVisible); + this.showAllSeqAnnotations.setEnabled(setVisible); + this.hideAllSeqAnnotations.setEnabled(setVisible); + this.showAllAlAnnotations.setEnabled(setVisible); + this.hideAllAlAnnotations.setEnabled(setVisible); } @Override @@ -4172,6 +4186,19 @@ 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, + MessageManager.getString("warn.oneseq_msainput_selection"), + MessageManager.getString("label.invalid_selection"), + JOptionPane.OK_CANCEL_OPTION); + if (option == JOptionPane.OK_OPTION) + { + msa = viewport.getAlignmentView(false); + } + + } else { /* @@ -5767,19 +5794,51 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * Action on selection of menu option to Show or Hide all annotations. + * Action on selection of menu options to Show or Hide annotations. * - * @param visibile + * @param visible + * @param forSequences + * update sequence-related annotations + * @param forAlignment + * update non-sequence-related annotations */ @Override - protected void setAllAnnotationsVisibility(boolean visible) + protected void setAnnotationsVisibility(boolean visible, + boolean forSequences, boolean forAlignment) { for (AlignmentAnnotation aa : alignPanel.getAlignment() .getAlignmentAnnotation()) { - aa.visible = visible; + boolean apply = (aa.sequenceRef == null && forAlignment) + || (aa.sequenceRef != null && forSequences); + if (apply) + { + aa.visible = visible; + } } - this.alignPanel.paintAlignment(true); + 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); + } + + /** + * + * @return alignment panels in this alignemnt frame + */ + public List getAlignPanels() + { + return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels; } }