public static SliderPanel getSliderPanel()
{
- JInternalFrame conservationSlider = Desktop
- .getInstance().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
- JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (conservationSlider != null && conservationSlider.isVisible())
{
{
SliderPanel sliderPanel = null;
- JInternalFrame conservationSlider = Desktop
- .getInstance().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
if (conservationSlider == null)
{
*/
public static void hidePIDSlider()
{
- JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (PIDSlider != null)
{
*/
public static void hideConservationSlider()
{
- JInternalFrame conservationSlider = Desktop
- .getInstance().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
if (conservationSlider != null)
{
{
hidePIDSlider();
- JInternalFrame conservationSlider = Desktop
- .getInstance().conservationSlider;
+ JInternalFrame conservationSlider = getConservationSlider();
if (!conservationSlider.isVisible())
{
SliderPanel sliderPanel = null;
- JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (PIDSlider == null)
{
{
hideConservationSlider();
- JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+ JInternalFrame PIDSlider = getPIDSlider();
if (!PIDSlider.isVisible())
{
}
}
- public static int getConservationValue()
- {
- return getValue(Desktop.getInstance().conservationSlider);
- }
-
- static int getValue(JInternalFrame slider)
- {
- return slider == null ? 0
- : ((SliderPanel) slider.getContentPane()).getValue();
- }
-
- public static int getPIDValue()
- {
- return getValue(Desktop.getInstance().PIDSlider);
- }
-
/**
* Answers true if the SliderPanel is for Conservation, false if it is for PID
* threshold
public String getTitle()
{
String title = null;
- JInternalFrame conservationSlider = Desktop
- .getInstance().conservationSlider;
- JInternalFrame PIDSlider = Desktop.getInstance().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();
+ }
}