patch for JAL-545 - make deep copy of feature settings
authorjprocter <Jim Procter>
Wed, 9 Jun 2010 14:06:02 +0000 (14:06 +0000)
committerjprocter <Jim Procter>
Wed, 9 Jun 2010 14:06:02 +0000 (14:06 +0000)
src/jalview/gui/FeatureRenderer.java

index 09dccfe..be83909 100755 (executable)
@@ -105,13 +105,31 @@ public class FeatureRenderer
       this.featureOrder = featureOrder;
     }
 
+    /**
+     * create an independent instance of the feature renderer settings
+     * 
+     * @param fr
+     */
     public FeatureRendererSettings(FeatureRenderer fr)
     {
-      this.renderOrder = fr.renderOrder;
-      this.featureGroups = fr.featureGroups;
-      this.featureColours = fr.featureColours;
+      this.renderOrder = new String[fr.renderOrder.length];
+      System.arraycopy(fr.renderOrder, 0, renderOrder, 0,
+              renderOrder.length);
+      this.featureGroups = new Hashtable(fr.featureGroups);
+      this.featureColours = new Hashtable(fr.featureColours);
+      Enumeration en = fr.featureColours.keys();
+      while (en.hasMoreElements())
+      {
+        Object next = en.nextElement();
+        Object val = featureColours.get(next);
+        if (val instanceof GraduatedColor)
+        {
+          featureColours
+                  .put(next, new GraduatedColor((GraduatedColor) val));
+        }
+      }
       this.transparency = fr.transparency;
-      this.featureOrder = fr.featureOrder;
+      this.featureOrder = new Hashtable(fr.featureOrder);
     }
   }