X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=fde4d90e18bbf9f5c2b1e09f3aac7850c817c9a6;hb=2ef43e1e505af2742f1c3a59619c8a4357ea82c4;hp=23d7612882a0e987cde599a647f6b45cbf2e237b;hpb=0125a426aecc7065538a13f48236dc1e8d268044;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 23d7612..fde4d90 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -61,8 +61,9 @@ public class AlignViewport SequenceGroup selectionGroup; int charHeight; int charWidth; + boolean validCharWidth; int wrappedWidth; - Font font = new Font("SansSerif", Font.PLAIN, 10); + Font font; AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); int threshold; @@ -73,6 +74,9 @@ public class AlignViewport boolean scaleRightWrapped = true; boolean hasHiddenColumns = false; boolean hasHiddenRows = false; + boolean showHiddenMarkers = true; + + boolean cursorMode = false; // The following vector holds the features which are // currently visible, in the correct order or rendering @@ -84,6 +88,7 @@ public class AlignViewport AlignmentAnnotation consensus; AlignmentAnnotation conservation; AlignmentAnnotation quality; + boolean autoCalculateConsensus = true; /** DOCUMENT ME!! */ public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! @@ -97,6 +102,8 @@ public class AlignViewport boolean antiAlias = false; + boolean padGaps = false; + public AlignViewport(AlignmentI al, boolean dataset) { @@ -114,6 +121,20 @@ public class AlignViewport setAlignment(al); init(); } + /** + * Create a new AlignViewport with hidden regions + * @param al AlignmentI + * @param hiddenColumns ColumnSelection + */ + public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns) { + setAlignment(al); + if (hiddenColumns!=null) { + this.colSel = hiddenColumns; + if (hiddenColumns.getHiddenColumns() != null) + hasHiddenColumns = true; + } + init(); + } void init() { @@ -131,6 +152,10 @@ public class AlignViewport showQuality = Cache.getDefault("SHOW_QUALITY", true); showIdentity = Cache.getDefault("SHOW_IDENTITY", true); + autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true); + + padGaps = Cache.getDefault("PAD_GAPS", false); + String fontName = Cache.getDefault("FONT_NAME", "SansSerif"); String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "") ; String fontSize = Cache.getDefault("FONT_SIZE", "10"); @@ -308,12 +333,19 @@ public class AlignViewport } catch (OutOfMemoryError error) { - javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Out of memory calculating conservation!!" - + - "\nSee help files for increasing Java Virtual Machine memory." - , "Out of memory", - javax.swing.JOptionPane.WARNING_MESSAGE); + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Out of memory calculating conservation!!" + + + "\nSee help files for increasing Java Virtual Machine memory." + , "Out of memory", + javax.swing.JOptionPane.WARNING_MESSAGE); + } + }); + System.out.println("Conservation calculation: " + error); System.gc(); @@ -393,12 +425,20 @@ public class AlignViewport }catch(OutOfMemoryError error) { - javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Out of memory calculating consensus!!" - + - "\nSee help files for increasing Java Virtual Machine memory." - , "Out of memory", - javax.swing.JOptionPane.WARNING_MESSAGE); + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Out of memory calc45ulating consensus!!" + + + "\nSee help files for increasing Java Virtual Machine memory." + , "Out of memory", + javax.swing.JOptionPane.WARNING_MESSAGE); + } + }); + + System.out.println("Consensus calculation: " + error); System.gc(); } @@ -600,6 +640,7 @@ public class AlignViewport java.awt.FontMetrics fm = c.getFontMetrics(font); setCharHeight(fm.getHeight()); setCharWidth(fm.charWidth('M')); + validCharWidth = true; } /** @@ -846,41 +887,6 @@ public class AlignViewport return increment; } - /** - * DOCUMENT ME! - * - * @param y DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getIndex(int y) - { - int y1 = 0; - int starty = getStartSeq(); - int endy = getEndSeq(); - - for (int i = starty; i <= endy; i++) - { - if ((i < alignment.getHeight()) && - (alignment.getSequenceAt(i) != null)) - { - int y2 = y1 + getCharHeight(); - - if ((y >= y1) && (y <= y2)) - { - return i; - } - - y1 = y2; - } - else - { - return -1; - } - } - - return -1; - } /** * DOCUMENT ME! @@ -1093,10 +1099,36 @@ public class AlignViewport return isDataset; } + + public void hideSelectedColumns() + { + if (colSel.size() < 1) + return; + + colSel.hideSelectedColumns(); + setSelectionGroup(null); + + hasHiddenColumns = true; + } + + + public void hideColumns(int start, int end) + { + if(start==end) + colSel.hideColumns(start); + else + colSel.hideColumns(start, end); + setSelectionGroup(null); + hasHiddenColumns = true; + } + public void hideSequence(SequenceI seq) { - alignment.getHiddenSequences().hideSequence(seq); - hasHiddenRows = true; + if(seq!=null) + { + alignment.getHiddenSequences().hideSequence(seq); + hasHiddenRows = true; + } } public void showSequence(int index) @@ -1107,8 +1139,232 @@ public class AlignViewport hasHiddenRows = false; } + public void showColumn(int col) + { + colSel.revealHiddenColumns(col); + if(colSel.getHiddenColumns()==null) + hasHiddenColumns = false; + } + + public void showAllHiddenColumns() + { + colSel.revealAllHiddenColumns(); + hasHiddenColumns = false; + } + + public void showAllHiddenSeqs() + { + if(alignment.getHiddenSequences().getSize()>0) + { + alignment.getHiddenSequences().showAll(); + hasHiddenRows = false; + } + } + public int adjustForHiddenSeqs(int alignmentIndex) { return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex); } + + /** + * This method returns the a new SequenceI [] with + * the selection sequence and start and end points adjusted + * @return String[] + */ + public SequenceI[] getSelectionAsNewSequence() + { + SequenceI[] sequences; + + if (selectionGroup == null) + sequences = alignment.getSequencesArray(); + else + sequences = selectionGroup.getSelectionAsNewSequences(alignment); + + return sequences; + } + + /** + * This method returns the visible alignment as text, as + * seen on the GUI, ie if columns are hidden they will not + * be returned in the result. + * Use this for calculating trees, PCA, redundancy etc on views + * which contain hidden columns. + * @return String[] + */ + public jalview.datamodel.CigarArray getViewAsCigars(boolean selectedRegionOnly) + { + CigarArray selection=null; + SequenceI [] seqs= null; + int i, iSize; + int start = 0, end = 0; + if(selectedRegionOnly && selectionGroup!=null) + { + iSize = selectionGroup.getSize(false); + seqs = selectionGroup.getSequencesInOrder(alignment); + start = selectionGroup.getStartRes(); + end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor + } + else + { + iSize = alignment.getHeight(); + seqs = alignment.getSequencesArray(); + end = alignment.getWidth()-1; + } + SeqCigar[] selseqs = new SeqCigar[iSize]; + for(i=0; i