Class AbstractVerbalDesignSupport<G extends GameComponent>

  • Type Parameters:
    G - the type of game component analyzed by the design support
    All Implemented Interfaces:
    DesignSupport<G>
    Direct Known Subclasses:
    LegacyDesignSupport, VerbalDesignSupportAdapter

    public abstract class AbstractVerbalDesignSupport<G extends GameComponent>
    extends java.lang.Object
    implements DesignSupport<G>
    An abstract base class for design supports that create verbal reports to describe their design analyses. The reports can include basic HTML formatting.
    Since:
    3.0
    Author:
    Chris Jennings
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractVerbalDesignSupport​(G gc)
      Creates a new verbal design support that will support the specified component.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract boolean analyze​(G gc, java.lang.StringBuilder b)
      This method is called when the design needs to reanalyzed.
      java.awt.Component createSupportView()
      Creates an interface component that will display or visualize the design support for the user.
      G getGameComponent()
      Returns the game component that this design support will analyze.
      java.lang.String getReport()
      Returns the design support's verbal report as a string.
      boolean isDesignValid()
      Returns true if the component's design is valid.
      void markChanged()
      When a support is attached to an editor, the editor will call this to mark the analysis as out of date when the component is edited.
      void updateSupportView​(java.awt.Component view)
      Updates a support view created by this design support to reflect the current design analysis.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractVerbalDesignSupport

        public AbstractVerbalDesignSupport​(G gc)
        Creates a new verbal design support that will support the specified component.
        Parameters:
        gc - the game component that the support will analyze
        Throws:
        java.lang.NullPointerException - if the component is null
    • Method Detail

      • getGameComponent

        public final G getGameComponent()
        Returns the game component that this design support will analyze.
        Specified by:
        getGameComponent in interface DesignSupport<G extends GameComponent>
        Returns:
        the component supported by this design support; cannot be null
      • getReport

        public final java.lang.String getReport()
        Returns the design support's verbal report as a string.
        Returns:
        the current report, reanalyzing the component if necessary
      • markChanged

        public void markChanged()
        Description copied from interface: DesignSupport
        When a support is attached to an editor, the editor will call this to mark the analysis as out of date when the component is edited.
        Specified by:
        markChanged in interface DesignSupport<G extends GameComponent>
      • isDesignValid

        public boolean isDesignValid()
        Description copied from interface: DesignSupport
        Returns true if the component's design is valid. The exact meaning of "valid" depends on the component type, but the general intent is that invalid components break the usual design rules for the component type in such a way that the resulting component may be unfair. Strange Eons does not use this value itself, but there are preference settings that allow users to request that their components should be marked if this returns false. (It is up to the plug-in author to implement this in the component's Sheets.
        Specified by:
        isDesignValid in interface DesignSupport<G extends GameComponent>
        Returns:
        true if the design is valid
      • analyze

        protected abstract boolean analyze​(G gc,
                                           java.lang.StringBuilder b)
        This method is called when the design needs to reanalyzed. It creates the new report by appending text to the provided string builder and returns a boolean value to indicate whether or not the design is valid.
        Parameters:
        gc - the game component to analyze (same as getGameComponent())
        b - a string builder that must be used to build the verbal design report
        Returns:
        true if the design is considered valid, false otherwise
      • updateSupportView

        public void updateSupportView​(java.awt.Component view)
        Description copied from interface: DesignSupport
        Updates a support view created by this design support to reflect the current design analysis. Because it may be costly to create this visualization, the view is not expected to update automatically. Instead, the game component editor will monitor the component for changes and then schedule an update of the the view for some future time.
        Specified by:
        updateSupportView in interface DesignSupport<G extends GameComponent>
        Parameters:
        view - the view to update; the result if a component that was not created by calling this support's DesignSupport.createSupportView() method is undefined
      • createSupportView

        public java.awt.Component createSupportView()
        Description copied from interface: DesignSupport
        Creates an interface component that will display or visualize the design support for the user. An editor for a game component that includes design support may create a view to add to its interface. It will then pass its view to the design support when it wants the design support to update the support content.
        Specified by:
        createSupportView in interface DesignSupport<G extends GameComponent>
        Returns:
        a component that visualizes a design support analysis