Class ChessClockControl

All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable, GameComponent, PropertyNameSource, CommandEncoder, ComponentDescription, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget, UniqueIdManager.Identifyable

CHESS CLOCK CONTROLLER for VASSAL. This Module-level component manages a set of one or more ChessClock clocks. It creates a master "Chess Clocks" button on the Module's toolbar. Clicking the button shows/hides the clocks themselves, when no clocks are running, or stops all clocks if one is running. The Chess Clock Control component also contains the configurable elements that specify how the clocks are to be displayed.
  • Field Details Link icon

  • Constructor Details Link icon

    • ChessClockControl Link icon

      public ChessClockControl()
  • Method Details Link icon

    • isInstanceIsActive Link icon

      public boolean isInstanceIsActive()
    • getChessClocks Link icon

      public List<ChessClock> getChessClocks()
      Returns:
      Our list of chessclocks
    • getDescription Link icon

      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 Link icon

      public void build(Element e)
      Builds the clock control's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new clock control" hierarchy.
      Specified by:
      build in interface Buildable
      Overrides:
      build in class AbstractBuildable
      Parameters:
      e - XML element to build from, or null to build the default hierarchy
    • addTo Link icon

      public void addTo(Buildable parent)
      Registers us with the game module, tool bar, command encoder, etc.
      Specified by:
      addTo in interface Buildable
      Parameters:
      parent - - Should be the main GameModule, but in any event that's what we add it to
    • removeFrom Link icon

      public void removeFrom(Buildable parent)
      Unregisters us from everything when shutting down.
      Specified by:
      removeFrom in interface Configurable
      Parameters:
      parent - - Presumably the main GameModule, but in any event that's what we remove ourselves from.
    • setId Link icon

      public void setId(String id)
      Manages our unique ID
      Specified by:
      setId in interface UniqueIdManager.Identifyable
      Parameters:
      id - - sets our unique id
    • getId Link icon

      public String getId()
      Specified by:
      getId in interface UniqueIdManager.Identifyable
      Returns:
      our unique id
    • isAllowReset Link icon

      public boolean isAllowReset()
      Returns:
      Whether clocks can be reset manually
    • getChessClocksVisible Link icon

      public boolean getChessClocksVisible()
      Returns:
      true if the group of chess clocks we manage is currently visible
    • getConfigureTypeName Link icon

      public static String getConfigureTypeName()
      Returns:
      Component type name, which appears in [..] in Editor window
    • getAllowableConfigureComponents Link icon

      public Class<?>[] getAllowableConfigureComponents()
      Specified by:
      getAllowableConfigureComponents in interface Configurable
      Returns:
      List of valid subcomponent class types for this component (in our case, individual Chess Clocks!) which can be added in the Editor.
    • getAttributeNames Link icon

      public String[] getAttributeNames()
      Description copied from class: AbstractBuildable
      Lists all the buildFile (XML) attribute names for this component. If this component is ALSO an AbstractConfigurable, then this list of attributes determines the appropriate attribute order for AbstractConfigurable.getAttributeDescriptions() and AbstractConfigurable.getAttributeTypes().
      Specified by:
      getAttributeNames in interface AutoConfigurable
      Specified by:
      getAttributeNames in class AbstractBuildable
      Returns:
      Key names for our attributes from the buildFile (XML) definition.
    • getAttributeDescriptions Link icon

      public String[] getAttributeDescriptions()
      Description copied from interface: AutoConfigurable
      Return an array of Strings describing the attributes of this object. These strings are used as prompts in the Properties window for this object.
      Specified by:
      getAttributeDescriptions in interface AutoConfigurable
      Specified by:
      getAttributeDescriptions in class AbstractConfigurable
      Returns:
      Descriptions for our buildFile (XML) attributes. These appear when our component is configured in the Editor window.
    • getAttributeTypes Link icon

      public Class<?>[] getAttributeTypes()
      Description copied from interface: AutoConfigurable
      Return the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, File, Color, and KeyStroke
      Specified by:
      getAttributeTypes in interface AutoConfigurable
      Specified by:
      getAttributeTypes in class AbstractConfigurable
      Returns:
      Class types for configuring each of our buildFile (XML) attributes. Specifies which flavor of configurer to uses.
    • setAttribute Link icon

      public void setAttribute(String key, Object value)
      Sets the value of one of this component's XML attributes
      Specified by:
      setAttribute in interface AutoConfigurable
      Specified by:
      setAttribute in interface Translatable
      Specified by:
      setAttribute in class AbstractBuildable
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      value - New value for the attribute. Can be either String version or the actual Object.
    • getAttributeValueString Link icon

      public String getAttributeValueString(String key)
      Gets the value of one of this component's XML attributes
      Specified by:
      getAttributeValueString in interface AutoConfigurable
      Specified by:
      getAttributeValueString in interface Translatable
      Specified by:
      getAttributeValueString in class AbstractBuildable
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      Returns:
      String value of the attribute.
    • getHelpFile Link icon

      public HelpFile getHelpFile()
      Specified by:
      getHelpFile in interface Configurable
      Returns:
      The help file for this component. Used when user clicks "Help" button while configuring the component in the Editor.
    • getInstance Link icon

      public static ChessClockControl getInstance()
      When we need to find a ChessClockControl in a static context
      Returns:
      First ChessClockControl in our module
    • getShowTenths Link icon

      public String getShowTenths()
      Returns:
      Setting for showing tenths of seconds. (Always, Auto, Never)
    • getShowSeconds Link icon

      public String getShowSeconds()
      Returns:
      Setting for showing seconds. (Always, Auto, Never)
    • getShowHours Link icon

      public String getShowHours()
      Returns:
      Setting for showing hours. (Always, Auto, Never)
    • getShowDays Link icon

      public String getShowDays()
      Returns:
      Setting for showing days. (Always, Auto, Never)
    • getClocksTicking Link icon

      public int getClocksTicking()
      Returns:
      the number of chess clocks currently ticking/active
    • stopAllClocks Link icon

      public Command stopAllClocks()
      Returns:
      A command to stop all the clocks
    • startNextClock Link icon

      public Command startNextClock()
      Returns:
      a command to start the next clock after stopping the one currently running (if any)
    • startOpponentClock Link icon

      public Command startOpponentClock()
      Returns:
      a command to start the opponents clock after stopping the one currently running (if any)
    • startClock Link icon

      public Command startClock(ChessClock targetClock)
      Returns:
      a command to start the requested clock after stopping the one currently running (if any)
    • stopClock Link icon

      public Command stopClock(ChessClock targetClock)
      Returns:
      a command to start the requested clock after stopping the one currently running (if any)
    • hideClocks Link icon

      public void hideClocks()
      Hide all the clocks on the toolbar
    • showClocks Link icon

      public void showClocks()
      Show all the clocks on the toolbar
    • updateAllClocks Link icon

      public void updateAllClocks()
      Update all clocks (when our time-display format changes)
    • pressControlButton Link icon

      public void pressControlButton()
      Figures out "the right thing to do" when player clicks the main Chess Clock Control button. Does one of the following, in order of priority: (1) If the clocks are hidden, show them (2) If any clock is running, stop them all (3) Hide all the clocks
    • setOnline Link icon

      public void setOnline(boolean online)
      Tells Chess Clock Control that this is a real online game, meaning we move to stricter verification standards for clocks (completely non-online clocks are really just "sandbox toys")
      Parameters:
      online - True if this is an online game
    • isOnline Link icon

      public boolean isOnline()
      Returns:
      True if this has been marked as an online game
    • setup Link icon

      public void setup(boolean gameStarting)
      Handles starting and ending a game from the point of view of Chess Clocks.
      Specified by:
      setup in interface GameComponent
      Parameters:
      gameStarting - If true, a game is starting. If false, then a game is ending.
    • addChessClock Link icon

      public void addChessClock(ChessClock clock)
      Allows individual chess clocks to add themselves to our control scheme
      Parameters:
      clock - clock to be added
    • removeChessClock Link icon

      public void removeChessClock(ChessClock clock)
      Removes a chess clock
      Parameters:
      clock - clock to be removed
    • decode Link icon

      public Command decode(String command)
      Deserializes our command from a string version, if the command belongs to us.
      Specified by:
      decode in interface CommandEncoder
      Parameters:
      command - Serialized string command
      Returns:
      An ChessClockControl.UpdateClockControlCommand
    • encode Link icon

      public String encode(Command c)
      Serializes our command into a string, if it belongs to us
      Specified by:
      encode in interface CommandEncoder
      Parameters:
      c - Command to serialize. Only serialized if it's an UpdateClockControlCommand.
      Returns:
      Serialized command, or null if command passed wasn't an UpdateClockControlCommand.
    • getRestoreCommand Link icon

      public Command getRestoreCommand()
      Description copied from interface: GameComponent
      When saving a game, each GameComponent should return a Command that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null
      Specified by:
      getRestoreCommand in interface GameComponent
      Returns:
      Our command for restoring from a saved game (or adding an online player)
    • isUnique Link icon

      public boolean isUnique()
      There can be only one!
      Specified by:
      isUnique in interface Buildable
      Returns: