getIndex replaced by findSeq in Seqpanel
[jalview.git] / src / jalview / appletgui / AlignViewport.java
index 4b4d74d..9f6448d 100755 (executable)
@@ -36,7 +36,10 @@ public class AlignViewport
   int startSeq;\r
   int endSeq;\r
 \r
-  boolean showFullId = true;\r
+\r
+  boolean cursorMode = false;\r
+\r
+  boolean showJVSuffix = true;\r
   boolean showText = true;\r
   boolean showColourText = false;\r
   boolean showBoxes = true;\r
@@ -53,14 +56,14 @@ public class AlignViewport
   boolean conservationColourSelected = false;\r
   boolean abovePIDThreshold = false;\r
 \r
-  SequenceGroup selectionGroup = new SequenceGroup();\r
+  SequenceGroup selectionGroup;\r
 \r
   int charHeight;\r
   int charWidth;\r
-  int chunkWidth;\r
-  int chunkHeight;\r
+  int wrappedWidth;\r
 \r
   Font font = new Font("SansSerif", Font.PLAIN, 10);\r
+  boolean validCharWidth = true;\r
   AlignmentI alignment;\r
 \r
   ColumnSelection colSel = new ColumnSelection();\r
@@ -74,6 +77,21 @@ public class AlignViewport
   boolean scaleLeftWrapped = true;\r
   boolean scaleRightWrapped = true;\r
 \r
+  // The following vector holds the features which are\r
+ // currently visible, in the correct order or rendering\r
+  Hashtable featuresDisplayed;\r
+\r
+\r
+  public Vector vconsensus;\r
+  AlignmentAnnotation consensus;\r
+  AlignmentAnnotation conservation;\r
+  AlignmentAnnotation quality;\r
+\r
+  boolean autocalculateConsensus = true;\r
+\r
+  public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!\r
+\r
+  private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this);\r
 \r
   boolean ignoreGapsInConsensusCalculation = false;\r
 \r
@@ -91,7 +109,7 @@ public class AlignViewport
       String param = applet.getParameter("showFullId");\r
       if (param != null)\r
       {\r
-        showFullId = Boolean.valueOf(param).booleanValue();\r
+        showJVSuffix = Boolean.valueOf(param).booleanValue();\r
       }\r
 \r
       param = applet.getParameter("showAnnotation");\r
@@ -123,14 +141,34 @@ public class AlignViewport
     updateConservation();\r
     updateConsensus();\r
 \r
-    if (applet != null && applet.getParameter("defaultColour") != null)\r
+\r
+    if (applet != null)\r
     {\r
-      globalColourScheme = ColourSchemeProperty.getColour(alignment,\r
-          applet.getParameter("defaultColour"));\r
-      if (globalColourScheme != null)\r
+      String colour = applet.getParameter("defaultColour");\r
+\r
+      if(colour == null)\r
+      {\r
+        colour = applet.getParameter("userDefinedColour");\r
+        if(colour !=null)\r
+          colour = "User Defined";\r
+      }\r
+\r
+      if(colour != null)\r
       {\r
-        globalColourScheme.setConsensus(vconsensus);\r
+        globalColourScheme = ColourSchemeProperty.getColour(alignment, colour);\r
+        if (globalColourScheme != null)\r
+        {\r
+          globalColourScheme.setConsensus(vconsensus);\r
+        }\r
       }\r
+\r
+      if(applet.getParameter("userDefinedColour")!=null)\r
+      {\r
+        ((UserColourScheme)globalColourScheme).parseAppletParameter(\r
+            applet.getParameter("userDefinedColour"));\r
+      }\r
+\r
+\r
     }\r
   }\r
 \r
@@ -139,15 +177,17 @@ public class AlignViewport
     showSequenceFeatures = b;\r
   }\r
 \r
-  public Vector vconsensus;\r
-  AlignmentAnnotation consensus;\r
-  AlignmentAnnotation conservation;\r
-  AlignmentAnnotation quality;\r
+  public boolean getShowSequenceFeatures()\r
+  {\r
+    return showSequenceFeatures;\r
+  }\r
 \r
-  public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!\r
 \r
   public void updateConservation()\r
   {\r
+    if(alignment.isNucleotide())\r
+          return;\r
+\r
     Conservation cons = new jalview.analysis.Conservation("All",\r
         jalview.schemes.ResidueProperties.propHash, 3,\r
         alignment.getSequences(), 0,\r
@@ -217,7 +257,7 @@ public class AlignViewport
                                              annotations,\r
                                              0f, // cons.qualityRange[0].floatValue(),\r
                                              11f, // cons.qualityRange[1].floatValue()\r
-                                             1);\r
+                                             AlignmentAnnotation.BAR_GRAPH);\r
       if (showConservation)\r
       {\r
         alignment.addAnnotation(conservation);\r
@@ -227,7 +267,7 @@ public class AlignViewport
                                         qannotations,\r
                                         cons.qualityRange[0].floatValue(),\r
                                         cons.qualityRange[1].floatValue(),\r
-                                        1);\r
+                                        AlignmentAnnotation.BAR_GRAPH);\r
       if (showQuality)\r
       {\r
         alignment.addAnnotation(quality);\r
@@ -290,7 +330,7 @@ public class AlignViewport
     if (consensus == null)\r
     {\r
       consensus = new AlignmentAnnotation("Consensus",\r
-                                          "PID", annotations, 0f, 100f, 1);\r
+                                          "PID", annotations, 0f, 100f, AlignmentAnnotation.BAR_GRAPH);\r
       if (showConsensus)\r
       {\r
         alignment.addAnnotation(consensus);\r
@@ -403,12 +443,17 @@ public class AlignViewport
     return endSeq;\r
   }\r
 \r
+  java.awt.Frame nullFrame;\r
   public void setFont(Font f)\r
   {\r
     font = f;\r
-    java.awt.Frame temp = new java.awt.Frame();\r
-    temp.addNotify();\r
-    java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font);\r
+    if(nullFrame == null)\r
+    {\r
+      nullFrame = new java.awt.Frame();\r
+      nullFrame.addNotify();\r
+    }\r
+\r
+    java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);\r
     setCharHeight(fm.getHeight());\r
     setCharWidth(fm.charWidth('M'));\r
   }\r
@@ -438,24 +483,14 @@ public class AlignViewport
     return charHeight;\r
   }\r
 \r
-  public void setChunkWidth(int w)\r
-  {\r
-    this.chunkWidth = w;\r
-  }\r
-\r
-  public int getChunkWidth()\r
-  {\r
-    return chunkWidth;\r
-  }\r
-\r
-  public void setChunkHeight(int h)\r
+  public void setWrappedWidth(int w)\r
   {\r
-    this.chunkHeight = h;\r
+    this.wrappedWidth = w;\r
   }\r
 \r
-  public int getChunkHeight()\r
+  public int getwrappedWidth()\r
   {\r
-    return chunkHeight;\r
+    return wrappedWidth;\r
   }\r
 \r
   public AlignmentI getAlignment()\r
@@ -546,32 +581,6 @@ public class AlignViewport
     return increment;\r
   }\r
 \r
-  public int getIndex(int y)\r
-  {\r
-    int y1 = 0;\r
-    int starty = getStartSeq();\r
-    int endy = getEndSeq();\r
-\r
-    for (int i = starty; i <= endy; i++)\r
-    {\r
-      if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null)\r
-      {\r
-        int y2 = y1 + getCharHeight();\r
-\r
-        if (y >= y1 && y <= y2)\r
-        {\r
-          return i;\r
-        }\r
-        y1 = y2;\r
-      }\r
-      else\r
-      {\r
-        return -1;\r
-      }\r
-    }\r
-    return -1;\r
-  }\r
-\r
   public ColumnSelection getColumnSelection()\r
   {\r
     return colSel;\r
@@ -602,14 +611,14 @@ public class AlignViewport
     return colourAppliesToAllGroups;\r
   }\r
 \r
-  public boolean getShowFullId()\r
+  public boolean getShowJVSuffix()\r
   {\r
-    return showFullId;\r
+    return showJVSuffix;\r
   }\r
 \r
-  public void setShowFullId(boolean b)\r
+  public void setShowJVSuffix(boolean b)\r
   {\r
-    showFullId = b;\r
+    showJVSuffix = b;\r
   }\r
 \r
   public boolean getShowAnnotation()\r
@@ -662,9 +671,44 @@ public class AlignViewport
           ignoreGapsInConsensusCalculation);\r
 \r
     }\r
+  }\r
+\r
+  /**\r
+   * Property change listener for changes in alignment\r
+   *\r
+   * @param listener DOCUMENT ME!\r
+   */\r
+  public void addPropertyChangeListener(\r
+      java.beans.PropertyChangeListener listener)\r
+  {\r
+      changeSupport.addPropertyChangeListener(listener);\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param listener DOCUMENT ME!\r
+   */\r
+  public void removePropertyChangeListener(\r
+      java.beans.PropertyChangeListener listener)\r
+  {\r
+      changeSupport.removePropertyChangeListener(listener);\r
+  }\r
 \r
+  /**\r
+   * Property change listener for changes in alignment\r
+   *\r
+   * @param prop DOCUMENT ME!\r
+   * @param oldvalue DOCUMENT ME!\r
+   * @param newvalue DOCUMENT ME!\r
+   */\r
+  public void firePropertyChange(String prop, Object oldvalue, Object newvalue)\r
+  {\r
+      changeSupport.firePropertyChange(prop, oldvalue, newvalue);\r
   }\r
 \r
+\r
+\r
   public boolean getIgnoreGapsConsensus()\r
   {\r
     return ignoreGapsInConsensusCalculation;\r