X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSliderPanel.java;h=940bab27a161d51cc861073dd64c9ca458983678;hb=1e9f882c52f5b95d198c42973e7b2b1ce2b420df;hp=f98139b75d952d767e1837ae8b1bde50ece70cf2;hpb=928017f8d5b3b70273b62ac83a9015fe2e785ff3;p=jalview.git diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java index f98139b..940bab2 100755 --- a/src/jalview/gui/SliderPanel.java +++ b/src/jalview/gui/SliderPanel.java @@ -26,7 +26,6 @@ import jalview.jbgui.GSliderPanel; import jalview.renderer.ResidueShaderI; import jalview.util.MessageManager; -import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.beans.PropertyVetoException; @@ -45,14 +44,11 @@ import javax.swing.event.InternalFrameEvent; * @author $author$ * @version $Revision$ */ +@SuppressWarnings("serial") public class SliderPanel extends GSliderPanel { private static final String BACKGROUND = "Background"; - static JInternalFrame conservationSlider; - - static JInternalFrame PIDSlider; - AlignmentPanel ap; boolean forConservation = true; @@ -66,6 +62,11 @@ public class SliderPanel extends GSliderPanel */ public static SliderPanel getSliderPanel() { + + JInternalFrame conservationSlider = getConservationSlider(); + + JInternalFrame PIDSlider = getPIDSlider(); + if (conservationSlider != null && conservationSlider.isVisible()) { return (SliderPanel) conservationSlider.getContentPane(); @@ -118,7 +119,7 @@ public class SliderPanel extends GSliderPanel @Override public void stateChanged(ChangeEvent evt) { - valueField.setText(slider.getValue() + ""); + valueField.setText(String.valueOf(slider.getValue())); valueChanged(slider.getValue()); } }); @@ -133,7 +134,7 @@ public class SliderPanel extends GSliderPanel }); slider.setValue(value); - valueField.setText(value + ""); + valueField.setText(String.valueOf(value)); } /** @@ -153,10 +154,13 @@ public class SliderPanel extends GSliderPanel { SliderPanel sliderPanel = null; + JInternalFrame conservationSlider = getConservationSlider(); + if (conservationSlider == null) { sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs); - conservationSlider = new JInternalFrame(); + conservationSlider = Desktop + .getInstance().conservationSlider = new JInternalFrame(); conservationSlider.setContentPane(sliderPanel); conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); } @@ -192,12 +196,14 @@ public class SliderPanel extends GSliderPanel */ public static void hidePIDSlider() { + JInternalFrame PIDSlider = getPIDSlider(); + if (PIDSlider != null) { try { PIDSlider.setClosed(true); - PIDSlider = null; + Desktop.getInstance().PIDSlider = null; } catch (PropertyVetoException ex) { } @@ -209,12 +215,14 @@ public class SliderPanel extends GSliderPanel */ public static void hideConservationSlider() { + JInternalFrame conservationSlider = getConservationSlider(); + if (conservationSlider != null) { try { conservationSlider.setClosed(true); - conservationSlider = null; + Desktop.getInstance().conservationSlider = null; } catch (PropertyVetoException ex) { } @@ -228,16 +236,19 @@ public class SliderPanel extends GSliderPanel { hidePIDSlider(); + JInternalFrame conservationSlider = getConservationSlider(); + if (!conservationSlider.isVisible()) { Desktop.addInternalFrame(conservationSlider, - conservationSlider.getTitle(), 420, 90, false); + conservationSlider.getTitle(), true, FRAME_WIDTH, + FRAME_HEIGHT, false, true); conservationSlider.addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameClosed(InternalFrameEvent e) { - conservationSlider = null; + Desktop.getInstance().conservationSlider = null; } }); conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); @@ -263,10 +274,12 @@ public class SliderPanel extends GSliderPanel SliderPanel sliderPanel = null; + JInternalFrame PIDSlider = getPIDSlider(); + if (PIDSlider == null) { sliderPanel = new SliderPanel(ap, threshold, false, rs); - PIDSlider = new JInternalFrame(); + PIDSlider = Desktop.getInstance().PIDSlider = new JInternalFrame(); PIDSlider.setContentPane(sliderPanel); PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); } @@ -304,17 +317,19 @@ public class SliderPanel extends GSliderPanel { hideConservationSlider(); + JInternalFrame PIDSlider = getPIDSlider(); + if (!PIDSlider.isVisible()) { - Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90, - false); + Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), true, + FRAME_WIDTH, FRAME_HEIGHT, false, true); PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); PIDSlider.addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameClosed(InternalFrameEvent e) { - PIDSlider = null; + Desktop.getInstance().PIDSlider = null; } }); PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); @@ -448,22 +463,6 @@ public class SliderPanel extends GSliderPanel } } - public static int getConservationValue() - { - return getValue(conservationSlider); - } - - static int getValue(JInternalFrame slider) - { - return slider == null ? 0 - : ((SliderPanel) slider.getContentPane()).getValue(); - } - - public static int getPIDValue() - { - return getValue(PIDSlider); - } - /** * Answers true if the SliderPanel is for Conservation, false if it is for PID * threshold @@ -484,6 +483,9 @@ public class SliderPanel extends GSliderPanel public String getTitle() { String title = null; + JInternalFrame conservationSlider = getConservationSlider(); + JInternalFrame PIDSlider = getPIDSlider(); + if (isForConservation()) { if (conservationSlider != null) @@ -498,12 +500,62 @@ public class SliderPanel extends GSliderPanel return title; } - @Override - protected void allGroupsCheck_actionPerformed(ActionEvent e) + /** + * Returns the singleton instance of the Conservation slider within current + * application scope, or null if there is none + * + * @return + */ + private static JInternalFrame getConservationSlider() { - if (allGroupsCheck.isSelected()) - { - valueChanged(slider.getValue()); - } + return Desktop.getInstance().conservationSlider; + } + + /** + * Returns the singleton instance of the PID slider within current application + * scope, or null if there is none + * + * @return + */ + private static JInternalFrame getPIDSlider() + { + return Desktop.getInstance().PIDSlider; + } + + /** + * Returns the current value of the Conservation slider, or zero if there is + * no such slider + * + * @param slider + * @return + */ + public static int getConservationValue() + { + return getValue(getConservationSlider()); + } + + /** + * Returns the current value of the PID slider, or zero if there is no such + * slider + * + * @param slider + * @return + */ + public static int getPIDValue() + { + return getValue(getPIDSlider()); + } + + /** + * Returns the current value of the given slider, or zero if {@code slider} is + * null + * + * @param slider + * @return + */ + static int getValue(JInternalFrame slider) + { + return slider == null ? 0 + : ((SliderPanel) slider.getContentPane()).getValue(); } }