X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=2e1a4e0251b169ff68777dbcd96b75fcc2984d90;hb=621a628afc1f6ee7a2778b9d0ae2729b88fe5bfd;hp=a92517c3b0f09afcee0673d4e3be235589e189e8;hpb=99f3f01792321efb671ac7ad946efffc3a3319a4;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index a92517c..2e1a4e0 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; @@ -86,6 +87,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! @@ -99,6 +101,8 @@ public class AlignViewport boolean antiAlias = false; + boolean padGaps = false; + public AlignViewport(AlignmentI al, boolean dataset) { @@ -133,6 +137,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"); @@ -310,12 +318,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(); @@ -395,12 +410,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(); } @@ -602,6 +625,7 @@ public class AlignViewport java.awt.FontMetrics fm = c.getFontMetrics(font); setCharHeight(fm.getHeight()); setCharWidth(fm.charWidth('M')); + validCharWidth = true; } /** @@ -1109,8 +1133,116 @@ public class AlignViewport hasHiddenRows = false; } + public void showAllHiddenSeqs() + { + 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 selected area 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 String [] getSelectionAsString() + { + String [] selection = null; + SequenceI [] seqs= null; + int i, iSize; + int start = 0, end = 0; + if(selectionGroup!=null) + { + iSize = selectionGroup.getSize(false); + seqs = selectionGroup.getSequencesInOrder(alignment); + start = selectionGroup.getStartRes(); + end = selectionGroup.getEndRes()+1; + } + else + { + iSize = alignment.getHeight(); + seqs = alignment.getSequencesArray(); + end = alignment.getWidth(); + } + + selection = new String[iSize]; + + + for(i=0; iblockEnd) + { + break; + } + + + visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd)); + + blockStart = hideEnd+1; + blockEnd = end; + } + + if(end>blockStart) + visibleSeq.append(seqs[i].getSequence(blockStart, end)); + + selection[i] = visibleSeq.toString(); + } + else + { + selection[i] = seqs[i].getSequence(start, end); + } + + // System.out.println(seqs[i].getName()+"\t"+ selection[i]); + } + + return selection; + } }