X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=2a804ad6ea1abdb60f50a4ce0132ad1abbc17cce;hb=b58a17a47d215b541be4d8057eb88072c599087e;hp=0f47cca4eb6a429eb4c9e6bbf043662e68dbc724;hpb=2e7da637a195ff484f92a333675284f071657cd6;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 0f47cca..2a804ad 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -34,6 +34,7 @@ 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; @@ -279,7 +280,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 @@ -377,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()) { @@ -389,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: @@ -551,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; } } @@ -724,10 +747,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()); @@ -1236,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) { @@ -1382,7 +1411,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() })); @@ -1397,7 +1426,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() })); @@ -1458,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()); @@ -1498,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()); @@ -1611,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) @@ -1662,7 +1709,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } if (!appendHistoryItem) + { addHistoryItem(ssc); + } repaint(); } @@ -1942,7 +1991,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 @@ -1997,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) @@ -2211,8 +2264,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); @@ -3056,8 +3110,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 @@ -4128,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 { /* @@ -4643,7 +4714,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (ds.getSequences() == null || !ds.getSequences().contains( sprods[s].getDatasetSequence())) + { ds.addSequence(sprods[s].getDatasetSequence()); + } sprods[s].updatePDBIds(); } Alignment al = new Alignment(sprods); @@ -5005,7 +5078,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { PDBEntry pe = new AssociatePdbFileWithSeq() .associatePdbWithSeq((String) fm[0], - (String) fm[1], toassoc, false); + (String) fm[1], toassoc, false, + Desktop.instance); if (pe != null) { System.err.println("Associated file : " @@ -5025,14 +5099,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane .showConfirmDialog( this, - MessageManager + ""+MessageManager .formatMessage( "label.ignore_unmatched_dropped_files_info", new String[] { Integer.valueOf( filesnotmatched .size()) - .toString() }), + .toString() })+"", MessageManager .getString("label.ignore_unmatched_dropped_files"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) @@ -5720,19 +5794,42 @@ 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); } }