Package VASSAL.build

Class Widget

All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable, PropertyNameSource, ComponentDescription, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget
Direct Known Subclasses:
BoxWidget, Chart, ChartWindow, HtmlChart, ListWidget, MapWidget, PanelWidget, PieceSlot, PieceWindow, TabWidget

public abstract class Widget extends AbstractConfigurable implements ComponentDescription
A general-purpose configurable GUI container Widgets are Configurable objects that represent AWT components. Adding a Widget to another Widget during a Buildable.build(org.w3c.dom.Element) operation will add the corresponding AWT component of the child to the component of the parent
  • Field Details

  • Constructor Details

    • Widget

      protected Widget()
  • Method Details

    • hasScale

      public boolean hasScale()
    • hasScalablePieces

      public boolean hasScalablePieces()
      Returns:
      false if we're a child of a ChartWindow, meaning there won't be pieces to scale
    • getScale

      public double getScale()
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface ComponentDescription
      Returns:
      Description to be displayed next to component type/name in the main Editor window. Or null or "" to not display anything.
    • build

      public void build(Element el)
      For memory efficiency reasons, a Widget is initialized lazily. This method only stores the element from which the build the Widget. The Widget is built from the stored element by invoking rebuild(). Subclasses should invoke rebuild() before invoking getComponent()
      Specified by:
      build in interface Buildable
      Overrides:
      build in class AbstractBuildable
      Parameters:
      el - the XML element containing the object data
    • rebuild

      protected void rebuild()
      Perform the build of this Buildable component using the element stored from when the the build(org.w3c.dom.Element) method was invoked
    • getBuildElement

      public Element getBuildElement(Document doc)
      Specified by:
      getBuildElement in interface Buildable
      Overrides:
      getBuildElement in class AbstractBuildable
      Parameters:
      doc - XML file
      Returns:
      an XML element from which this component can be built
    • getChildAllowableConfigureComponents

      public Class<?>[] getChildAllowableConfigureComponents()
      Allowable components for a CHILD of this class - default is to ask our parent for this list. Top-level parents must override this with the proper child list for their trees.
      Returns:
      configure components allowed for children of this class
    • getAllowableConfigureComponents

      public Class<?>[] getAllowableConfigureComponents()
      The allowable Configurable components of a Widget determined by its parent's Child-Allowable method.
      Specified by:
      getAllowableConfigureComponents in interface Configurable
      Returns:
      a list of valid sub-component Classes. If a Class appears in this list, then instances of that class may be added to this component from the Editor's ConfigureTree window by right-clicking on the component and selecting the appropriate "Add" option.
    • addTo

      public void addTo(Buildable b)
      Description copied from interface: Buildable
      Adds this component to its parent. In order to make Buildable objects extensible, the child is responsible for adding itself to the parent. That way, Buildable subcomponents can be defined in an extension package without needing to modify the containing class.
      Specified by:
      addTo in interface Buildable
      Parameters:
      b - parent Buildable to add this component to as a subcomponent.
    • removeFrom

      public void removeFrom(Buildable b)
      Description copied from interface: Configurable
      Remove this component from its parent
      Specified by:
      removeFrom in interface Configurable
    • getParent

      public Widget getParent()
    • getConfigureComponents

      public Configurable[] getConfigureComponents()
      Specified by:
      getConfigureComponents in interface Configurable
      Overrides:
      getConfigureComponents in class AbstractConfigurable
      Returns:
      A list of all child components (i.e. subcomponents) of this component that are configurable.
    • getComponent

      public abstract Component getComponent()
      Returns:
      the Component for this widget. For efficiency, the Component may be initialized lazily instead of being created in the Buildable.build(org.w3c.dom.Element) method
    • getHelpFile

      public HelpFile getHelpFile()
      Specified by:
      getHelpFile in interface Configurable
      Returns:
      a HelpFile describing how to use and configure * this component