Package hoverball

Class Hovlet

java.lang.Object
hoverball.Hovlet
Direct Known Subclasses:
Controller, Session, Team, Unit

public abstract class Hovlet
extends java.lang.Object
The class Hovlet (= "small Hoverball program") represents the base class for all programming elements that can connect to the Simulator.

Hovlets can be interlaced into each other. Each hovlet has a super-hovlet parent and a list of sub-hovlets hovlets, that can be added by the method add(...). The connectability upward and downward is to be defined in its constructor. A hovlet without super-hovlet is called root-hovlet.

The resulting hovlet trees are displayed in so-called browsers that show certain hovlets on request. The method show() opens a new browser for the full hovlet tree (unless this has already happened) which displays the initially calling hovlet. (The looks of the browser can be defined by the root-hovlet using the method browse(...).) Otherwise the hovlet is simply shown in the corresponding browser.

A Hovlet has the following properties:

  • It holds a title. See title.

  • It can define private menus which are shown in the browser beside the default menu Hovlet. See menubar.

  • It has an icon panel displayed beside the hovlet selection bar. See icon.

  • It owns a main panel which is displayed in the center of the browser and can freely be defined. You can use the paint(...)-method of the main panel, plotting by default the hovlet banner. See main.

  • It is able to indicate a status line in the browser. See status(...).

  • A hovlet must be able to connect to the Hoverball Simulator. For this, it has the methods connect(...) and disconnect() at its disposal, but the connecting itself is not yet implemented.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.awt.Color background
      Default background color for all new hovlets
      static int BANNER
      Height of the hovlet banner (in pixels)
      static java.awt.Color foreground
      Default foreground color for all new hovlets
      Hovlet[] hovlets
      Sub-hovlets
      javax.swing.JPanel icon
      Icon panel of the hovlet
      javax.swing.JPanel main
      Main panel of the hovlet
      javax.swing.JMenuBar menubar
      Menu bar of the hovlet
      Hovlet parent
      Super-hovlet (null, if root)
      java.lang.String title
      Title of the hovlet
    • Constructor Summary

      Constructors 
      Constructor Description
      Hovlet​(java.lang.String title)
      Creates an empty hovlet.
      Hovlet​(java.lang.String title, boolean upward, boolean downward)
      Creates an empty hovlet with the indicated connectabilities.
    • Method Summary

      Modifier and Type Method Description
      boolean add​(Hovlet hovlet)
      Adds a hovlet to this hovlet.
      void browse​(javax.swing.JInternalFrame browser)
      Alters the looks of the browser if the hovlet is the root-hovlet.
      void close()
      Closes the hovlet.
      boolean connect​(java.lang.String address)
      Connects the hovlet to the specified address.
      protected boolean connecting​(java.lang.String address)
      Void for the implementation of connecting.
      void disconnect()
      Disconnects the hovlet.
      protected void disconnecting()
      Void for the implementation of disconnecting.
      void locate​(int x, int y)
      Demands the browser position.
      void locate​(java.awt.Point location)
      Demands the browser position.
      void show()
      Shows the hovlet.
      void status​(java.lang.String status)
      Displays a text in the status line of the browser.
      java.lang.String title​(java.lang.String separator)
      Returns the title of the hovlet with its path.

      Methods inherited from class java.lang.Object

      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Details

      • background

        public static java.awt.Color background
        Default background color for all new hovlets
      • foreground

        public static java.awt.Color foreground
        Default foreground color for all new hovlets
      • public static final int BANNER
        Height of the hovlet banner (in pixels)
        See Also:
        Constant Field Values
      • parent

        public Hovlet parent
        Super-hovlet (null, if root)
      • hovlets

        public Hovlet[] hovlets
        Sub-hovlets
      • title

        public final java.lang.String title
        Title of the hovlet
      • menubar

        public final javax.swing.JMenuBar menubar
        Menu bar of the hovlet
      • icon

        public final javax.swing.JPanel icon
        Icon panel of the hovlet
      • main

        public final javax.swing.JPanel main
        Main panel of the hovlet
    • Constructor Details

      • Hovlet

        public Hovlet​(java.lang.String title)
        Creates an empty hovlet.
        Parameters:
        title - title of the hovlet
      • Hovlet

        public Hovlet​(java.lang.String title, boolean upward, boolean downward)
        Creates an empty hovlet with the indicated connectabilities.
        Parameters:
        title - title of the hovlet
        upward - connectable upward?
        downward - connectable downward?
    • Method Details

      • close

        public void close()
        Closes the hovlet.
      • title

        public java.lang.String title​(java.lang.String separator)
        Returns the title of the hovlet with its path.
        Parameters:
        separator - separating character string for the path
        Returns:
        title with path
      • add

        public boolean add​(Hovlet hovlet)
        Adds a hovlet to this hovlet.

        If the connection of the hovlets is not valid, or if one of them is already connected or displayed, connection cannot succeed.

        Parameters:
        hovlet - hovlet
        Returns:
        true, if connection succeeded false, if connection failed
      • show

        public void show()
        Shows the hovlet.

        If this is the first call of show() by all hovlets within the hovlet tree, a new browser is opened showing the hovlet. Otherwise the hovlet is simply shown.

      • status

        public void status​(java.lang.String status)
        Displays a text in the status line of the browser.

        The argument null displays the default status of the browser.

        Parameters:
        status - status
      • locate

        public void locate​(int x, int y)
        Demands the browser position.

        If the hovlet is a root-hovlet, the browser will be positioned on opening at the indicated place.

        Parameters:
        x - x-coordinate of the required browser position
        y - y-coordinate of the required browser position
      • locate

        public void locate​(java.awt.Point location)
        Demands the browser position.

        If the hovlet is a root-hovlet, the browser will be positioned on opening at the indicated place.

        Parameters:
        location - required browser position
      • browse

        public void browse​(javax.swing.JInternalFrame browser)
        Alters the looks of the browser if the hovlet is the root-hovlet.

        If a hovlet tree has to be shown in a browser, it is the root-hovlet that determines its looks by modifying the frame of the browser. The browser itself is not yet visible.

        This method is empty and can be overwritten.

        Parameters:
        browser - frame of the browser
      • connect

        public boolean connect​(java.lang.String address)
        Connects the hovlet to the specified address.
        Parameters:
        address - network address
        Returns:
        true, if connection succeeded
      • disconnect

        public void disconnect()
        Disconnects the hovlet.
      • connecting

        protected boolean connecting​(java.lang.String address)
        Void for the implementation of connecting.

        The method should return true if the connection succeeded.

        The present content of this method successively connects all sub-hovlets to the indicated address and returns true if at least one connection succeeded. If required, you can access this code by super.connecting(...)

        Parameters:
        address - network address
        Returns:
        true, if connection succeeded
      • disconnecting

        protected void disconnecting()
        Void for the implementation of disconnecting.

        The present content of this method disconnects sucessively all sub-hovlets. If required, you can access this code by super.connecting(...)