X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSliderPanel.java;h=7d733c9624deeb331aaaf1449eea486e42df4548;hb=78ca38e25791832308bf179d91a41c352d305f4c;hp=8c290b5b45fe315b88baa9f2b5d84ab28f5be597;hpb=2de8acfae59aced665e4c37ad0f7dcc2ed68818e;p=jalview.git diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java index 8c290b5..7d733c9 100755 --- a/src/jalview/gui/SliderPanel.java +++ b/src/jalview/gui/SliderPanel.java @@ -1,32 +1,41 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) - * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * - * 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 file is part of Jalview. * - * 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. + * Jalview 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 3 + * of the License, or (at your option) any later version. + * + * Jalview 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 + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.gui; -import java.util.*; +import jalview.datamodel.SequenceGroup; +import jalview.jbgui.GSliderPanel; +import jalview.schemes.ColourSchemeI; +import jalview.util.MessageManager; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.beans.PropertyVetoException; +import java.util.Iterator; -import jalview.datamodel.*; -import jalview.jbgui.*; -import jalview.schemes.*; +import javax.swing.JInternalFrame; +import javax.swing.JLayeredPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; /** * DOCUMENT ME! @@ -50,13 +59,13 @@ public class SliderPanel extends GSliderPanel * Creates a new SliderPanel object. * * @param ap - * DOCUMENT ME! + * DOCUMENT ME! * @param value - * DOCUMENT ME! + * DOCUMENT ME! * @param forConserve - * DOCUMENT ME! + * DOCUMENT ME! * @param cs - * DOCUMENT ME! + * DOCUMENT ME! */ public SliderPanel(final AlignmentPanel ap, int value, boolean forConserve, ColourSchemeI cs) @@ -69,19 +78,22 @@ public class SliderPanel extends GSliderPanel if (forConservation) { - label.setText("Enter value to increase conservation visibility"); + label.setText(MessageManager + .getString("label.enter_value_increase_conservation_visibility")); slider.setMinimum(0); slider.setMaximum(100); } else { - label.setText("Enter % identity above which to colour residues"); + label.setText(MessageManager + .getString("label.enter_percentage_identity_above_which_colour_residues")); slider.setMinimum(0); slider.setMaximum(100); } slider.addChangeListener(new ChangeListener() { + @Override public void stateChanged(ChangeEvent evt) { valueField.setText(slider.getValue() + ""); @@ -91,6 +103,7 @@ public class SliderPanel extends GSliderPanel slider.addMouseListener(new MouseAdapter() { + @Override public void mouseReleased(MouseEvent evt) { ap.paintAlignment(true); @@ -105,11 +118,11 @@ public class SliderPanel extends GSliderPanel * DOCUMENT ME! * * @param ap - * DOCUMENT ME! + * DOCUMENT ME! * @param cs - * DOCUMENT ME! + * DOCUMENT ME! * @param source - * DOCUMENT ME! + * DOCUMENT ME! * * @return DOCUMENT ME! */ @@ -128,13 +141,16 @@ public class SliderPanel extends GSliderPanel else { sp = (SliderPanel) conservationSlider.getContentPane(); + sp.slider.setValue(cs.getConservationInc()); sp.cs = cs; } - conservationSlider.setTitle("Conservation Colour Increment (" + source - + ")"); + conservationSlider + .setTitle(MessageManager.formatMessage( + "label.conservation_colour_increment", + new String[] { source })); - if (ap.av.alignment.getGroups() != null) + if (ap.av.getAlignment().getGroups() != null) { sp.setAllGroupsCheckEnabled(true); } @@ -147,27 +163,55 @@ public class SliderPanel extends GSliderPanel } /** - * DOCUMENT ME! + * Hides the PID slider panel if it is shown */ - public static void showConservationSlider() + public static void hidePIDSlider() { - try + if (PIDSlider != null) { - PIDSlider.setClosed(true); - PIDSlider = null; - } catch (Exception ex) + try + { + PIDSlider.setClosed(true); + PIDSlider = null; + } catch (PropertyVetoException ex) + { + } + } + } + + /** + * Hides the conservation slider panel if it is shown + */ + public static void hideConservationSlider() + { + if (conservationSlider != null) { + try + { + conservationSlider.setClosed(true); + conservationSlider = null; + } catch (PropertyVetoException ex) + { + } } + } + + /** + * DOCUMENT ME! + */ + public static void showConservationSlider() + { + hidePIDSlider(); if (!conservationSlider.isVisible()) { - Desktop.addInternalFrame(conservationSlider, conservationSlider - .getTitle(), 420, 90, false); + Desktop.addInternalFrame(conservationSlider, + conservationSlider.getTitle(), 420, 90, false); conservationSlider - .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + .addInternalFrameListener(new InternalFrameAdapter() { - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent e) + @Override + public void internalFrameClosed(InternalFrameEvent e) { conservationSlider = null; } @@ -180,11 +224,11 @@ public class SliderPanel extends GSliderPanel * DOCUMENT ME! * * @param ap - * DOCUMENT ME! + * DOCUMENT ME! * @param cs - * DOCUMENT ME! + * DOCUMENT ME! * @param source - * DOCUMENT ME! + * DOCUMENT ME! * * @return DOCUMENT ME! */ @@ -205,12 +249,16 @@ public class SliderPanel extends GSliderPanel else { pid = (SliderPanel) PIDSlider.getContentPane(); + pid.slider.setValue(cs.getThreshold()); pid.cs = cs; } - PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")"); + PIDSlider + .setTitle(MessageManager.formatMessage( + "label.percentage_identity_threshold", + new String[] { source })); - if (ap.av.alignment.getGroups() != null) + if (ap.av.getAlignment().getGroups() != null) { pid.setAllGroupsCheckEnabled(true); } @@ -227,28 +275,21 @@ public class SliderPanel extends GSliderPanel */ public static void showPIDSlider() { - try - { - conservationSlider.setClosed(true); - conservationSlider = null; - } catch (Exception ex) - { - } + hideConservationSlider(); if (!PIDSlider.isVisible()) { Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90, false); PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); - PIDSlider - .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() - { - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent e) - { - PIDSlider = null; - } - }); + PIDSlider.addInternalFrameListener(new InternalFrameAdapter() + { + @Override + public void internalFrameClosed(InternalFrameEvent e) + { + PIDSlider = null; + } + }); PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); } } @@ -257,7 +298,7 @@ public class SliderPanel extends GSliderPanel * DOCUMENT ME! * * @param i - * DOCUMENT ME! + * DOCUMENT ME! */ public void valueChanged(int i) { @@ -266,57 +307,46 @@ public class SliderPanel extends GSliderPanel return; } - ColourSchemeI toChange = null; - Vector allGroups = null; - int groupIndex = 0; + ColourSchemeI toChange = cs; + Iterator allGroups = null; if (allGroupsCheck.isSelected()) { - allGroups = ap.av.alignment.getGroups(); - groupIndex = allGroups.size() - 1; - } - else - { - toChange = cs; + allGroups = ap.av.getAlignment().getGroups().listIterator(); } - while (groupIndex > -1) + while (toChange != null) { - if (allGroups != null) + if (forConservation) { - toChange = ((SequenceGroup) allGroups.get(groupIndex)).cs; - - if (toChange == null) - { - groupIndex--; - - continue; - } + toChange.setConservationInc(i); } - - if (forConservation) + else + { + toChange.setThreshold(i, ap.av.isIgnoreGapsConsensus()); + } + if (allGroups != null && allGroups.hasNext()) { - if (toChange.conservationApplied()) + while ((toChange = allGroups.next().cs) == null + && allGroups.hasNext()) { - toChange.setConservationInc(i); + ; } } else { - toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus()); + toChange = null; } - - groupIndex--; } - ap.seqPanel.seqCanvas.repaint(); + ap.getSeqPanel().seqCanvas.repaint(); } /** * DOCUMENT ME! * * @param b - * DOCUMENT ME! + * DOCUMENT ME! */ public void setAllGroupsCheckEnabled(boolean b) { @@ -326,26 +356,8 @@ public class SliderPanel extends GSliderPanel /** * DOCUMENT ME! * - * @param e - * DOCUMENT ME! - */ - public void valueField_actionPerformed(ActionEvent e) - { - try - { - int i = Integer.parseInt(valueField.getText()); - slider.setValue(i); - } catch (NumberFormatException ex) - { - valueField.setText(slider.getValue() + ""); - } - } - - /** - * DOCUMENT ME! - * * @param value - * DOCUMENT ME! + * DOCUMENT ME! */ public void setValue(int value) { @@ -362,6 +374,7 @@ public class SliderPanel extends GSliderPanel return Integer.parseInt(valueField.getText()); } + @Override public void slider_mouseReleased(MouseEvent e) { if (ap.overviewPanel != null)