X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=37422590d4306f1fe2bf136981b554fd2487fbed;hb=91c5d2144a780716e755e99882acffe46b40f18f;hp=088d4273b8397893f8fd4fea13df5e64b43218c1;hpb=1deb6329192c4750c104d4da8c70f9cb6e3c5a42;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 088d427..3742259 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; @@ -71,12 +72,23 @@ public class AlignViewport boolean scaleAboveWrapped = false; boolean scaleLeftWrapped = true; 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 + Hashtable featuresDisplayed = null; + /** DOCUMENT ME!! */ public Vector vconsensus; AlignmentAnnotation consensus; AlignmentAnnotation conservation; AlignmentAnnotation quality; + boolean autoCalculateConsensus = true; /** DOCUMENT ME!! */ public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! @@ -90,6 +102,8 @@ public class AlignViewport boolean antiAlias = false; + boolean padGaps = false; + public AlignViewport(AlignmentI al, boolean dataset) { @@ -124,6 +138,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"); @@ -178,11 +196,16 @@ public class AlignViewport * * @param b DOCUMENT ME! */ - public void showSequenceFeatures(boolean b) + public void setShowSequenceFeatures(boolean b) { showSequenceFeatures = b; } + public boolean getShowSequenceFeatures() + { + return showSequenceFeatures; + } + /** * DOCUMENT ME! */ @@ -296,12 +319,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(); @@ -381,12 +411,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(); } @@ -588,6 +626,7 @@ public class AlignViewport java.awt.FontMetrics fm = c.getFontMetrics(font); setCharHeight(fm.getHeight()); setCharWidth(fm.charWidth('M')); + validCharWidth = true; } /** @@ -1064,7 +1103,6 @@ public class AlignViewport { globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation); } - } public boolean getIgnoreGapsConsensus() @@ -1081,4 +1119,176 @@ public class AlignViewport { return isDataset; } + + + public void hideSelectedColumns() + { + if (colSel.selected.size() < 1) + return; + + while (colSel.selected.size() > 0) + { + int column = ( (Integer) colSel.selected.firstElement()).intValue(); + colSel.hideColumns(column); + } + setSelectionGroup(null); + hasHiddenColumns = true; + } + + + public void hideColumns(int start, int end) + { + if(start==end) + end++; + + for(int i=start; i0) + { + 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 String [] getViewAsString(boolean selectedRegionOnly) + { + String [] 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()+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); + } + } + + return selection; + } + + public boolean getShowHiddenMarkers() + { + return showHiddenMarkers; + } + + public void setShowHiddenMarkers(boolean show) + { + showHiddenMarkers = show; + } }