From: amwaterhouse Date: Wed, 15 Dec 2004 17:22:04 +0000 (+0000) Subject: New class X-Git-Tag: Release_2_0~808 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7a127d183b3078bf2d73be4db516d97b1986e3ce;p=jalview.git New class --- diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java new file mode 100755 index 0000000..f177867 --- /dev/null +++ b/src/jalview/gui/SliderPanel.java @@ -0,0 +1,87 @@ +package jalview.gui; + +import jalview.jbgui.*; +import jalview.datamodel.*; +import jalview.schemes.*; +import java.awt.event.*; +import javax.swing.event.*; + +public class SliderPanel extends GSliderPanel +{ + AlignmentPanel ap; + boolean forConservation = true; + ColourSchemeI cs; + + public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, ColourSchemeI cs) + { + this.ap = ap; + this.cs = cs; + forConservation = forConserve; + if(forConservation) + { + label.setText("Enter the value by which to decrease conservation colour intensity"); + slider.setMinimum(0); + slider.setMaximum(50); + } + else + { + label.setText("Enter the percent identity above which to colour residues"); + slider.setMinimum(0); + slider.setMaximum(100); + } + + + + slider.addChangeListener( new ChangeListener() + { + public void stateChanged(ChangeEvent evt) + { + valueField.setText( slider.getValue()+"" ); + valueChanged( slider.getValue() ); + } + }); + + slider.setValue(value); + valueField.setText(value+""); + } + + public void valueChanged(int i) + { + + if(forConservation) + { + if (cs instanceof ConservationColourScheme) + ( (ConservationColourScheme) cs).inc = i; + } + else + { + if( cs instanceof ResidueColourScheme) + { + ResidueColourScheme rcs = (ResidueColourScheme) cs; + rcs.setThreshold(i); + } + else if( cs instanceof ScoreColourScheme) + { + ScoreColourScheme scs = (ScoreColourScheme) cs; + scs.setThreshold(i); + } + + } + + ap.seqPanel.seqCanvas.paintFlag=true; + ap.seqPanel.repaint(); + + } + + public void valueField_actionPerformed(ActionEvent e) + { + try{ + int i = Integer.parseInt(valueField.getText()); + slider.setValue(i); + } + catch(Exception ex) + { + valueField.setText( slider.getValue()+"" ); + } + } +}