Allow features in overview window
authoramwaterhouse <Andrew Waterhouse>
Mon, 30 Jan 2006 14:45:10 +0000 (14:45 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 30 Jan 2006 14:45:10 +0000 (14:45 +0000)
src/jalview/appletgui/FeatureRenderer.java
src/jalview/appletgui/OverviewPanel.java

index 4a97e43..048df28 100755 (executable)
@@ -24,7 +24,6 @@ import java.awt.*;
 \r
 import java.util.*;\r
 \r
-\r
 /**\r
  * DOCUMENT ME!\r
  *\r
@@ -36,7 +35,6 @@ public class FeatureRenderer
     AlignViewport av;\r
     SequenceGroup currentSequenceGroup = null;\r
     SequenceGroup[] allGroups = null;\r
-    Color resBoxColour;\r
     Graphics graphics;\r
     float transparency = .4f;\r
 \r
@@ -44,6 +42,8 @@ public class FeatureRenderer
     // to be added, in the correct order or rendering\r
     Vector featuresDisplayed;\r
 \r
+    Color currentColour = null;\r
+\r
     /**\r
      * Creates a new FeatureRenderer object.\r
      *\r
@@ -59,7 +59,7 @@ public class FeatureRenderer
 \r
     }\r
 \r
-boolean highlightTransparent = true;\r
+    boolean highlightTransparent = true;\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -73,7 +73,7 @@ boolean highlightTransparent = true;
      * @param width DOCUMENT ME!\r
      * @param height DOCUMENT ME!\r
      */\r
-    public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,\r
+    public void drawSequence(Graphics g, SequenceI seq,\r
         int start, int end, int x1, int y1, int width, int height)\r
     {\r
 \r
@@ -141,7 +141,8 @@ boolean highlightTransparent = true;
 \r
                 if (fstart == fend)\r
                 {\r
-                    g.setColor(getColour(type));\r
+                    currentColour = getColour(type);\r
+                    g.setColor(currentColour);\r
                     g.fillRoundRect((fstart - start) * width, y1, width,\r
                         height, 4, 4);\r
                     g.setColor(Color.white);\r
@@ -164,8 +165,9 @@ boolean highlightTransparent = true;
                         {\r
                             continue;\r
                         }\r
+                        currentColour = getColour(type);\r
+                        g.setColor(currentColour);\r
 \r
-                        g.setColor(getColour(type));\r
                         g.fillRect((i - start) * width, y1, width, height);\r
 \r
                         g.setColor(Color.white);\r
@@ -187,6 +189,25 @@ boolean highlightTransparent = true;
           }\r
     }\r
 \r
+\r
+    Image offscreen;\r
+    Frame nullframe;\r
+    public Color findFeatureColour(Color initialCol, SequenceI seq, int i)\r
+    {\r
+      currentColour = initialCol;\r
+      if(offscreen == null)\r
+      {\r
+        nullframe = new Frame();\r
+        nullframe.addNotify();\r
+        offscreen = nullframe.createImage(1, 1);\r
+      }\r
+\r
+      drawSequence(offscreen.getGraphics(), seq, i, i, 0, 0, 1, 1);\r
+      return currentColour;\r
+    }\r
+\r
+\r
+\r
     public Color getColour(String featureType)\r
     {\r
       return (Color)featureColours.get(featureType);\r
index c5789fe..9c3e908 100755 (executable)
@@ -40,7 +40,7 @@ public class OverviewPanel
   // Can set different properties in this seqCanvas than\r
   // main visible SeqCanvas\r
   SequenceRenderer sr;\r
-  //FeatureRenderer fr;\r
+  FeatureRenderer fr;\r
 \r
 \r
   Frame nullFrame;\r
@@ -57,10 +57,9 @@ public class OverviewPanel
     sr = new SequenceRenderer(av);\r
     sr.graphics = nullFrame.getGraphics();\r
     sr.renderGaps( false );\r
-    //fr = new FeatureRenderer(av);\r
-    //fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency;\r
-    //fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed;\r
-\r
+    fr = new FeatureRenderer(av);\r
+    fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency;\r
+    fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed;\r
 \r
 \r
     // scale the initial size of overviewpanel to shape of alignment\r
@@ -245,7 +244,16 @@ public class OverviewPanel
         lastrow = (int)(row*sampleRow);\r
         lastcol = (int)(col*sampleCol);\r
 \r
-        color = sr.findSequenceColour(av.alignment.getSequenceAt(lastrow), lastcol);\r
+        if(av.alignment.getSequenceAt(lastrow).getLength()>lastcol)\r
+        {\r
+          color = sr.findSequenceColour(av.alignment.getSequenceAt(lastrow), lastcol);\r
+\r
+          if (av.showSequenceFeatures)\r
+            color = fr.findFeatureColour(color,\r
+                                         av.alignment.getSequenceAt(lastrow),\r
+                                         lastcol);\r
+        }\r
+\r
 \r
         mg.setColor(color);\r
         mg.fillRect(col,row,1,1);\r