Class SlotWindow

All Implemented Interfaces:
ComponentPaintCache.Cacheable, Inspectable, ManagedWindow, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
Spells

public class SlotWindow extends InternalManagedWindow implements Inspectable
A window for showing contents of an entity's slot in a grid of ItemPanels
See Also:
Serialized Form
  • Constructor Details

    • SlotWindow

      public SlotWindow(String title, int width, int height)
      Create a new EntityContainer.
      Parameters:
      title - window title
      width - number of slot columns
      height - number of slot rows
  • Method Details

    • setSlotsLayout

      protected void setSlotsLayout(int width, int height)
    • setAcceptedTypes

      @SafeVarargs public final void setAcceptedTypes(Class<? extends IEntity>... types)
      Set the types the panels can accept.
      Parameters:
      types - accepted types
    • setSlot

      public void setSlot(IEntity parent, String slot)
      Sets the parent entity of the window.
      Parameters:
      parent - entity owning the slot presented by the window
      slot - slot presented
    • setInspector

      public void setInspector(Inspector inspector)
      Set the inspector used for the contained entities.
      Specified by:
      setInspector in interface Inspectable
      Parameters:
      inspector - used inspector
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class InternalWindow
    • close

      public void close()
      Description copied from class: InternalWindow
      Close the window. Either deletes or hides it, according to the policy set with InternalWindow.setHideOnClose(boolean).
      Overrides:
      close in class InternalWindow
    • isCloseEnough

      public boolean isCloseEnough()
      Check if the user is close enough the parent entity of the slot. If the user is too far away the window should not be opened, and it should be closed if it was already open.
      Returns:
      true if the user is close enough to have the window open, false otherwise.