X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSliderPanel.java;h=caabbf98046dc6463e685327ee30c77a934a6b3d;hb=588042b69abf8e60bcc950b24c283933c7dd422f;hp=6c89fb7846ebde116ea1b0ce9c4b782f94386954;hpb=5cd8e373c75fb348ecda4d94d8a46468fb92756d;p=jalview.git diff --git a/src/jalview/appletgui/SliderPanel.java b/src/jalview/appletgui/SliderPanel.java index 6c89fb7..caabbf9 100755 --- a/src/jalview/appletgui/SliderPanel.java +++ b/src/jalview/appletgui/SliderPanel.java @@ -1,32 +1,35 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.appletgui; -import jalview.jbappletgui.*; -import jalview.schemes.*; -import jalview.datamodel.*; +import java.util.*; + import java.awt.*; import java.awt.event.*; -import java.util.*; -public class SliderPanel extends GSliderPanel +import jalview.datamodel.*; +import jalview.jbappletgui.*; +import jalview.schemes.*; + +public class SliderPanel + extends GSliderPanel { AlignmentPanel ap; boolean forConservation = true; @@ -35,12 +38,13 @@ public class SliderPanel extends GSliderPanel static Frame conservationSlider; static Frame PIDSlider; - public static int setConservationSlider(AlignmentPanel ap, ColourSchemeI cs, String source) + public static int setConservationSlider(AlignmentPanel ap, ColourSchemeI cs, + String source) { SliderPanel sp = null; - ConservationColourScheme ccs = (ConservationColourScheme)cs; + ConservationColourScheme ccs = (ConservationColourScheme) cs; - if(conservationSlider == null) + if (conservationSlider == null) { sp = new SliderPanel(ap, ccs.inc, true, cs); conservationSlider = new Frame(); @@ -48,30 +52,38 @@ public class SliderPanel extends GSliderPanel } else { - sp = (SliderPanel)conservationSlider.getComponent(0); - sp.cs = cs; + sp = (SliderPanel) conservationSlider.getComponent(0); + sp.cs = cs; } - conservationSlider.setTitle("Conservation Colour Increment ("+source+")"); - if(ap.av.alignment.getGroups()!=null) - sp.setAllGroupsCheckEnabled( true ); + conservationSlider.setTitle("Conservation Colour Increment (" + source + + ")"); + if (ap.av.alignment.getGroups() != null) + { + sp.setAllGroupsCheckEnabled(true); + } else - sp.setAllGroupsCheckEnabled( false); + { + sp.setAllGroupsCheckEnabled(false); + } return sp.getValue(); } public static void showConservationSlider() { - try{ + try + { PIDSlider.setVisible(false); PIDSlider = null; - }catch(Exception ex){} - + } + catch (Exception ex) + {} - if(!conservationSlider.isVisible()) + if (!conservationSlider.isVisible()) { - jalview.bin.JalviewLite.addFrame(conservationSlider, conservationSlider.getTitle(), 420, 100); + jalview.bin.JalviewLite.addFrame(conservationSlider, + conservationSlider.getTitle(), 420, 100); conservationSlider.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) @@ -84,41 +96,50 @@ public class SliderPanel extends GSliderPanel } - public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source) - { - SliderPanel pid = null; - if(PIDSlider == null) - { - pid = new SliderPanel(ap, 50, false, cs); - PIDSlider = new Frame(); - PIDSlider.add(pid); - } - else - { - pid = (SliderPanel)PIDSlider.getComponent(0); - pid.cs = cs; - } - PIDSlider.setTitle("Percentage Identity Threshold ("+source+")"); - - if (ap.av.alignment.getGroups() != null) - pid.setAllGroupsCheckEnabled(true); - else - pid.setAllGroupsCheckEnabled(false); - - return pid.getValue(); - - } - - public static void showPIDSlider() - { - try{ - conservationSlider.setVisible(false); - conservationSlider = null; - }catch(Exception ex){} - - if(!PIDSlider.isVisible()) - { - jalview.bin.JalviewLite.addFrame(PIDSlider, PIDSlider.getTitle(), 420, 100); + public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, + String source) + { + SliderPanel pid = null; + if (PIDSlider == null) + { + pid = new SliderPanel(ap, 50, false, cs); + PIDSlider = new Frame(); + PIDSlider.add(pid); + } + else + { + pid = (SliderPanel) PIDSlider.getComponent(0); + pid.cs = cs; + } + PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")"); + + if (ap.av.alignment.getGroups() != null) + { + pid.setAllGroupsCheckEnabled(true); + } + else + { + pid.setAllGroupsCheckEnabled(false); + } + + return pid.getValue(); + + } + + public static void showPIDSlider() + { + try + { + conservationSlider.setVisible(false); + conservationSlider = null; + } + catch (Exception ex) + {} + + if (!PIDSlider.isVisible()) + { + jalview.bin.JalviewLite.addFrame(PIDSlider, PIDSlider.getTitle(), 420, + 100); PIDSlider.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) @@ -128,76 +149,82 @@ public class SliderPanel extends GSliderPanel }); } - } - + } - public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, ColourSchemeI cs) + public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, + ColourSchemeI cs) { this.ap = ap; this.cs = cs; forConservation = forConserve; undoButton.setVisible(false); applyButton.setVisible(false); - if(forConservation) + if (forConservation) { label.setText("Modify conservation visibility"); slider.setMinimum(0); - slider.setMaximum(50+slider.getVisibleAmount()); + slider.setMaximum(50 + slider.getVisibleAmount()); slider.setUnitIncrement(1); } else { label.setText("Colour residues above % occurence"); slider.setMinimum(0); - slider.setMaximum(100+slider.getVisibleAmount()); + slider.setMaximum(100 + slider.getVisibleAmount()); slider.setBlockIncrement(1); } - - slider.addAdjustmentListener( new AdjustmentListener() + slider.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent evt) { - valueField.setText( slider.getValue()+"" ); - valueChanged( slider.getValue() ); + valueField.setText(slider.getValue() + ""); + valueChanged(slider.getValue()); } }); slider.setValue(value); - valueField.setText(value+""); + valueField.setText(value + ""); } public void valueChanged(int i) { - if(cs == null) + if (cs == null) + { return; + } ColourSchemeI toChange = null; Vector allGroups = null; int groupIndex = 0; - if(allGroupsCheck.getState()) + if (allGroupsCheck.getState()) { allGroups = ap.av.alignment.getGroups(); - groupIndex = allGroups.size()-1; + groupIndex = allGroups.size() - 1; } else + { toChange = cs; + } - - while( groupIndex > -1 ) + while (groupIndex > -1) { - if(allGroups!=null) - toChange = ((SequenceGroup)allGroups.elementAt(groupIndex)).cs; + if (allGroups != null) + { + toChange = ( (SequenceGroup) allGroups.elementAt(groupIndex)).cs; + } if (forConservation) { if (toChange instanceof ConservationColourScheme) + { ( (ConservationColourScheme) toChange).inc = i; + } } else { - ( (ResidueColourScheme) toChange).setThreshold(i); + ( (ResidueColourScheme) toChange).setThreshold(i); } groupIndex--; @@ -212,16 +239,16 @@ public class SliderPanel extends GSliderPanel allGroupsCheck.setEnabled(b); } - public void valueField_actionPerformed(ActionEvent e) { - try{ + try + { int i = Integer.parseInt(valueField.getText()); slider.setValue(i); } - catch(Exception ex) + catch (Exception ex) { - valueField.setText( slider.getValue()+"" ); + valueField.setText(slider.getValue() + ""); } } @@ -229,10 +256,10 @@ public class SliderPanel extends GSliderPanel { slider.setValue(value); } + public int getValue() { return Integer.parseInt(valueField.getText()); } - }