New class
authoramwaterhouse <Andrew Waterhouse>
Wed, 15 Dec 2004 17:22:04 +0000 (17:22 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 15 Dec 2004 17:22:04 +0000 (17:22 +0000)
src/jalview/gui/SliderPanel.java [new file with mode: 0755]

diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java
new file mode 100755 (executable)
index 0000000..f177867
--- /dev/null
@@ -0,0 +1,87 @@
+package jalview.gui;\r
+\r
+import jalview.jbgui.*;\r
+import jalview.datamodel.*;\r
+import jalview.schemes.*;\r
+import java.awt.event.*;\r
+import javax.swing.event.*;\r
+\r
+public class SliderPanel extends GSliderPanel\r
+{\r
+  AlignmentPanel ap;\r
+  boolean forConservation = true;\r
+  ColourSchemeI cs;\r
+\r
+  public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, ColourSchemeI cs)\r
+  {\r
+    this.ap = ap;\r
+    this.cs = cs;\r
+    forConservation = forConserve;\r
+    if(forConservation)\r
+    {\r
+      label.setText("Enter the value by which to decrease conservation colour intensity");\r
+      slider.setMinimum(0);\r
+      slider.setMaximum(50);\r
+    }\r
+    else\r
+    {\r
+      label.setText("Enter the percent identity above which to colour residues");\r
+      slider.setMinimum(0);\r
+      slider.setMaximum(100);\r
+    }\r
+\r
+\r
+\r
+    slider.addChangeListener( new ChangeListener()\r
+    {\r
+      public void stateChanged(ChangeEvent evt)\r
+      {\r
+        valueField.setText( slider.getValue()+"" );\r
+        valueChanged( slider.getValue() );\r
+      }\r
+    });\r
+\r
+    slider.setValue(value);\r
+    valueField.setText(value+"");\r
+  }\r
+\r
+  public void valueChanged(int i)\r
+  {\r
+\r
+    if(forConservation)\r
+    {\r
+      if (cs instanceof ConservationColourScheme)\r
+        ( (ConservationColourScheme) cs).inc = i;\r
+    }\r
+    else\r
+     {\r
+       if( cs instanceof ResidueColourScheme)\r
+       {\r
+         ResidueColourScheme rcs = (ResidueColourScheme) cs;\r
+         rcs.setThreshold(i);\r
+       }\r
+       else if( cs instanceof ScoreColourScheme)\r
+       {\r
+         ScoreColourScheme scs = (ScoreColourScheme) cs;\r
+         scs.setThreshold(i);\r
+       }\r
+\r
+     }\r
+\r
+    ap.seqPanel.seqCanvas.paintFlag=true;\r
+    ap.seqPanel.repaint();\r
+\r
+  }\r
+\r
+  public void valueField_actionPerformed(ActionEvent e)\r
+  {\r
+    try{\r
+      int i = Integer.parseInt(valueField.getText());\r
+      slider.setValue(i);\r
+    }\r
+    catch(Exception ex)\r
+    {\r
+      valueField.setText( slider.getValue()+"" );\r
+    }\r
+  }\r
+}\r