X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=cc57961160589c5068f7df08939f9a45573cb9ef;hb=e3eb93bc131a0f088312fddde91b728dbebe40d4;hp=c1f088b3d8965991cc5da195ad40f67ca0c562ad;hpb=e2d27f21c1655d5707adad16fe174f2c88ba7cd3;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index c1f088b..cc57961 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -37,7 +37,6 @@ import jalview.ws.*; import java.awt.dnd.*; import org.biojava.dasobert.eventmodel.*; - /** * DOCUMENT ME! * @@ -69,6 +68,7 @@ public class AlignFrame */ public AlignFrame(AlignmentI al) { + viewport = new AlignViewport(al); this.setDropTarget(new java.awt.dnd.DropTarget(this, this)); @@ -347,9 +347,26 @@ public class AlignFrame } else { - String output = new FormatAdapter().formatSequences(format, - viewport.getAlignment(). - getSequences()); + + String[] omitHidden = null; + + if (viewport.hasHiddenColumns) + { + int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, + "The Alignment contains hidden columns." + + "\nDo you want to save only the visible alignment?", + "Save / Omit Hidden Columns", + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + + if (reply == JOptionPane.YES_OPTION) + omitHidden = viewport.getViewAsString(false); + } + + String output = new FormatAdapter().formatSequences( + format, + viewport.alignment.getSequencesArray(), + omitHidden); + if (output == null) { return false; @@ -380,13 +397,32 @@ public class AlignFrame */ protected void outputText_actionPerformed(ActionEvent e) { + String [] omitHidden = null; + + if(viewport.hasHiddenColumns) + { + int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, + "The Alignment contains hidden columns." + +"\nDo you want to output only the visible alignment?", + "Save / Omit Hidden Columns", + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + + if(reply==JOptionPane.YES_OPTION) + { + omitHidden = viewport.getViewAsString(false); + } + } + CutAndPasteTransfer cap = new CutAndPasteTransfer(); Desktop.addInternalFrame(cap, "Alignment output - " + e.getActionCommand(), 600, 500); - cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), - viewport.getAlignment(). - getSequences())); + + + cap.setText(new FormatAdapter().formatSequences( + e.getActionCommand(), + viewport.alignment.getSequencesArray(), + omitHidden)); } /** @@ -443,6 +479,7 @@ public class AlignFrame new AnnotationExporter().exportFeatures(alignPanel); } + public void exportAnnotations_actionPerformed(ActionEvent e) { new AnnotationExporter().exportAnnotations( @@ -648,83 +685,41 @@ public class AlignFrame return; } - SequenceGroup sg = viewport.getSelectionGroup(); - - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - - Hashtable orderedSeqs = new Hashtable(); - SequenceI[] seqs = new SequenceI[sg.getSize(false)]; + SequenceI [] seqs = viewport.getSelectionAsNewSequence(); + String[] omitHidden = null; - for (int i = 0; i < sg.getSize(false); i++) + if (viewport.hasHiddenColumns) { - SequenceI seq = sg.getSequenceAt(i); - int index = viewport.alignment.findIndex(seq); - orderedSeqs.put(index + "", seq); + omitHidden = viewport.getViewAsString(true); } - int index = 0, startRes, endRes; - char ch; + String output = new FormatAdapter().formatSequences( + "Fasta", + seqs, + omitHidden); - for (int i = 0; i < sg.getSize(false); i++) - { - SequenceI seq = null; - while (seq == null) - { - if (orderedSeqs.containsKey(index + "")) - { - seq = (SequenceI) orderedSeqs.get(index + ""); - index++; + Toolkit.getDefaultToolkit().getSystemClipboard() + .setContents(new StringSelection(output), Desktop.instance); - break; - } - else - { - index++; - } - } - - //FIND START RES - //Returns residue following index if gap - startRes = seq.findPosition(sg.getStartRes()); - - //FIND END RES - //Need to find the residue preceeding index if gap - endRes = 0; - - for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++) + Vector hiddenColumns = null; + if(viewport.hasHiddenColumns && viewport.getSelectionGroup()!=null) + { + hiddenColumns =new Vector(); + int hiddenOffset = viewport.getSelectionGroup().getStartRes(); + for(int i=0; i 0) - { - endRes += seq.getStart() - 1; - } - - seqs[i] = new Sequence(seq.getName(), - seq.getSequence(sg.getStartRes(), sg.getEndRes() + 1), - startRes, - endRes); - seqs[i].setDescription(seq.getDescription()); - seqs[i].setDBRef(seq.getDBRef()); - seqs[i].setSequenceFeatures(seq.getSequenceFeatures()); - seqs[i].setDatasetSequence(seq.getDatasetSequence()); - if(seq.getAnnotation()!=null) - { - for(int a=0; a>>This is a fix for the moment, until a better solution is found!!<<< af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings( @@ -1394,6 +1408,46 @@ public class AlignFrame alignPanel.setWrapAlignment(wrapMenuItem.isSelected()); } + public void showAllSeqs_actionPerformed(ActionEvent e) + { + viewport.showAllHiddenSeqs(); + repaint(); + } + + public void showAllColumns_actionPerformed(ActionEvent e) + { + viewport.showAllHiddenColumns(); + } + + public void hideSelSequences_actionPerformed(ActionEvent e) + { + if(viewport.getSelectionGroup()==null) + return; + + SequenceI [] seqs = viewport.getSelectionGroup().getSequencesInOrder( + viewport.alignment + ); + + for(int i=0; i