X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=fde4d90e18bbf9f5c2b1e09f3aac7850c817c9a6;hb=d5b157fc64cc6e5f633a2f7ae991a29b7c557b94;hp=2922f0910e5b23904b95946ab7f6d96cd4601067;hpb=92f934a3ed429a46227cf829f985d72cb7e86fb7;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 2922f09..fde4d90 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -43,7 +43,7 @@ public class AlignViewport int endRes; int startSeq; int endSeq; - boolean showFullId = false; + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; boolean showBoxes = true; @@ -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! @@ -86,6 +98,19 @@ public class AlignViewport boolean ignoreGapsInConsensusCalculation = false; + boolean isDataset = false; + + boolean antiAlias = false; + + boolean padGaps = false; + + + public AlignViewport(AlignmentI al, boolean dataset) + { + isDataset = dataset; + setAlignment(al); + init(); + } /** * Creates a new AlignViewport object. * @@ -94,26 +119,43 @@ public class AlignViewport public AlignViewport(AlignmentI al) { setAlignment(al); - this.startRes = 0; - this.endRes = al.getWidth() - 1; - this.startSeq = 0; - this.endSeq = al.getHeight() - 1; - - updateFromPreferences(); + init(); } - /** - * DOCUMENT ME! + * Create a new AlignViewport with hidden regions + * @param al AlignmentI + * @param hiddenColumns ColumnSelection */ - public void updateFromPreferences() + public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns) { + setAlignment(al); + if (hiddenColumns!=null) { + this.colSel = hiddenColumns; + if (hiddenColumns.getHiddenColumns() != null) + hasHiddenColumns = true; + } + init(); + } + + void init() { - showFullId = Cache.getDefault("SHOW_FULL_ID", true); + this.startRes = 0; + this.endRes = alignment.getWidth() - 1; + this.startSeq = 0; + this.endSeq = alignment.getHeight() - 1; + + antiAlias = Cache.getDefault("ANTI_ALIAS", false); + + showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true); showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true); showConservation = Cache.getDefault("SHOW_CONSERVATION", true); 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"); @@ -137,9 +179,11 @@ public class AlignViewport // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done - updateConservation(); - - updateConsensus(); + if(vconsensus==null && !isDataset) + { + updateConservation(); + updateConsensus(); + } if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null) { @@ -166,11 +210,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! */ @@ -256,7 +305,7 @@ public class AlignViewport ConsPercGaps + "% gaps", annotations, 0f, // cons.qualityRange[0].floatValue(), 11f, // cons.qualityRange[1].floatValue() - 1); + AlignmentAnnotation.BAR_GRAPH); if (showConservation) { @@ -268,7 +317,7 @@ public class AlignViewport qannotations, cons.qualityRange[0].floatValue(), cons.qualityRange[1].floatValue(), - 1); + AlignmentAnnotation.BAR_GRAPH); if (showQuality) { @@ -284,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(); @@ -352,7 +408,7 @@ public class AlignViewport if (consensus == null) { consensus = new AlignmentAnnotation("Consensus", "PID", - annotations, 0f, 100f, 1); + annotations, 0f, 100f,AlignmentAnnotation.BAR_GRAPH); if (showIdentity) { @@ -369,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(); } @@ -576,6 +640,7 @@ public class AlignViewport java.awt.FontMetrics fm = c.getFontMetrics(font); setCharHeight(fm.getHeight()); setCharWidth(fm.charWidth('M')); + validCharWidth = true; } /** @@ -822,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! @@ -914,9 +944,9 @@ public class AlignViewport * * @return DOCUMENT ME! */ - public boolean getShowFullId() + public boolean getShowJVSuffix() { - return showFullId; + return showJVSuffix; } /** @@ -924,11 +954,12 @@ public class AlignViewport * * @param b DOCUMENT ME! */ - public void setShowFullId(boolean b) + public void setShowJVSuffix(boolean b) { - showFullId = b; + showJVSuffix = b; } + /** * DOCUMENT ME! * @@ -1051,11 +1082,289 @@ public class AlignViewport { globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation); } - } public boolean getIgnoreGapsConsensus() { return ignoreGapsInConsensusCalculation; } + + public void setDataset(boolean b) + { + isDataset = b; + } + + public boolean isDataset() + { + 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) + { + if(seq!=null) + { + alignment.getHiddenSequences().hideSequence(seq); + hasHiddenRows = true; + } + } + + public void showSequence(int index) + { + alignment.getHiddenSequences().showSequence(index); + + if(alignment.getHiddenSequences().getSize()<1) + 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