JAL-2504 update the right feature colour when creating a new feature bug/JAL-2510amendFeatures
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 22 May 2017 14:37:32 +0000 (15:37 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 22 May 2017 14:37:32 +0000 (15:37 +0100)
src/jalview/appletgui/FeatureRenderer.java
src/jalview/gui/FeatureRenderer.java

index a6d0d99..38ecf76 100644 (file)
@@ -394,9 +394,10 @@ public class FeatureRenderer extends
     /*
      * only update default type and group if we used defaults
      */
+    String enteredType = name.getText().trim();
     if (dialog.accept && useLastDefaults)
     {
-      lastFeatureAdded = name.getText().trim();
+      lastFeatureAdded = enteredType;
       lastFeatureGroupAdded = group.getText().trim();
     }
 
@@ -405,7 +406,7 @@ public class FeatureRenderer extends
       SequenceFeature sf = features[featureIndex];
       if (dialog.accept)
       {
-        sf.type = name.getText().trim();
+        sf.type = enteredType;
         sf.featureGroup = group.getText().trim();
         if (sf.featureGroup != null && sf.featureGroup.length() < 1)
         {
@@ -450,7 +451,7 @@ public class FeatureRenderer extends
       {
         for (int i = 0; i < sequences.length; i++)
         {
-          features[i].type = name.getText().trim();
+          features[i].type = enteredType;
           features[i].featureGroup = group.getText().trim();
           features[i].description = description.getText()
                   .replace('\n', ' ');
@@ -461,7 +462,7 @@ public class FeatureRenderer extends
         Color newColour = colourPanel.getBackground();
         // setColour(lastFeatureAdded, fcol);
 
-        setColour(lastFeatureAdded, new FeatureColour(newColour)); // was fcol
+        setColour(enteredType, new FeatureColour(newColour)); // was fcol
         featuresAdded();
       }
       else
index 2f12eef..55c4323 100644 (file)
@@ -199,7 +199,7 @@ public class FeatureRenderer extends
           if (col != null)
           {
             fcol = new FeatureColour(col);
-            updateColourButton(mainPanel, colour, new FeatureColour(col));
+            updateColourButton(mainPanel, colour, fcol);
           }
         }
         else
@@ -357,7 +357,7 @@ public class FeatureRenderer extends
     end.setValue(new Integer(firstFeature.getEnd()));
     description.setText(firstFeature.getDescription());
     updateColourButton(mainPanel, colour,
-            (oldcol = fcol = getFeatureStyle(name.getText())));
+            (oldcol = fcol = getFeatureStyle(featureType)));
     Object[] options;
     if (!create)
     {
@@ -386,14 +386,15 @@ public class FeatureRenderer extends
 
     FeaturesFile ffile = new FeaturesFile();
 
-    if (reply == JvOptionPane.OK_OPTION && name.getText().length() > 0)
+    String enteredType = name.getText().trim();
+    if (reply == JvOptionPane.OK_OPTION && enteredType.length() > 0)
     {
       /*
        * update default values only if creating using default values
        */
       if (useLastDefaults)
       {
-        lastFeatureAdded = name.getText().trim();
+        lastFeatureAdded = enteredType;
         lastFeatureGroupAdded = group.getText().trim();
         // TODO: determine if the null feature group is valid
         if (lastFeatureGroupAdded.length() < 1)
@@ -422,7 +423,7 @@ public class FeatureRenderer extends
          * YES_OPTION corresponds to the Amend button
          * need to refresh Feature Settings if type, group or colour changed
          */
-        sf.type = name.getText().trim();
+        sf.type = enteredType;
         sf.featureGroup = group.getText().trim();
         sf.description = description.getText().replaceAll("\n", " ");
         boolean refreshSettings = (!featureType.equals(sf.type) || !featureGroup
@@ -449,12 +450,12 @@ public class FeatureRenderer extends
     else
     // NEW FEATURES ADDED
     {
-      if (reply == JvOptionPane.OK_OPTION && lastFeatureAdded.length() > 0)
+      if (reply == JvOptionPane.OK_OPTION && enteredType.length() > 0)
       {
         for (int i = 0; i < sequences.size(); i++)
         {
           SequenceFeature sf = features.get(i);
-          sf.type = name.getText().trim();
+          sf.type = enteredType;
           // fix for JAL-1538 - always set feature group here
           sf.featureGroup = group.getText().trim();
           sf.description = description.getText().replaceAll("\n", " ");
@@ -462,7 +463,7 @@ public class FeatureRenderer extends
           ffile.parseDescriptionHTML(sf, false);
         }
 
-        setColour(lastFeatureAdded, fcol);
+        setColour(enteredType, fcol);
 
         featuresAdded();