Class Widget

java.lang.Object
com.spinyowl.legui.component.Component
com.spinyowl.legui.component.Widget
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Dialog

public class Widget extends Component
Widget component is container which have predefined components such as container, title label, close and minimize buttons and predefined event listeners. This component can be moved, minimized and restored, closed. Also you can enable or disable title and make widget non-ascendible using setAscendible(boolean).
See Also:
  • Field Details

  • Constructor Details

    • Widget

      public Widget()
      Creates a widget with default title text. Ascendible by default (See isAscendible()).
    • Widget

      public Widget(boolean ascendible)
      Creates a widget with default title text. Ascendible by default (See isAscendible()).
      Parameters:
      ascendible - used to make it ascendible or not.
    • Widget

      public Widget(float x, float y, float width, float height)
      Creates a widget with default title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      x - x position in parent.
      y - y position in parent.
      width - width of component.
      height - height of component.
    • Widget

      public Widget(float x, float y, float width, float height, boolean ascendible)
      Creates a widget with default title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      x - x position in parent.
      y - y position in parent.
      width - width of component.
      height - height of component.
      ascendible - used to make it ascendible or not.
    • Widget

      public Widget(org.joml.Vector2f position, org.joml.Vector2f size)
      Creates a widget with default title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      position - position in parent.
      size - size of component.
    • Widget

      public Widget(org.joml.Vector2f position, org.joml.Vector2f size, boolean ascendible)
      Creates a widget with default title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      position - position in parent.
      size - size of component.
      ascendible - used to make it ascendible or not.
    • Widget

      public Widget(String title)
      Creates a widget with specified title text. Ascendible by default (See isAscendible()).
      Parameters:
      title - widget text.
    • Widget

      public Widget(String title, boolean ascendible)
      Creates a widget with specified title text. Ascendible by default (See isAscendible()).
      Parameters:
      title - widget text.
      ascendible - used to make it ascendible or not.
    • Widget

      public Widget(String title, float x, float y, float width, float height)
      Creates a widget with specified title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      title - widget text.
      x - x position in parent.
      y - y position in parent.
      width - width of component.
      height - height of component.
    • Widget

      public Widget(String title, float x, float y, float width, float height, boolean ascendible)
      Creates a widget with specified title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      title - widget text.
      x - x position in parent.
      y - y position in parent.
      width - width of component.
      height - height of component.
      ascendible - used to make it ascendible or not.
    • Widget

      public Widget(String title, org.joml.Vector2f position, org.joml.Vector2f size)
      Creates a widget with specified title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      title - widget text.
      position - position in parent.
      size - size of component.
    • Widget

      public Widget(String title, org.joml.Vector2f position, org.joml.Vector2f size, boolean ascendible)
      Creates a widget with specified title text and specified position and size. Ascendible by default (See isAscendible()).
      Parameters:
      title - widget text.
      position - position in parent.
      size - size of component.
      ascendible - used to make it ascendible or not.
  • Method Details

    • initialize

      public void initialize(String title)
      This method used to initialize widget.
      Parameters:
      title - title to set.
    • applyStylesToContainer

      public void applyStylesToContainer(Component container)
    • getTitleHeight

      public float getTitleHeight()
      Returns height of title.
      Returns:
      height of title.
    • setTitleHeight

      public void setTitleHeight(float titleHeight)
      Used to set title height.
      Parameters:
      titleHeight - title height to set.
    • isTitleEnabled

      public boolean isTitleEnabled()
      Returns true if title enabled.
      Returns:
      true if title enabled.
    • setTitleEnabled

      public void setTitleEnabled(boolean titleEnabled)
      Used to set title enabled or not.
      Parameters:
      titleEnabled - title state (enable or not) to set.
    • isCloseable

      public boolean isCloseable()
      Returns true if widget should be closeable.
      Returns:
      true if widget should be closeable.
    • setCloseable

      public void setCloseable(boolean closeable)
      Used to set would widget closeable or not.
      Parameters:
      closeable - widget state (closeable or not) to set.
    • getCloseButton

      public Button getCloseButton()
      Returns close button of widget.
      Returns:
      close button of widget.
    • getMinimizeButton

      public Button getMinimizeButton()
      Returns minimize button of widget.
      Returns:
      minimize button of widget.
    • getTitleContainer

      public Component getTitleContainer()
      Returns title container. Can be used to customize widget.
      Returns:
      title container.
    • getTitleTextState

      public TextState getTitleTextState()
      Returns title text state.
      Returns:
      title text state.
    • getTitle

      public Label getTitle()
    • getCloseButtonColor

      public org.joml.Vector4f getCloseButtonColor()
      Returns close button text color.
      Returns:
      close button text color.
    • setCloseButtonColor

      public void setCloseButtonColor(org.joml.Vector4f closeButtonColor)
      Used to set close button text color.
      Parameters:
      closeButtonColor - close button text color to set.
    • getContainer

      public Component getContainer()
      Returns widget container that hold all other elements. Should be used to add components.
      Returns:
      widget container.
    • setContainer

      public void setContainer(Component container)
      Used to set widget container.
      Parameters:
      container - widget container to set.
    • isDraggable

      public boolean isDraggable()
      Returns true if widget could be dragged.
      Returns:
      true if widget could be dragged.
    • setDraggable

      public void setDraggable(boolean draggable)
      Used to set widget draggable or not.
      Parameters:
      draggable - new draggable state of widget.
    • isMinimizable

      public boolean isMinimizable()
      Returns true if widget could be minimized (minimize button is visible).
      Returns:
      true if widget could be minimized (minimize button is visible).
    • setMinimizable

      public void setMinimizable(boolean minimizable)
      Used to make minimize button visible or not.
      Parameters:
      minimizable - new minimizable state of widget.
    • isMinimized

      public boolean isMinimized()
      Returns true if widget minimized.
      Returns:
      true if widget minimized.
    • setMinimized

      public void setMinimized(boolean minimized)
      Used to minimize/maximize widget.
      Parameters:
      minimized - true to minimize, false to maximize.
    • hide

      public void hide()
    • show

      public void show()
    • getCloseIcon

      public Icon getCloseIcon()
      Returns close icon that used by close button.
      Returns:
      close icon that used by close button.
    • setCloseIcon

      public void setCloseIcon(Icon closeIcon)
      Used to set close icon to close button.
      Parameters:
      closeIcon - close icon to set.
    • getMaximizeIcon

      public Icon getMaximizeIcon()
      Returns maximize icon that used by minimize button.
      Returns:
      maximize icon that used by minimize button.
    • setMaximizeIcon

      public void setMaximizeIcon(Icon maximizeIcon)
      Used to set maximize icon to minimize button.
      Parameters:
      maximizeIcon - maximize icon to set.
    • getMinimizeIcon

      public Icon getMinimizeIcon()
      Returns minimize icon that used by minimize button.
      Returns:
      minimize icon that used by minimize button.
    • setMinimizeIcon

      public void setMinimizeIcon(Icon minimizeIcon)
      Used to set minimize icon to minimize button.
      Parameters:
      minimizeIcon - minimize icon to set.
    • addWidgetCloseEventListener

      public void addWidgetCloseEventListener(EventListener<WidgetCloseEvent> eventListener)
      Used to add event listener for widget close event.
      Parameters:
      eventListener - event listener to add.
    • getWidgetCloseEvents

      public List<EventListener<WidgetCloseEvent>> getWidgetCloseEvents()
      Returns all event listeners for widget close event.
      Returns:
      all event listeners for widget close event.
    • removeWidgetCloseEventListener

      public void removeWidgetCloseEventListener(EventListener<WidgetCloseEvent> eventListener)
      Used to remove event listener for widget close event.
      Parameters:
      eventListener - event listener to remove.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Component
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Component
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • isResizable

      public boolean isResizable()
    • setResizable

      public void setResizable(boolean resizable)
    • getResizeButton

      public Button getResizeButton()
    • isAscendible

      public boolean isAscendible()
      Returns true if widget could ascend to the top in parent container.
      Returns:
      true if widget could ascend to the top in parent container.
    • setAscendible

      public void setAscendible(boolean ascendible)
      Set true to make widget ascend to the top in parent container on click event on widget or any component inside.
      Parameters:
      ascendible - new state.