Class HotSpot

  • Direct Known Subclasses:
    Hyperlink, KeyHotSpot

    public abstract class HotSpot
    extends java.lang.Object
    Abstract class that is used to parse data of a line on the screen to create hot spots such as function keys (or other send keys) and links. Extending classes provides a way to parse a line on the screen and if a hot spot is found, call "addHotSpot" to create a new hot spot. This will create a new instance of the same class as the extending class.

    This abstract class handles both parsing and identifying hot spots of a certain type as well as the actual drawing of them on screen and when they are activated (performing a function).

    Author:
    Christopher Mindus
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      protected booleanactive
      Is this hot spot active?
      java.lang.Stringtext
      The text of the hot spot, null if not yet set.
      intwidth
      The width of the hot spot in characters.
      intx
      The X position of the line where this hot spot is located in character count.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      HotSpot() 
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and TypeMethodDescription
      abstract voidactivate​(TerminalWindow tw)
      Called when the hot spot is activated.
      protected char[]addHotSpot​(HotSpot hs, char[] line, java.util.List<HotSpot> hotSpots, int x, int width)
      Adds a new hot spot of this same class (but a new instance) to the list.
      abstract intcheck​(char[] line, java.util.List<HotSpot> hotSpots, int begin, int end)
      Checks if a hot spot is found.
      abstract booleancontinueChecking​(char[] line, char ch, int begin, int end)
      Checks if it is OK to keep on checking.
      booleanequals​(java.lang.Object o)
      Checks if one hot spot is equal to another.
      voidfillCharBackground​(java.awt.Graphics g, int xPos, int yPos, int x, int y, int cx, int cy)
      Gets the background for drawing on the screen of the hot spot.
      inthashCode()
      Gets the hash code.
      abstract voidinitialize​(java.lang.String setup, boolean active)
      Performs initialization from the setup data.
      booleanisInside​(int xPos)
      Checks if a position is inside the hot spot.
      voidonCreate​(HotSpot parent)
      Called when a new hot spot has been instantiated.
      java.util.List<HotSpot>parse​(char[] line, java.util.List<HotSpot> hotSpots)
      Performs parsing of the line just updated on the host screen.
      voidpostPaint​(java.awt.Graphics g, int xPos, int yPos, int x, int y, int cx, int cy)
      Post-painting the character of the hot spot.
      voidsetTextColor​(java.awt.Graphics g, int xPos, int yPos, int x, int y, int cx, int cy)
      Sets the color to use for the text (character) using g.setColor(nnn).
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • x

        public int x
        The X position of the line where this hot spot is located in character count.
      • width

        public int width
        The width of the hot spot in characters.
      • text

        public java.lang.String text
        The text of the hot spot, null if not yet set.
      • active

        protected boolean active
        Is this hot spot active?
    • Constructor Detail

      • HotSpot

        public HotSpot()
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Checks if one hot spot is equal to another.
        Overrides:
        equals in class java.lang.Object
        Returns:
        The equality flag not taking into account the active sstate.
      • hashCode

        public int hashCode()
        Gets the hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code.
      • initialize

        public abstract void initialize​(java.lang.String setup,
                                        boolean active)
        Performs initialization from the setup data.
      • parse

        public final java.util.List<HotSpot> parse​(char[] line,
                                                   java.util.List<HotSpot> hotSpots)
        Performs parsing of the line just updated on the host screen. If this hot spot is successful, it should clear the data with the zero character. This method returns the same "hostSpots" list if there is no change, otherwise a new list.
      • continueChecking

        public abstract boolean continueChecking​(char[] line,
                                                 char ch,
                                                 int begin,
                                                 int end)
        Checks if it is OK to keep on checking.
      • check

        public abstract int check​(char[] line,
                                  java.util.List<HotSpot> hotSpots,
                                  int begin,
                                  int end)
        Checks if a hot spot is found. If it is, the position returned should be directly after the new hot spot.
      • onCreate

        public void onCreate​(HotSpot parent)
        Called when a new hot spot has been instantiated.
      • addHotSpot

        protected char[] addHotSpot​(HotSpot hs,
                                    char[] line,
                                    java.util.List<HotSpot> hotSpots,
                                    int x,
                                    int width)
        Adds a new hot spot of this same class (but a new instance) to the list.
      • isInside

        public final boolean isInside​(int xPos)
        Checks if a position is inside the hot spot.
      • fillCharBackground

        public void fillCharBackground​(java.awt.Graphics g,
                                       int xPos,
                                       int yPos,
                                       int x,
                                       int y,
                                       int cx,
                                       int cy)
        Gets the background for drawing on the screen of the hot spot.
      • setTextColor

        public void setTextColor​(java.awt.Graphics g,
                                 int xPos,
                                 int yPos,
                                 int x,
                                 int y,
                                 int cx,
                                 int cy)
        Sets the color to use for the text (character) using g.setColor(nnn).
      • postPaint

        public void postPaint​(java.awt.Graphics g,
                              int xPos,
                              int yPos,
                              int x,
                              int y,
                              int cx,
                              int cy)
        Post-painting the character of the hot spot.
      • activate

        public abstract void activate​(TerminalWindow tw)
        Called when the hot spot is activated.