X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FFeatureColourChooser.java;h=064d58b9f0f1c39a24076d80e9947840ab20ec8b;hb=ce26ffcae5e876cf4127173c92f0eddffc9830da;hp=4f5e7eade1d775d76ccd147dd78ebfcd01256756;hpb=cf255ab50c5295713871e8d75f7504d730971013;p=jalview.git diff --git a/src/jalview/gui/FeatureColourChooser.java b/src/jalview/gui/FeatureColourChooser.java index 4f5e7ea..064d58b 100644 --- a/src/jalview/gui/FeatureColourChooser.java +++ b/src/jalview/gui/FeatureColourChooser.java @@ -76,9 +76,11 @@ public class FeatureColourChooser extends JalviewDialog boolean adjusting = false; - private float min; + final private float min; - private float max; + final private float max; + + final private float scaleFactor; String type = null; @@ -107,7 +109,7 @@ public class FeatureColourChooser extends JalviewDialog { if (!adjusting) { - thresholdValue.setText((slider.getValue() / 1000f) + ""); + thresholdValue.setText((slider.getValue() / scaleFactor) + ""); valueChanged(); } } @@ -128,6 +130,14 @@ public class FeatureColourChooser extends JalviewDialog float mm[] = ((float[][]) fr.getMinMax().get(type))[0]; min = mm[0]; max = mm[1]; + + /* + * ensure scale factor allows a scaled range with + * 10 integer divisions ('ticks'); if we have got here, + * we should expect that max != min + */ + scaleFactor = (max == min) ? 1f : 100f / (max - min); + oldcs = fr.getFeatureColours().get(type); if (oldcs instanceof GraduatedColor) { @@ -185,17 +195,6 @@ public class FeatureColourChooser extends JalviewDialog waitForInput(); } - public FeatureColourChooser() - { - try - { - jbInit(); - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - private void jbInit() throws Exception { @@ -441,11 +440,11 @@ public class FeatureColourChooser extends JalviewDialog adjusting = true; acg.setThresh(threshline.value); - float range = max * 1000f - min * 1000f; + float range = (max - min) * scaleFactor; - slider.setMinimum((int) (min * 1000)); - slider.setMaximum((int) (max * 1000)); - slider.setValue((int) (threshline.value * 1000)); + slider.setMinimum((int) (min * scaleFactor)); + slider.setMaximum((int) (max * scaleFactor)); + slider.setValue((int) (threshline.value * scaleFactor)); thresholdValue.setText(threshline.value + ""); slider.setMajorTickSpacing((int) (range / 10f)); slider.setEnabled(true); @@ -545,7 +544,7 @@ public class FeatureColourChooser extends JalviewDialog try { float f = Float.parseFloat(thresholdValue.getText()); - slider.setValue((int) (f * 1000)); + slider.setValue((int) (f * scaleFactor)); threshline.value = f; } catch (NumberFormatException ex) { @@ -554,7 +553,7 @@ public class FeatureColourChooser extends JalviewDialog public void valueChanged() { - threshline.value = slider.getValue() / 1000f; + threshline.value = slider.getValue() / scaleFactor; cs.setThresh(threshline.value); changeColour(); ap.paintAlignment(false);