From: gmungoc Date: Tue, 11 Aug 2020 09:35:32 +0000 (+0100) Subject: JAL-3371 more fine-grained slider; set Param slider to initial default X-Git-Tag: Release_2_11_2_0~30^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e09a3103605a8b6ca54b824b7bb6a75c5f35957a;p=jalview.git JAL-3371 more fine-grained slider; set Param slider to initial default --- diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index ba575ae..53b0305 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -93,7 +93,7 @@ public class OptsAndParamsPage JLabel optlabel = new JLabel(); - JComboBox val = new JComboBox(); + JComboBox val = new JComboBox<>(); public OptionBox(OptionI opt) { @@ -127,7 +127,7 @@ public class OptsAndParamsPage } } add(enabled, BorderLayout.NORTH); - for (Object str : opt.getPossibleValues()) + for (String str : opt.getPossibleValues()) { val.addItem(str); } @@ -589,7 +589,7 @@ public class OptsAndParamsPage { if (choice) { - choicebox = new JComboBox(); + choicebox = new JComboBox<>(); choicebox.addActionListener(this); controlPanel.add(choicebox, BorderLayout.CENTER); } @@ -632,7 +632,9 @@ public class OptsAndParamsPage }); valueField.setPreferredSize(new Dimension(60, 25)); + valueField.setText(parm.getValue()); slider = makeSlider(parm.getValidValue()); + updateSliderFromValueField(); slider.addChangeListener(this); controlPanel.add(slider, BorderLayout.WEST); diff --git a/src/jalview/gui/Slider.java b/src/jalview/gui/Slider.java index 7f18461..714e770 100644 --- a/src/jalview/gui/Slider.java +++ b/src/jalview/gui/Slider.java @@ -16,6 +16,12 @@ import javax.swing.JSlider; public class Slider extends JSlider { /* + * the number of nominal positions the slider represents + * (higher number = more fine-grained positioning) + */ + private static final int SCALE_TICKS = 1000; + + /* * 'true' value corresponding to zero on the slider */ private float trueMin; @@ -57,7 +63,7 @@ public class Slider extends JSlider trueMin = min; trueMax = max; setMinimum(0); - sliderScaleFactor = 100f / (max - min); + sliderScaleFactor = SCALE_TICKS / (max - min); int sliderMax = (int) ((max - min) * sliderScaleFactor); setMaximum(sliderMax); setSliderValue(value);