Class Controller
public final class Controller extends Hovlet
Among the Controller's functions are counted:
Please refer to the Hoverball Manual for a more detailed description.
Moreover, the Controller has the important duty to display the Graphical Debugging of the Java units that have registered at it by the command debug(...) The debugging can be enabled/disabled via the Controller's menu Debug for a single unit, or by clicking on the units' hovlet icons. See also hoverball.debug.Debug.
There is a human KeyListener installed on screen. All human units (of the same Java instance) are controllable when the screen is active. The colors of sphere and background can be changed by the screen methods setForeground(...) und setBackground(...).
The Controller is executable as an integrated hovlet or as a stand-alone hovlet, but no sub-hovlet can be added.
The class Controller can also be run as an application:
java hoverball.Controller [host][:port][#hash]
-
Field Summary
Fields Modifier and Type Field Description javax.swing.JInternalFrame
frame
Controller's frame (if stand-alone)javax.swing.JInternalFrame
viewer
Frame of the Hoverball screen.Fields inherited from class hoverball.Hovlet
background, BANNER, foreground, hovlets, icon, main, menubar, parent, title
-
Constructor Summary
Constructors Constructor Description Controller()
Opens a Controller.Controller(boolean shortcuts)
Opens a Controller and enables or disables the screen shortcuts -
Method Summary
Modifier and Type Method Description void
browse(javax.swing.JInternalFrame frame)
[Implementation]void
close()
Closes the Controller.boolean
complete()
Returns if the game has finished ("Complete").protected boolean
connecting(java.lang.String server)
[Implementation]void
debug(Team team)
Deletes all units of a team from the registration of Graphical Debugging.void
debug(Team team, boolean debug)
Registers all units of a team for Graphical Debugging.void
debug(Unit unit)
Deletes a unit from the registration of Graphical Debugging.void
debug(Unit unit, boolean debug)
Registers a unit for Graphical Debugging.protected void
disconnecting()
[Implementation]void
follow(Team team, int n)
Follows a ball on screen (follow mode).void
follow(Unit unit)
Follows a unit on screen (follow mode).boolean
fullscreen()
Returns if full screen mode.void
fullscreen(boolean fullscreen)
Turns full screen on or off.java.lang.String
get(java.lang.String key)
Returns the value of a Simulator variable.static void
main(java.lang.String[] args)
Executes the Controller (application!).double
option(java.lang.String key)
Returns the value of a Hoverball option.void
set(java.lang.String key, double value)
Sets a Simulator variable.void
set(java.lang.String key, java.lang.String value)
Sets a Simulator variable.int
state()
Returns the connected Simulator's state.void
state(int state)
Changes the connected Simulator's state.void
style(boolean antialiasing)
Sets the display style.double
time()
Returns the game time in the Simulator.void
view(int memory)
Sends a view from a memory cell.void
view(int memory, java.lang.String pucks)
Saves a view.void
zoom(double zoom)
Zooms the screen.
-
Field Details
-
Constructor Details
-
Controller
public Controller()Opens a Controller. -
Controller
public Controller(boolean shortcuts)Opens a Controller and enables or disables the screen shortcuts
-
-
Method Details
-
main
public static void main(java.lang.String[] args)Executes the Controller (application!). -
close
public void close()Closes the Controller. -
browse
public void browse(javax.swing.JInternalFrame frame)[Implementation] -
style
public void style(boolean antialiasing)Sets the display style.- Parameters:
antialiasing
- true for antialiasing
-
fullscreen
public void fullscreen(boolean fullscreen)Turns full screen on or off.- Parameters:
fullscreen
- true for full screen
-
fullscreen
public boolean fullscreen()Returns if full screen mode.- Returns:
- true if full screen
-
view
public void view(int memory, java.lang.String pucks)Saves a view.A view contains all information about a snapshot of a Hoverball game. Admittedly, the objects of a view are only characterized by their
(what t n)
-identification. In case of altered channels the view gets another meaning. Thus the use of this method only makes sense if you are sure that the same units always connect to the Simulator in the same order. This is true for a Hoverball session on a local host.The part of a
(view...)
-message concerning the pucks has to be transmitted as a string conforming to the Control Client to Server protocol. Hence it is not possible to define time or score by this command.Hint: Such a string is easy to create at run time: The menu View > Copy to Clipboard copies the necessary string for the current view into the system clipboard, so that afterwards it can be inserted in the programming code.
The argument
null
deletes the view from the memory cell.- Parameters:
memory
- memory cellpucks
- part of a(view...)
-message concerning the pucks
-
view
public void view(int memory)Sends a view from a memory cell.- Parameters:
memory
- memory cell
-
follow
Follows a unit on screen (follow mode).If
unit
has the valuenull
, the follow mode gets disabled.- Parameters:
unit
- unit
-
follow
Follows a ball on screen (follow mode).If
team
has the valuenull
the shot ball is followed, otherwise the team ball of the indicated team.The ball numbers are counted starting with 1.
- Parameters:
team
- team of the ball (null
= shot ball)n
- ball number
-
zoom
public void zoom(double zoom)Zooms the screen.- Parameters:
zoom
- zoom factor.
-
debug
Registers all units of a team for Graphical Debugging.If
debug
equalstrue
, the graphical output of this team is initially enabled.- Parameters:
team
- teamdebug
- graphical output enabled?
-
debug
Deletes all units of a team from the registration of Graphical Debugging.- Parameters:
team
- team
-
debug
Registers a unit for Graphical Debugging.If
debug
equalstrue
, the graphical output of this unit is initially enabled.- Parameters:
unit
- unitdebug
- graphical output enabled?
-
debug
Deletes a unit from the registration of Graphical Debugging.- Parameters:
unit
- unit
-
set
public void set(java.lang.String key, java.lang.String value)Sets a Simulator variable.If
value
equalsnull
the variable is deleted.- Parameters:
key
- Simulator variablevalue
- value
-
set
public void set(java.lang.String key, double value)Sets a Simulator variable.The
double
value is converted into astring
.- Parameters:
key
- Simulator variablevalue
- value
-
get
public java.lang.String get(java.lang.String key)Returns the value of a Simulator variable.- Parameters:
key
- Simulator variable- Returns:
- the value
-
option
public double option(java.lang.String key)Returns the value of a Hoverball option.If
key
is a Simulator variable but no option, it returns 0.- Parameters:
key
- Hoverball option- Returns:
- the value
-
state
public void state(int state)Changes the connected Simulator's state.- Parameters:
state
- new state
-
state
public int state()Returns the connected Simulator's state.- Returns:
- state
-
time
public double time()Returns the game time in the Simulator.- Returns:
- time
-
complete
public boolean complete()Returns if the game has finished ("Complete").- Returns:
- complete
-
connecting
protected final boolean connecting(java.lang.String server)[Implementation]- Overrides:
connecting
in classHovlet
- Parameters:
server
- network address- Returns:
true
, if connection succeeded
-
disconnecting
protected final void disconnecting()[Implementation]- Overrides:
disconnecting
in classHovlet
-