Features now array for speed of rendering
authoramwaterhouse <Andrew Waterhouse>
Fri, 24 Feb 2006 11:41:26 +0000 (11:41 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 24 Feb 2006 11:41:26 +0000 (11:41 +0000)
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/OverviewPanel.java

index 22789a1..405fe98 100755 (executable)
@@ -24,8 +24,6 @@ import java.awt.*;
 \r
 import java.util.*;\r
 \r
-import java.awt.image.*;\r
-\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -40,17 +38,19 @@ public class FeatureRenderer
     float transparency = 1.0f;\r
     FontMetrics fm;\r
     int charOffset;\r
-    boolean drawText = true;\r
-\r
-    // The following vector holds the features which are\r
-    // to be added, in the correct order or rendering\r
-    Vector featuresDisplayed = null;\r
 \r
     // A higher level for grouping features of a\r
    // particular type\r
     Hashtable featureGroups = null;\r
 \r
 \r
+    // This is actually an Integer held in the hashtable,\r
+    // Retrieved using the key feature type\r
+    Object currentColour;\r
+\r
+    String [] renderOrder;\r
+\r
+\r
     /**\r
      * Creates a new FeatureRenderer object.\r
      *\r
@@ -62,27 +62,67 @@ public class FeatureRenderer
         initColours();\r
     }\r
 \r
+\r
+    public Color findFeatureColour(Color initialCol, SequenceI seq, int i)\r
+    {\r
+      if(!av.showSequenceFeatures)\r
+        return initialCol;\r
+\r
+        lastSequence = seq;\r
+        sequenceFeatures = lastSequence.getDatasetSequence().getSequenceFeatures();\r
+        if(sequenceFeatures==null)\r
+          return initialCol;\r
+\r
+        sfSize = sequenceFeatures.length;\r
+\r
+      if(jalview.util.Comparison.isGap(lastSequence.getCharAt(i)))\r
+        return Color.white;\r
+\r
+      currentColour = null;\r
+\r
+      drawSequence(null, lastSequence, lastSequence.findPosition(i), -1,-1, -1, -1);\r
+\r
+      if(currentColour==null)\r
+        return initialCol;\r
+\r
+      return new Color( ((Integer)currentColour).intValue() );\r
+    }\r
     /**\r
      * This is used by the Molecule Viewer to get the accurate colour\r
      * of the rendered sequence\r
      */\r
-    BufferedImage bi;\r
-    public Color findFeatureColour(Color initialCol, SequenceI seq, int i)\r
+\r
+    boolean overview = false;\r
+\r
+    int white = Color.white.getRGB();\r
+    public int findFeatureColour(int initialCol, int seqIndex, int column)\r
     {\r
       if(!av.showSequenceFeatures)\r
         return initialCol;\r
 \r
-      if (bi == null)\r
-        bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);\r
+      if(seqIndex!=lastSequenceIndex)\r
+      {\r
+        lastSequence = av.alignment.getSequenceAt(seqIndex);\r
+        lastSequenceIndex = seqIndex;\r
+        sequenceFeatures = lastSequence.getDatasetSequence().getSequenceFeatures();\r
+        if(sequenceFeatures==null)\r
+          return initialCol;\r
 \r
-      bi.setRGB(0,0, initialCol.getRGB());\r
+        sfSize = sequenceFeatures.length;\r
+      }\r
 \r
-      drawText = false;\r
 \r
-      drawSequence(bi.getGraphics(), seq, i, i, 0, 0, 1, 1);\r
-      drawText = true;\r
+      if(jalview.util.Comparison.isGap(lastSequence.getCharAt(column)))\r
+        return Color.white.getRGB();\r
+\r
+      currentColour = null;\r
+\r
+      drawSequence(null, lastSequence, lastSequence.findPosition(column), -1,-1, -1, -1);\r
+\r
+      if(currentColour==null)\r
+        return initialCol;\r
 \r
-      return new Color(bi.getRGB(0, 0));\r
+      return  ((Integer)currentColour).intValue();\r
     }\r
 \r
 \r
@@ -99,18 +139,41 @@ public class FeatureRenderer
      * @param width DOCUMENT ME!\r
      * @param height DOCUMENT ME!\r
      */\r
+   // String type;\r
+   // SequenceFeature sf;\r
+    int lastSequenceIndex=-1;\r
+    SequenceI lastSequence;\r
+    SequenceFeature [] sequenceFeatures;\r
+    int sfSize, sfindex, spos, epos;\r
+\r
     public void drawSequence(Graphics g, SequenceI seq,\r
-                             int start, int end, int x1, int y1, int width, int height)\r
+                             int start, int end, int y1, int width, int height)\r
     {\r
-\r
-        //System.out.println(start+" "+end+" "+x1+" "+y1);\r
-      if (seq.getDatasetSequence().getSequenceFeatures() == null\r
-          || seq.getDatasetSequence().getSequenceFeatures().size()==0)\r
+      if (   seq.getDatasetSequence().getSequenceFeatures() == null\r
+          || seq.getDatasetSequence().getSequenceFeatures().length==0)\r
         return;\r
 \r
-      fm = g.getFontMetrics();\r
 \r
-      if (transparency != 1)\r
+      if(g!=null)\r
+        fm = g.getFontMetrics();\r
+\r
+\r
+      if (av.featuresDisplayed == null || renderOrder==null)\r
+       {\r
+         findAllFeatures();\r
+         sequenceFeatures = seq.getDatasetSequence().getSequenceFeatures();\r
+         sfSize = sequenceFeatures.length;\r
+       }\r
+\r
+       if(lastSequence==null || seq!=lastSequence)\r
+      {\r
+        lastSequence = seq;\r
+        sequenceFeatures = seq.getDatasetSequence().getSequenceFeatures();\r
+        sfSize = sequenceFeatures.length;\r
+      }\r
+\r
+\r
+      if (transparency != 1 && g!=null)\r
       {\r
         Graphics2D g2 = (Graphics2D) g;\r
         g2.setComposite(\r
@@ -118,61 +181,80 @@ public class FeatureRenderer
                 AlphaComposite.SRC_OVER, transparency));\r
       }\r
 \r
-      String type;\r
-      SequenceFeature sf;\r
-      if (featuresDisplayed == null)\r
-        findAllFeatures();\r
-\r
-      Enumeration e = featuresDisplayed.elements(), e2;\r
-\r
-      // Loop through each visible feature\r
-      while (e.hasMoreElements())\r
+      if(!overview)\r
       {\r
+        spos = lastSequence.findPosition(start);\r
+        epos = lastSequence.findPosition(end);\r
+      }\r
+\r
+      String type;\r
+      for(int renderIndex=0; renderIndex<renderOrder.length; renderIndex++)\r
+       {\r
+        type =  renderOrder[renderIndex];\r
 \r
-        type = e.nextElement().toString();\r
-        e2 = seq.getDatasetSequence().getSequenceFeatures().elements();\r
         // loop through all features in sequence to find\r
         // current feature to render\r
-          while (e2.hasMoreElements())\r
+        for (sfindex = 0; sfindex < sfSize; sfindex++)\r
         {\r
-\r
-          sf = (SequenceFeature) e2.nextElement();\r
-          if (!type.equals(sf.getType()))\r
+          if (!sequenceFeatures[sfindex].type.equals(type))\r
             continue;\r
 \r
-          if(featureGroups!=null\r
-             && sf.getFeatureGroup()!=null\r
-             && featureGroups.containsKey(sf.getFeatureGroup())\r
-             && !((Boolean)featureGroups.get(sf.getFeatureGroup())).booleanValue())\r
+          if (featureGroups != null\r
+              && sequenceFeatures[sfindex].featureGroup != null\r
+              &&\r
+              featureGroups.containsKey(sequenceFeatures[sfindex].featureGroup)\r
+              &&\r
+              ! ( (Boolean) featureGroups.get(sequenceFeatures[sfindex].featureGroup)).\r
+              booleanValue())\r
           {\r
             continue;\r
           }\r
 \r
-          if (sf.getBegin() > seq.getEnd())\r
+          if (!overview && (sequenceFeatures[sfindex].getBegin() > epos\r
+                            || sequenceFeatures[sfindex].getEnd() < spos))\r
             continue;\r
 \r
-          if (type.equals("disulfide bond"))\r
+          if (overview)\r
+          {\r
+\r
+            if (sequenceFeatures[sfindex].begin - 1 <= start &&\r
+                sequenceFeatures[sfindex].end + 1 >= start)\r
+            {\r
+              currentColour = av.featuresDisplayed.get(sequenceFeatures[sfindex].\r
+                  type);\r
+            }\r
+\r
+          }\r
+          else if (sequenceFeatures[sfindex].type.equals("disulfide bond"))\r
           {\r
 \r
             renderFeature(g, seq,\r
-                          seq.findIndex(sf.getBegin()) - 1,\r
-                          seq.findIndex(sf.getBegin()) - 1,\r
-                          type, start, end, x1, y1, width, height);\r
+                          seq.findIndex(sequenceFeatures[sfindex].begin) - 1,\r
+                          seq.findIndex(sequenceFeatures[sfindex].begin) - 1,\r
+                          new Color( ( (Integer) av.featuresDisplayed.get(\r
+                sequenceFeatures[sfindex].type)).intValue()),\r
+                          start, end, y1, width, height);\r
             renderFeature(g, seq,\r
-                          seq.findIndex(sf.getEnd()) - 1,\r
-                          seq.findIndex(sf.getEnd()) - 1,\r
-                          type, start, end, x1, y1, width, height);\r
+                          seq.findIndex(sequenceFeatures[sfindex].end) - 1,\r
+                          seq.findIndex(sequenceFeatures[sfindex].end) - 1,\r
+                          new Color( ( (Integer) av.featuresDisplayed.get(\r
+                sequenceFeatures[sfindex].type)).intValue()),\r
+                          start, end, y1, width, height);\r
 \r
           }\r
           else\r
             renderFeature(g, seq,\r
-                          seq.findIndex(sf.getBegin()) - 1,\r
-                          seq.findIndex(sf.getEnd()) - 1,\r
-                          type, start, end, x1, y1, width, height);\r
+                          seq.findIndex(sequenceFeatures[sfindex].begin) - 1,\r
+                          seq.findIndex(sequenceFeatures[sfindex].end) - 1,\r
+                          getColour(sequenceFeatures[sfindex].type),\r
+                          start, end, y1, width, height);\r
+\r
+\r
         }\r
+\r
       }\r
 \r
-        if(transparency!=1.0f)\r
+        if(transparency!=1.0f && g!=null)\r
         {\r
           Graphics2D g2 = (Graphics2D) g;\r
           g2.setComposite(\r
@@ -182,69 +264,78 @@ public class FeatureRenderer
     }\r
 \r
 \r
+    char s;\r
+    int i;\r
     void renderFeature(Graphics g, SequenceI seq,\r
-                       int fstart, int fend, String type, int start, int end, int x1, int y1, int width, int height)\r
+                       int fstart, int fend, Color featureColour, int start, int end,  int y1, int width, int height)\r
     {\r
 \r
       if (((fstart <= end) && (fend >= start)))\r
       {\r
-          if (fstart < start)\r
-          { // fix for if the feature we have starts before the sequence start,\r
-              fstart = start; // but the feature end is still valid!!\r
-          }\r
+        if (fstart < start)\r
+        { // fix for if the feature we have starts before the sequence start,\r
+          fstart = start; // but the feature end is still valid!!\r
+        }\r
 \r
-          if (fend >= end)\r
-          {\r
-            fend = end;\r
-          }\r
-          for (int i = fstart; i <= fend; i++)\r
+        if (fend >= end)\r
+        {\r
+          fend = end;\r
+        }\r
+\r
+          for (i = fstart; i <= fend; i++)\r
           {\r
-            char s = seq.getSequence().charAt(i);\r
+            s = seq.getSequence().charAt(i);\r
 \r
             if (jalview.util.Comparison.isGap(s))\r
             {\r
               continue;\r
             }\r
 \r
-            g.setColor(getColour(type));\r
+            g.setColor(featureColour);\r
 \r
             g.fillRect( (i - start) * width, y1, width, height);\r
 \r
-            if(drawText)\r
-           {\r
-             g.setColor(Color.white);\r
-             charOffset = (width - fm.charWidth(s)) / 2;\r
-             g.drawString(String.valueOf(s),\r
-                          charOffset + x1 + (width * (i - start)),\r
-                          (y1 + height) - height / 5); //pady = height / 5;\r
-           }\r
+            g.setColor(Color.white);\r
+            charOffset = (width - fm.charWidth(s)) / 2;\r
+            g.drawString(String.valueOf(s),\r
+                         charOffset + (width * (i - start)),\r
+                         (y1 + height) - height / 5); //pady = height / 5;\r
+\r
           }\r
-        }\r
+      }\r
     }\r
 \r
     void findAllFeatures()\r
     {\r
-      Vector features = new Vector();\r
-      SequenceFeature sf;\r
-      featuresDisplayed = new Vector();\r
-      Enumeration e;\r
+      av.featuresDisplayed = new Hashtable();\r
       for (int i = 0; i < av.alignment.getHeight(); i++)\r
       {\r
-        features = av.alignment.getSequenceAt(i).getDatasetSequence().\r
+        SequenceFeature [] features = av.alignment.getSequenceAt(i).getDatasetSequence().\r
             getSequenceFeatures();\r
+\r
         if (features == null)\r
           continue;\r
 \r
-        e = features.elements();\r
-        while (e.hasMoreElements())\r
+        int index = 0;\r
+        while (index < features.length)\r
         {\r
-          sf = (SequenceFeature) e.nextElement();\r
-          if (!featuresDisplayed.contains(sf.getType()))\r
+          if (!av.featuresDisplayed.containsKey(features[index].getType()))\r
           {\r
-            featuresDisplayed.addElement(sf.getType());\r
+            av.featuresDisplayed.put(features[index].getType(),\r
+                                  new Integer( getColour(features[index].getType()).getRGB()) );\r
           }\r
+          index++;\r
         }\r
       }\r
+\r
+      renderOrder = new String[av.featuresDisplayed.size()];\r
+      Enumeration en = av.featuresDisplayed.keys();\r
+      int i = 0;\r
+      while(en.hasMoreElements())\r
+      {\r
+        renderOrder[i] = en.nextElement().toString();\r
+        i++;\r
+      }\r
     }\r
 \r
     public Color getColour(String featureType)\r
@@ -254,10 +345,13 @@ public class FeatureRenderer
 \r
     public void addNewFeature(String name, Color col)\r
     {\r
+\r
       setColour(name, col);\r
-      if(featuresDisplayed==null)\r
-        featuresDisplayed = new Vector();\r
-      featuresDisplayed.insertElementAt(name, 0);\r
+      if(av.featuresDisplayed==null)\r
+        av.featuresDisplayed = new Hashtable();\r
+\r
+\r
+      av.featuresDisplayed.put(name, "NOGROUP");\r
     }\r
 \r
     public void setColour(String featureType, Color col)\r
@@ -280,14 +374,22 @@ public class FeatureRenderer
       // The feature table will display high priority\r
       // features at the top, but theses are the ones\r
       // we need to render last, so invert the data\r
-      featuresDisplayed.clear();\r
+      av.featuresDisplayed.clear();\r
+\r
+      renderOrder = new String[data.length];\r
+\r
+      if(data.length>0)\r
       for(int i=data.length-1; i>-1; i--)\r
       {\r
        String type = data[i][0].toString();\r
        setColour(type, (Color)data[i][1]);\r
        if( ((Boolean)data[i][2]).booleanValue() )\r
-         featuresDisplayed.addElement(type);\r
+       {\r
+         av.featuresDisplayed.put(type, new Integer(getColour(type).getRGB()));\r
+       }\r
+       renderOrder[i] = type;\r
       }\r
+\r
     }\r
 \r
     Hashtable featureColours = new Hashtable();\r
index eb74454..3979ebe 100755 (executable)
@@ -35,6 +35,7 @@ public class FeatureSettings extends JPanel
   final FeatureRenderer fr;\r
   final AlignmentPanel ap;\r
   final AlignViewport av;\r
+  Hashtable allFeatures;\r
   Object [][] originalData;\r
   final JInternalFrame frame;\r
   JScrollPane scrollPane = new JScrollPane();\r
@@ -124,8 +125,12 @@ public class FeatureSettings extends JPanel
     bigPanel.add(transPanel, BorderLayout.SOUTH);\r
     bigPanel.add(scrollPane, BorderLayout.CENTER);\r
     if(groupPanel!=null)\r
+    {\r
+      groupPanel.setLayout(\r
+          new GridLayout(groupPanel.getComponentCount()/3, 4));\r
+      groupPanel.validate();\r
       bigPanel.add(groupPanel, BorderLayout.NORTH);\r
-\r
+    }\r
     add(bigPanel, BorderLayout.CENTER);\r
     add(buttonPanel, BorderLayout.SOUTH);\r
 \r
@@ -139,30 +144,28 @@ public class FeatureSettings extends JPanel
     else\r
       fr.featureGroups.clear();\r
 \r
-    Vector allFeatures = new Vector();\r
-    Vector features;\r
-    Enumeration e;\r
-    SequenceFeature sf;\r
+    allFeatures = new Hashtable();\r
+    SequenceFeature[] features;\r
 \r
   for (int i = 0; i < av.alignment.getHeight(); i++)\r
   {\r
     features = av.alignment.getSequenceAt(i).getDatasetSequence().\r
         getSequenceFeatures();\r
+\r
     if (features == null)\r
       continue;\r
 \r
-    e = features.elements();\r
-    while (e.hasMoreElements())\r
+    int index = 0;\r
+    while (index < features.length)\r
     {\r
-      sf = (SequenceFeature) e.nextElement();\r
-      if(sf.getFeatureGroup()!=null\r
-          && !fr.featureGroups.containsKey(sf.getFeatureGroup()))\r
+      if(features[index].getFeatureGroup()!=null\r
+          && !fr.featureGroups.containsKey(features[index].getFeatureGroup()))\r
        {\r
-         fr.featureGroups.put(sf.getFeatureGroup(), new Boolean(true));\r
+         fr.featureGroups.put(features[index].getFeatureGroup(), new Boolean(true));\r
          if(groupPanel==null)\r
             groupPanel = new JPanel();\r
 \r
-          final JCheckBox check = new JCheckBox(sf.getFeatureGroup(), true);\r
+          final JCheckBox check = new JCheckBox(features[index].getFeatureGroup(), true);\r
           check.setFont(new Font("Serif", Font.BOLD, 12));\r
           check.addItemListener(new ItemListener()\r
               {\r
@@ -176,15 +179,19 @@ public class FeatureSettings extends JPanel
                     if (ap.overviewPanel != null)\r
                       ap.overviewPanel.updateOverviewImage();\r
                   }\r
-\r
+                  resetTable();\r
                 }\r
               });\r
           groupPanel.add(check);\r
        }\r
-      if (!allFeatures.contains(sf.getType()))\r
+      if (!allFeatures.contains(features[index].getType()))\r
       {\r
-        allFeatures.addElement(sf.getType());\r
+        if(features[index].featureGroup!=null)\r
+          allFeatures.put(features[index].getType(), features[index].featureGroup);\r
+        else\r
+          allFeatures.put(features[index].getType(), "NOGROUP");\r
       }\r
+      index++;\r
     }\r
   }\r
     if(allFeatures.size()<1)\r
@@ -200,87 +207,111 @@ public class FeatureSettings extends JPanel
        return;\r
      }\r
 \r
+     resetTable();\r
+  }\r
+\r
+  void resetTable()\r
+  {\r
     int fSize = allFeatures.size();\r
 \r
     String type;\r
     boolean originalExists = false;\r
-    if(originalData!=null)\r
+    if (originalData != null)\r
       originalExists = true;\r
     else\r
       originalData = new Object[fSize][3];\r
 \r
-    Object [][] data = new Object[fSize][3];\r
-    for(int i=0; i<fSize; i++)\r
+    Object[][] tmp = new Object[fSize][3];\r
+    int tmpIndex = 0;\r
+\r
+    Enumeration en = allFeatures.keys();\r
+    int i=0;\r
+    while(en.hasMoreElements())\r
     {\r
-      type = allFeatures.elementAt(i).toString();\r
+      type = en.nextElement().toString();\r
       Color col = fr.getColour(type);\r
-      data[i][0]=type;\r
-      data[i][1]=col;\r
-      if(fr.featuresDisplayed!=null)\r
-         data[i][2] = new Boolean(fr.featuresDisplayed.contains(type));\r
-      else\r
-        data[i][2] = new Boolean(true);\r
-\r
-      if(!originalExists)\r
+\r
+\r
+      //This will ignore any features which are in groups not shown\r
+     if(fr.featureGroups==null\r
+           ||   ((Boolean)fr.featureGroups.get(allFeatures.get(type))).booleanValue())\r
+      {\r
+        tmp[tmpIndex][0] = type;\r
+        tmp[tmpIndex][1] = col;\r
+        if (av.featuresDisplayed != null)\r
+          tmp[tmpIndex][2] = new Boolean(av.featuresDisplayed.containsKey(type));\r
+        else\r
+          tmp[tmpIndex][2] = new Boolean(true);\r
+\r
+        tmpIndex++;\r
+      }\r
+\r
+\r
+      if (!originalExists)\r
       {\r
         originalData[i][0] = type;\r
         originalData[i][1] = col;\r
-        if (fr.featuresDisplayed != null)\r
-          originalData[i][2] = new Boolean(fr.featuresDisplayed.contains(type));\r
+        if (av.featuresDisplayed != null)\r
+          originalData[i][2] = new Boolean(av.featuresDisplayed.contains(type));\r
         else\r
           originalData[i][2] = new Boolean(true);\r
       }\r
+      i++;\r
     }\r
-    ////////////////////////////////////\r
-        //Now build the table\r
-        table = new JTable(new FeatureTableModel(data));\r
-        scrollPane.setViewportView(table);\r
-        table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));\r
-        table.setFont(new Font("Verdana", Font.PLAIN, 12));\r
-        table.setDefaultRenderer(Color.class,\r
-                             new ColorRenderer());\r
 \r
-        table.setDefaultEditor(Color.class,\r
-                          new ColorEditor());\r
+    Object [][]data = new Object[tmpIndex][3];\r
+    System.arraycopy(tmp, 0, data,0, tmpIndex);\r
 \r
-        table.getColumnModel().getColumn(0).setPreferredWidth(200);\r
+    table = new JTable(new FeatureTableModel(data));\r
+    scrollPane.setViewportView(table);\r
+    table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));\r
+    table.setFont(new Font("Verdana", Font.PLAIN, 12));\r
+    table.setDefaultRenderer(Color.class,\r
+                         new ColorRenderer());\r
 \r
-        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+    table.setDefaultEditor(Color.class,\r
+                      new ColorEditor());\r
 \r
-        table.addMouseListener(new MouseAdapter()\r
-            {\r
-              public void mousePressed(MouseEvent evt)\r
-              {\r
-                selectedRow = table.rowAtPoint(evt.getPoint());\r
-              }\r
-            });\r
+    table.getColumnModel().getColumn(0).setPreferredWidth(200);\r
+\r
+    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
 \r
-        table.addMouseMotionListener(new MouseMotionAdapter()\r
+    table.addMouseListener(new MouseAdapter()\r
+        {\r
+          public void mousePressed(MouseEvent evt)\r
+          {\r
+            selectedRow = table.rowAtPoint(evt.getPoint());\r
+          }\r
+        });\r
+\r
+    table.addMouseMotionListener(new MouseMotionAdapter()\r
+        {\r
+          public void mouseDragged(MouseEvent evt)\r
+          {\r
+            int newRow = table.rowAtPoint(evt.getPoint());\r
+            if(newRow!=selectedRow\r
+               && selectedRow!=-1\r
+               && newRow!=-1)\r
             {\r
-              public void mouseDragged(MouseEvent evt)\r
-              {\r
-                int newRow = table.rowAtPoint(evt.getPoint());\r
-                if(newRow!=selectedRow\r
-                   && selectedRow!=-1\r
-                   && newRow!=-1)\r
-                {\r
-                  Object[] temp = new Object[3];\r
-                  temp[0] = table.getValueAt(selectedRow, 0);\r
-                  temp[1] = table.getValueAt(selectedRow, 1);\r
-                  temp[2] = table.getValueAt(selectedRow, 2);\r
+              Object[] temp = new Object[3];\r
+              temp[0] = table.getValueAt(selectedRow, 0);\r
+              temp[1] = table.getValueAt(selectedRow, 1);\r
+              temp[2] = table.getValueAt(selectedRow, 2);\r
 \r
-                  table.setValueAt(table.getValueAt(newRow, 0), selectedRow, 0);\r
-                  table.setValueAt(table.getValueAt(newRow, 1), selectedRow, 1);\r
-                  table.setValueAt(table.getValueAt(newRow, 2), selectedRow, 2);\r
+              table.setValueAt(table.getValueAt(newRow, 0), selectedRow, 0);\r
+              table.setValueAt(table.getValueAt(newRow, 1), selectedRow, 1);\r
+              table.setValueAt(table.getValueAt(newRow, 2), selectedRow, 2);\r
 \r
-                  table.setValueAt(temp[0], newRow, 0);\r
-                  table.setValueAt(temp[1], newRow, 1);\r
-                  table.setValueAt(temp[2], newRow, 2);\r
+              table.setValueAt(temp[0], newRow, 0);\r
+              table.setValueAt(temp[1], newRow, 1);\r
+              table.setValueAt(temp[2], newRow, 2);\r
 \r
-                  selectedRow = newRow;\r
-                }\r
-              }\r
-        });\r
+              selectedRow = newRow;\r
+            }\r
+          }\r
+    });\r
+\r
+    updateFeatureRenderer(data);\r
 \r
   }\r
 \r
index c690490..a1e8ea0 100755 (executable)
@@ -65,7 +65,9 @@ public class OverviewPanel extends JPanel implements Runnable
 \r
         sr = new SequenceRenderer(av);\r
         sr.renderGaps( false );\r
+        sr.forOverview = true;\r
         fr = new FeatureRenderer(av);\r
+        fr.overview = true;\r
 \r
 \r
         // scale the initial size of overviewpanel to shape of alignment\r
@@ -245,11 +247,10 @@ public class OverviewPanel extends JPanel implements Runnable
 \r
        if (av.showSequenceFeatures)\r
        {\r
-         fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().\r
-             featuresDisplayed;\r
          fr.featureGroups = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups;\r
          fr.featureColours = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours;\r
          fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency;\r
+         fr.sequenceFeatures = ap.seqPanel.seqCanvas.getFeatureRenderer().sequenceFeatures;\r
        }\r
 \r
         int alwidth = av.alignment.getWidth();\r
@@ -275,14 +276,15 @@ public class OverviewPanel extends JPanel implements Runnable
         float sampleRow = (float) alheight / (float) sequencesHeight;\r
 \r
         int lastcol=-1, lastrow=-1;\r
-        Color color = Color.white;\r
-        for (int col = 0; col < width; col++)\r
+        int color = Color.white.getRGB();\r
+        int row, col;\r
+        for (row = 0; row < sequencesHeight; row++)\r
         {\r
-          for (int row = 0; row < sequencesHeight; row++)\r
-          {\r
+            for (col = 0; col < width; col++)\r
+            {\r
             if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow)\r
             {\r
-              miniMe.setRGB(col,row,color.getRGB());\r
+              miniMe.setRGB(col,row,color);\r
               continue;\r
             }\r
 \r
@@ -292,17 +294,24 @@ public class OverviewPanel extends JPanel implements Runnable
             if(av.alignment.getSequenceAt(lastrow).getLength()>lastcol)\r
             {\r
              color = sr.getResidueBoxColour(\r
-                av.alignment.getSequenceAt(lastrow), lastcol);\r
+                av.alignment.getSequenceAt(lastrow), lastcol).getRGB();\r
 \r
              if(av.showSequenceFeatures)\r
-                 color = fr.findFeatureColour(color,  av.alignment.getSequenceAt(lastrow),\r
-                                             lastcol);\r
+                 color = fr.findFeatureColour(color,  lastrow, lastcol);\r
 \r
             }\r
 \r
-            miniMe.setRGB(col,row,color.getRGB());\r
+            miniMe.setRGB(col,row,color);\r
+\r
 \r
-            if (av.conservation != null)\r
+          }\r
+        }\r
+\r
+        if (av.conservation != null)\r
+        {\r
+          for (col = 0; col < width; col++)\r
+          {\r
+            lastcol = (int) (col * sampleCol);\r
             {\r
               mg.translate(col, sequencesHeight);\r
               ap.annotationPanel.drawGraph(mg, av.conservation,\r
@@ -310,11 +319,10 @@ public class OverviewPanel extends JPanel implements Runnable
                                            graphHeight,\r
                                            (int) (col * sampleCol),\r
                                            (int) (col * sampleCol) + 1);\r
-              mg.translate(-col, -sequencesHeight);\r
+              mg.translate( -col, -sequencesHeight);\r
             }\r
           }\r
         }\r
-\r
         System.gc();\r
 \r
         resizing = false;\r