Class FunctionButton

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

public class FunctionButton extends JToggleButton
A JButton to activate functions on the decoder. FunctionButtons have a right-click popupMenu menu with several configuration options:
  • Set the text
  • Set the locking state
  • Set visibility
  • Set Font
  • Set function number identity
See Also:
  • Field Details

  • Constructor Details

    • FunctionButton

      public FunctionButton()
      Construct the FunctionButton.
  • Method Details

    • destroy

      public void destroy()
    • getButtonHeight

      public static int getButtonHeight()
      Get Button Height.
      Returns:
      height.
    • getButtonWidth

      public static int getButtonWidth()
      Get the Button Width.
      Returns:
      width.
    • getButtonImageSize

      public int getButtonImageSize()
      Get the Image Button Width.
      Returns:
      width.
    • setButtonImageSize

      public void setButtonImageSize(int is)
      Set the Image Button Hieght and Width.
      Parameters:
      is - the image size (sqaure image size = width = height)
    • setIdentity

      public void setIdentity(int id)
      Set the function number this button will operate.
      Parameters:
      id - An integer, minimum 0.
    • getIdentity

      public int getIdentity()
      Get the function number this button operates.
      Returns:
      An integer, minimum 0.
    • setState

      public void setState(boolean isOn)
      Set the state of the function button. Does not send update to layout, just updates button status.

      To update AND send to layout use setSelected(boolean).

      Parameters:
      isOn - True if the function should be active.
    • getState

      public boolean getState()
      Get the state of the function.
      Returns:
      true if the function is active.
    • setIsLockable

      public void setIsLockable(boolean isLockable)
      Set the locking state of the button.

      Changes in this parameter are only be sent to the listeners if the dirty bit is set.

      Parameters:
      isLockable - True if the a clicking and releasing the button changes the function state. False if the state is changed back when the button is released
    • getIsLockable

      public boolean getIsLockable()
      Get the locking state of the function.
      Returns:
      True if the a clicking and releasing the button changes the function state. False if the state is changed back when button is released
    • setDisplay

      public void setDisplay(boolean displayed)
      Set the display state of the button.
      Parameters:
      displayed - True if the button exists False if the button has been removed by the user
    • getDisplay

      public boolean getDisplay()
      Get the display state of the button.
      Returns:
      True if the button exists False if the button has been removed by the user
    • setDirty

      public void setDirty(boolean dirty)
      Set Function Button Dirty.
      Parameters:
      dirty - True when button has been modified by user, else false.
    • isDirty

      public boolean isDirty()
      Get if Button is Dirty.
      Returns:
      true when function button has been modified by user.
    • getButtonLabel

      Get the Button Label.
      Returns:
      Button Label text.
    • setButtonLabel

      public void setButtonLabel(String label)
      Set the Button Label.
      Parameters:
      label - Label Text.
    • setText

      public void setText(String s)
      Set Button Text.
      Overrides:
      setText in class AbstractButton
    • updateLnF

      public void updateLnF()
      Update Button Look and Feel ! Hide/show it if necessary Decide if it should show the label or an image with text as tooltip. Button UI updated according to above result.
    • setSelected

      public void setSelected(boolean newState)
      Change the state of the function. Sets internal state, setSelected, and sends to listeners.

      To update this button WITHOUT sending to layout, use setState.

      Overrides:
      setSelected in class AbstractButton
      Parameters:
      newState - true = Is Function on, False = Is Function off.
    • addFunctionListener

      Add a listener to this button, probably some sort of keypad panel.
      Parameters:
      l - The FunctionListener that wants notifications via the FunctionListener.notifyFunctionStateChanged.
    • removeFunctionListener

      Remove a listener from this button.
      Parameters:
      l - The FunctionListener to be removed
    • setDropFolder

      Set the folder where droped images in function button property panel will be stored
      Parameters:
      df - the folder path
    • getXml

      public org.jdom2.Element getXml()
      Collect the prefs of this object into XML Element.
      • identity
      • text
      • isLockable
      Returns:
      the XML of this object.
    • setXml

      public void setXml(org.jdom2.Element e)
      Set the preferences based on the XML Element.
      • identity
      • text
      • isLockable
      Parameters:
      e - The Element for this object.
    • setIconPath

      public void setIconPath(String fnImg)
      Set the Icon Path, NON selected.

      Checks image and sets isImageOK flag.

      Parameters:
      fnImg - icon path.
    • getIconPath

      Get the Icon Path, NON selected.
      Returns:
      Icon Path, else empty string if null.
    • setSelectedIconPath

      public void setSelectedIconPath(String fnImg)
      Set the Selected Icon Path.

      Checks image and sets isSelectedImageOK flag.

      Parameters:
      fnImg - selected icon path.
    • getSelectedIconPath

      Get the Selected Icon Path.
      Returns:
      selected Icon Path, else empty string if null.
    • isImageOK

      public boolean isImageOK()
      Get if isImageOK.
      Returns:
      true if isImageOK.
    • isSelectedImageOK

      public boolean isSelectedImageOK()
      Get if isSelectedImageOK.
      Returns:
      true if isSelectedImageOK.
    • setThrottle

      protected void setThrottle(Throttle throttle)
      Set Throttle.
      Parameters:
      throttle - the throttle that this button is associated with.
    • getThrottle

      Get Throttle for this button.
      Returns:
      throttle associated with this button. May be null if no throttle currently associated.