JAL-4024 only render partially when new view overlaps with last rendered annotation...
[jalview.git] / src / jalview / gui / OptsAndParamsPage.java
index acd8445..e0427cc 100644 (file)
  */
 package jalview.gui;
 
-import jalview.util.MessageManager;
-import jalview.ws.params.ArgumentI;
-import jalview.ws.params.OptionI;
-import jalview.ws.params.ParameterI;
-import jalview.ws.params.ValueConstrainI;
-import jalview.ws.params.ValueConstrainI.ValueType;
-
 import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Dimension;
@@ -35,6 +28,8 @@ import java.awt.GridLayout;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseEvent;
@@ -59,6 +54,12 @@ import javax.swing.border.TitledBorder;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
+import jalview.util.MessageManager;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.OptionI;
+import jalview.ws.params.ParameterI;
+import jalview.ws.params.ValueConstrainI;
+import jalview.ws.params.ValueConstrainI.ValueType;
 import net.miginfocom.swing.MigLayout;
 
 /**
@@ -92,7 +93,7 @@ public class OptsAndParamsPage
 
     JLabel optlabel = new JLabel();
 
-    JComboBox val = new JComboBox();
+    JComboBox<String> val = new JComboBox<>();
 
     public OptionBox(OptionI opt)
     {
@@ -126,7 +127,7 @@ public class OptsAndParamsPage
         }
       }
       add(enabled, BorderLayout.NORTH);
-      for (Object str : opt.getPossibleValues())
+      for (String str : opt.getPossibleValues())
       {
         val.addItem(str);
       }
@@ -288,7 +289,7 @@ public class OptsAndParamsPage
 
     boolean integ = false;
 
-    Object lastVal;
+    String lastVal;
 
     ParameterI parameter;
 
@@ -300,11 +301,6 @@ public class OptsAndParamsPage
 
     Slider slider = null;
 
-    /*
-     * true minimum corresponding to 0 (minimum) of the slider
-     */
-    int sliderZeroValue;
-
     JTextArea string = new JTextArea();
 
     ValueConstrainI validator = null;
@@ -484,9 +480,10 @@ public class OptsAndParamsPage
      * 
      * @return
      */
-    private Object getCurrentValue()
+    private String getCurrentValue()
     {
-      return choice ? choicebox.getSelectedItem() : valueField.getText();
+      return choice ? (String) choicebox.getSelectedItem()
+              : valueField.getText();
     }
 
     @Override
@@ -577,9 +574,8 @@ public class OptsAndParamsPage
       if (!adjusting)
       {
         float value = slider.getSliderValue();
-        valueField.setText(
-                integ ? Integer.toString((int) value)
-                        : Float.toString(value));
+        valueField.setText(integ ? Integer.toString((int) value)
+                : Float.toString(value));
         checkIfModified();
       }
     }
@@ -592,7 +588,7 @@ public class OptsAndParamsPage
       {
         if (choice)
         {
-          choicebox = new JComboBox();
+          choicebox = new JComboBox<>();
           choicebox.addActionListener(this);
           controlPanel.add(choicebox, BorderLayout.CENTER);
         }
@@ -625,8 +621,20 @@ public class OptsAndParamsPage
             {
             }
           });
+          valueField.addFocusListener(new FocusAdapter()
+          {
+
+            @Override
+            public void focusLost(FocusEvent e)
+            {
+              actionPerformed(null);
+            }
+
+          });
           valueField.setPreferredSize(new Dimension(60, 25));
+          valueField.setText(parm.getValue());
           slider = makeSlider(parm.getValidValue());
+          updateSliderFromValueField();
           slider.addChangeListener(this);
 
           controlPanel.add(slider, BorderLayout.WEST);
@@ -693,8 +701,7 @@ public class OptsAndParamsPage
           {
             valueField.setText(valueField.getText().trim());
             iVal = Integer.valueOf(valueField.getText());
-            if (minValue != null
-                    && minValue.intValue() > iVal)
+            if (minValue != null && minValue.intValue() > iVal)
             {
               iVal = minValue.intValue();
               // TODO: provide visual indication that hard limit was reached for
@@ -725,8 +732,7 @@ public class OptsAndParamsPage
           {
             valueField.setText(valueField.getText().trim());
             fVal = Float.valueOf(valueField.getText());
-            if (minValue != null
-                    && minValue.floatValue() > fVal)
+            if (minValue != null && minValue.floatValue() > fVal)
             {
               fVal = minValue.floatValue();
               // TODO: provide visual indication that hard limit was reached for
@@ -734,8 +740,7 @@ public class OptsAndParamsPage
               // update value field to reflect any bound checking we performed.
               valueField.setText("" + fVal);
             }
-            if (maxValue != null
-                    && maxValue.floatValue() < fVal)
+            if (maxValue != null && maxValue.floatValue() < fVal)
             {
               fVal = maxValue.floatValue();
               // TODO: provide visual indication that hard limit was reached for