Can be used for annotation colouring
authoramwaterhouse <Andrew Waterhouse>
Mon, 30 Jan 2006 14:58:09 +0000 (14:58 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 30 Jan 2006 14:58:09 +0000 (14:58 +0000)
src/jalview/gui/SliderPanel.java

index 5b177d4..6f8a0b2 100755 (executable)
@@ -44,6 +44,7 @@ public class SliderPanel extends GSliderPanel
     static JInternalFrame PIDSlider;\r
     AlignmentPanel ap;\r
     boolean forConservation = true;\r
+    boolean forAnnotation = false;\r
     ColourSchemeI cs;\r
 \r
     /**\r
@@ -89,6 +90,44 @@ public class SliderPanel extends GSliderPanel
         valueField.setText(value + "");\r
     }\r
 \r
+    public SliderPanel(final AlignmentAnnotation annotation, final AlignmentPanel ap)\r
+    {\r
+      forAnnotation = true;\r
+      undoButton.setVisible(false);\r
+      applyButton.setVisible(false);\r
+      allGroupsCheck.setVisible(false);\r
+      label.setText("Adjust value - "+annotation.getGraphLine(0).label);\r
+\r
+      float range = annotation.graphMax * 1000 - annotation.graphMin * 1000;\r
+\r
+      slider.setMinimum( (int) (annotation.graphMin * 1000));\r
+      slider.setMaximum( (int) (annotation.graphMax * 1000));\r
+      slider.setValue( (int) (annotation.getGraphLine(0).value * 1000));\r
+      valueField.setText( annotation.getGraphLine(0).value + "");\r
+      slider.setMajorTickSpacing( (int) (range / 10f));\r
+      slider.setMinorTickSpacing( (int) (range / 100f));\r
+      slider.setPaintTicks(true);\r
+\r
+      JInternalFrame slideFrame = new JInternalFrame();\r
+      slideFrame.setLayer(JLayeredPane.PALETTE_LAYER);\r
+      Desktop.addInternalFrame(slideFrame,\r
+                               "Adjust " + annotation.label +" value",\r
+                               250, 90);\r
+\r
+      slideFrame.setContentPane(this);\r
+      slider.addChangeListener(new ChangeListener()\r
+      {\r
+        public void stateChanged(ChangeEvent evt)\r
+        {\r
+          valueField.setText( ((float)slider.getValue()/1000f) + "");\r
+          annotation.getGraphLine(0).value = (float)slider.getValue()/1000f;\r
+          ap.repaint();\r
+        }\r
+      });\r
+\r
+    }\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -315,8 +354,16 @@ public class SliderPanel extends GSliderPanel
     {\r
         try\r
         {\r
+          if (forAnnotation)\r
+          {\r
+            float f = Float.parseFloat(valueField.getText());\r
+            slider.setValue( (int)( f * 1000 ));\r
+          }\r
+          else\r
+          {\r
             int i = Integer.parseInt(valueField.getText());\r
             slider.setValue(i);\r
+          }\r
         }\r
         catch (Exception ex)\r
         {\r