X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignViewport.java;h=9f6448d513ceb2a995cff47383a2cbc2b265b609;hb=2ad64bdec4782e3fbfa3b5867a1aa7d1571629fa;hp=e7cae4434305e6beea837c9fc87f28067a0db551;hpb=9fff97021c2c637e426f6971d54dcf3fd4191985;p=jalview.git diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index e7cae44..9f6448d 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -36,7 +36,10 @@ public class AlignViewport int startSeq; int endSeq; - boolean showFullId = true; + + boolean cursorMode = false; + + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; boolean showBoxes = true; @@ -53,14 +56,14 @@ public class AlignViewport boolean conservationColourSelected = false; boolean abovePIDThreshold = false; - SequenceGroup selectionGroup = new SequenceGroup(); + SequenceGroup selectionGroup; int charHeight; int charWidth; - int chunkWidth; - int chunkHeight; + int wrappedWidth; Font font = new Font("SansSerif", Font.PLAIN, 10); + boolean validCharWidth = true; AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); @@ -74,6 +77,21 @@ public class AlignViewport boolean scaleLeftWrapped = true; boolean scaleRightWrapped = true; + // The following vector holds the features which are + // currently visible, in the correct order or rendering + Hashtable featuresDisplayed; + + + public Vector vconsensus; + AlignmentAnnotation consensus; + AlignmentAnnotation conservation; + AlignmentAnnotation quality; + + boolean autocalculateConsensus = true; + + public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! + + private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this); boolean ignoreGapsInConsensusCalculation = false; @@ -91,7 +109,7 @@ public class AlignViewport String param = applet.getParameter("showFullId"); if (param != null) { - showFullId = Boolean.valueOf(param).booleanValue(); + showJVSuffix = Boolean.valueOf(param).booleanValue(); } param = applet.getParameter("showAnnotation"); @@ -123,14 +141,34 @@ public class AlignViewport updateConservation(); updateConsensus(); - if (applet != null && applet.getParameter("defaultColour") != null) + + if (applet != null) { - globalColourScheme = ColourSchemeProperty.getColour(alignment, - applet.getParameter("defaultColour")); - if (globalColourScheme != null) + String colour = applet.getParameter("defaultColour"); + + if(colour == null) + { + colour = applet.getParameter("userDefinedColour"); + if(colour !=null) + colour = "User Defined"; + } + + if(colour != null) { - globalColourScheme.setConsensus(vconsensus); + globalColourScheme = ColourSchemeProperty.getColour(alignment, colour); + if (globalColourScheme != null) + { + globalColourScheme.setConsensus(vconsensus); + } } + + if(applet.getParameter("userDefinedColour")!=null) + { + ((UserColourScheme)globalColourScheme).parseAppletParameter( + applet.getParameter("userDefinedColour")); + } + + } } @@ -139,15 +177,17 @@ public class AlignViewport showSequenceFeatures = b; } - public Vector vconsensus; - AlignmentAnnotation consensus; - AlignmentAnnotation conservation; - AlignmentAnnotation quality; + public boolean getShowSequenceFeatures() + { + return showSequenceFeatures; + } - public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! public void updateConservation() { + if(alignment.isNucleotide()) + return; + Conservation cons = new jalview.analysis.Conservation("All", jalview.schemes.ResidueProperties.propHash, 3, alignment.getSequences(), 0, @@ -217,7 +257,7 @@ public class AlignViewport annotations, 0f, // cons.qualityRange[0].floatValue(), 11f, // cons.qualityRange[1].floatValue() - 1); + AlignmentAnnotation.BAR_GRAPH); if (showConservation) { alignment.addAnnotation(conservation); @@ -227,7 +267,7 @@ public class AlignViewport qannotations, cons.qualityRange[0].floatValue(), cons.qualityRange[1].floatValue(), - 1); + AlignmentAnnotation.BAR_GRAPH); if (showQuality) { alignment.addAnnotation(quality); @@ -290,7 +330,7 @@ public class AlignViewport if (consensus == null) { consensus = new AlignmentAnnotation("Consensus", - "PID", annotations, 0f, 100f, 1); + "PID", annotations, 0f, 100f, AlignmentAnnotation.BAR_GRAPH); if (showConsensus) { alignment.addAnnotation(consensus); @@ -301,6 +341,9 @@ public class AlignViewport consensus.annotations = annotations; } + if(globalColourScheme!=null) + globalColourScheme.setConsensus(vconsensus); + } public SequenceGroup getSelectionGroup() @@ -400,12 +443,17 @@ public class AlignViewport return endSeq; } + java.awt.Frame nullFrame; public void setFont(Font f) { font = f; - java.awt.Frame temp = new java.awt.Frame(); - temp.addNotify(); - java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font); + if(nullFrame == null) + { + nullFrame = new java.awt.Frame(); + nullFrame.addNotify(); + } + + java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font); setCharHeight(fm.getHeight()); setCharWidth(fm.charWidth('M')); } @@ -435,24 +483,14 @@ public class AlignViewport return charHeight; } - public void setChunkWidth(int w) - { - this.chunkWidth = w; - } - - public int getChunkWidth() - { - return chunkWidth; - } - - public void setChunkHeight(int h) + public void setWrappedWidth(int w) { - this.chunkHeight = h; + this.wrappedWidth = w; } - public int getChunkHeight() + public int getwrappedWidth() { - return chunkHeight; + return wrappedWidth; } public AlignmentI getAlignment() @@ -543,32 +581,6 @@ public class AlignViewport return increment; } - 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; - } - public ColumnSelection getColumnSelection() { return colSel; @@ -599,14 +611,14 @@ public class AlignViewport return colourAppliesToAllGroups; } - public boolean getShowFullId() + public boolean getShowJVSuffix() { - return showFullId; + return showJVSuffix; } - public void setShowFullId(boolean b) + public void setShowJVSuffix(boolean b) { - showFullId = b; + showJVSuffix = b; } public boolean getShowAnnotation() @@ -653,16 +665,50 @@ public class AlignViewport { ignoreGapsInConsensusCalculation = b; updateConsensus(); - if (globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme) + if (globalColourScheme!=null) { - ( (ResidueColourScheme) globalColourScheme).setThreshold( - ( (ResidueColourScheme) globalColourScheme).getThreshold(), + globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation); } + } + + /** + * Property change listener for changes in alignment + * + * @param listener DOCUMENT ME! + */ + public void addPropertyChangeListener( + java.beans.PropertyChangeListener listener) + { + changeSupport.addPropertyChangeListener(listener); + } + + /** + * DOCUMENT ME! + * + * @param listener DOCUMENT ME! + */ + public void removePropertyChangeListener( + java.beans.PropertyChangeListener listener) + { + changeSupport.removePropertyChangeListener(listener); + } + /** + * Property change listener for changes in alignment + * + * @param prop DOCUMENT ME! + * @param oldvalue DOCUMENT ME! + * @param newvalue DOCUMENT ME! + */ + public void firePropertyChange(String prop, Object oldvalue, Object newvalue) + { + changeSupport.firePropertyChange(prop, oldvalue, newvalue); } + + public boolean getIgnoreGapsConsensus() { return ignoreGapsInConsensusCalculation;