package jalview.gui;
import jalview.analysis.Conservation;
-import jalview.bin.Instance;
import jalview.datamodel.SequenceGroup;
import jalview.jbgui.GSliderPanel;
import jalview.renderer.ResidueShaderI;
public static SliderPanel getSliderPanel()
{
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (conservationSlider != null && conservationSlider.isVisible())
{
{
SliderPanel sliderPanel = null;
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
if (conservationSlider == null)
{
sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs);
- conservationSlider = Instance
- .getDesktop().conservationSlider = new JInternalFrame();
+ conservationSlider = Desktop
+ .getInstance().conservationSlider = new JInternalFrame();
conservationSlider.setContentPane(sliderPanel);
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
}
*/
public static void hidePIDSlider()
{
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (PIDSlider != null)
{
try
{
PIDSlider.setClosed(true);
- Instance.getDesktop().PIDSlider = null;
+ Desktop.getInstance().PIDSlider = null;
} catch (PropertyVetoException ex)
{
}
*/
public static void hideConservationSlider()
{
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
if (conservationSlider != null)
{
try
{
conservationSlider.setClosed(true);
- Instance.getDesktop().conservationSlider = null;
+ Desktop.getInstance().conservationSlider = null;
} catch (PropertyVetoException ex)
{
}
{
hidePIDSlider();
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
if (!conservationSlider.isVisible())
{
@Override
public void internalFrameClosed(InternalFrameEvent e)
{
- Instance.getDesktop().conservationSlider = null;
+ Desktop.getInstance().conservationSlider = null;
}
});
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
SliderPanel sliderPanel = null;
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (PIDSlider == null)
{
sliderPanel = new SliderPanel(ap, threshold, false, rs);
- PIDSlider = Instance.getDesktop().PIDSlider = new JInternalFrame();
+ PIDSlider = Desktop.getInstance().PIDSlider = new JInternalFrame();
PIDSlider.setContentPane(sliderPanel);
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
}
{
hideConservationSlider();
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (!PIDSlider.isVisible())
{
@Override
public void internalFrameClosed(InternalFrameEvent e)
{
- Instance.getDesktop().PIDSlider = null;
+ Desktop.getInstance().PIDSlider = null;
}
});
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
}
}
- public static int getConservationValue()
- {
- return getValue(Instance.getDesktop().conservationSlider);
- }
-
- static int getValue(JInternalFrame slider)
- {
- return slider == null ? 0
- : ((SliderPanel) slider.getContentPane()).getValue();
- }
-
- public static int getPIDValue()
- {
- return getValue(Instance.getDesktop().PIDSlider);
- }
-
/**
* Answers true if the SliderPanel is for Conservation, false if it is for PID
* threshold
public String getTitle()
{
String title = null;
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
+ JInternalFrame PIDSlider = getPIDSlider();
if (isForConservation())
{
}
return title;
}
+
+ /**
+ * Returns the singleton instance of the Conservation slider within current
+ * application scope, or null if there is none
+ *
+ * @return
+ */
+ private static JInternalFrame getConservationSlider()
+ {
+ 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();
+ }
}