JAL-2629 add StringParameter
[jalview.git] / src / jalview / gui / FeatureRenderer.java
index 2f12eef..358798d 100644 (file)
@@ -63,8 +63,8 @@ import javax.swing.event.DocumentListener;
  * @author $author$
  * @version $Revision$
  */
-public class FeatureRenderer extends
-        jalview.renderer.seqfeatures.FeatureRenderer
+public class FeatureRenderer
+        extends jalview.renderer.seqfeatures.FeatureRenderer
 {
   /*
    * defaults for creating a new feature are the last created
@@ -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
@@ -239,14 +239,13 @@ public class FeatureRenderer extends
        */
       gridPanel = new JPanel(new GridLayout(4, 1));
       JPanel choosePanel = new JPanel();
-      choosePanel.add(new JLabel(MessageManager
-              .getString("label.select_feature")
-              + ":"));
+      choosePanel.add(new JLabel(
+              MessageManager.getString("label.select_feature") + ":"));
       final JComboBox<String> overlaps = new JComboBox<String>();
       for (SequenceFeature sf : features)
       {
-        String text = sf.getType() + "/" + sf.getBegin() + "-"
-                + sf.getEnd() + " (" + sf.getFeatureGroup() + ")";
+        String text = sf.getType() + "/" + sf.getBegin() + "-" + sf.getEnd()
+                + " (" + sf.getFeatureGroup() + ")";
         overlaps.addItem(text);
       }
       choosePanel.add(overlaps);
@@ -271,14 +270,15 @@ public class FeatureRenderer extends
             highlight.addResult(sequences.get(0), sf.getBegin(),
                     sf.getEnd());
 
-            alignPanel.getSeqPanel().seqCanvas.highlightSearchResults(highlight);
+            alignPanel.getSeqPanel().seqCanvas
+                    .highlightSearchResults(highlight);
 
           }
           FeatureColourI col = getFeatureStyle(name.getText());
           if (col == null)
           {
-            col = new FeatureColour(ColorUtils
-                    .createColourFromName(name.getText()));
+            col = new FeatureColour(
+                    ColorUtils.createColourFromName(name.getText()));
           }
           oldcol = fcol = col;
           updateColourButton(mainPanel, colour, col);
@@ -315,9 +315,8 @@ public class FeatureRenderer extends
     mainPanel.add(gridPanel, BorderLayout.NORTH);
 
     JPanel descriptionPanel = new JPanel();
-    descriptionPanel.add(new JLabel(MessageManager
-            .getString("label.description:"),
-            JLabel.RIGHT));
+    descriptionPanel.add(new JLabel(
+            MessageManager.getString("label.description:"), JLabel.RIGHT));
     description.setFont(JvSwingUtils.getTextAreaFont());
     description.setLineWrap(true);
     descriptionPanel.add(new JScrollPane(description));
@@ -357,7 +356,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)
     {
@@ -371,10 +370,11 @@ public class FeatureRenderer extends
           MessageManager.getString("action.cancel") };
     }
 
-    String title = create ? MessageManager
-            .getString("label.create_new_sequence_features")
+    String title = create
+            ? MessageManager.getString("label.create_new_sequence_features")
             : MessageManager.formatMessage("label.amend_delete_features",
-                    new String[] { sequences.get(0).getName() });
+                    new String[]
+                    { sequences.get(0).getName() });
 
     /*
      * show the dialog
@@ -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,11 +423,11 @@ 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
-                .equals(sf.featureGroup));
+        boolean refreshSettings = (!featureType.equals(sf.type)
+                || !featureGroup.equals(sf.featureGroup));
         refreshSettings |= (fcol != oldcol);
 
         setColour(sf.type, fcol);
@@ -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();
 
@@ -513,7 +514,8 @@ public class FeatureRenderer extends
     {
       String msg = MessageManager.formatMessage("label.warning_hidden",
               MessageManager.getString("label.group"), group);
-      JvOptionPane.showMessageDialog(panel, msg, "", JvOptionPane.OK_OPTION);
+      JvOptionPane.showMessageDialog(panel, msg, "",
+              JvOptionPane.OK_OPTION);
     }
   }