JavaFX Scoreboard v1.0 README
How to Run the Application
The Organization of the Souce Code
A Little more Detail on the
archive contains the source code required to build an electronic
scoreboard. It is written in Java utilizing the JavaFX
2.x API, and is packaged as a NetBeans
project. The type of scoreboard chosen for this
implementation pertains to ice hockey. With an
understanding of the overall organization and structure of the
code, it should be straightforward to extend scoreboard
functionality to include other sports.
At start up, the scoreboard
executes in one of two modes: as a master (the default), or as a slave. In master mode, the
scoreboard user interface is active. When a user moves
his/her pointing device over an editable part of the
scoreboard (a scoreboard digit), that component will, via
JavaFX animation, increase in size. This provides the
user a visual cue about what component is in focus. By
either clicking on the focused digit, or by utilizing
keyboard input, the user can change the value of the focused
digit. Each time a scoreboard digit is modified, an
XML packet is created describing the modification, and sent
out over an IP socket.
or remote scoreboard
mode, the scoreboard UI is inactive. That is to say,
it will not respond to any mouse or keyboard input.
Its display can only be updated by listening in on an
agreed-upon IP socket (configurable by command-line switch)
for XML scoreboard update packets. Upon receiving
those packets, the remote scoreboard instance will parse the
XML data and change the scoreboard display
accordingly. To start up a scoreboard in slave mode,
use the -slave command-line switch. It is
possible (and desirable) to have multiple slave scoreboards
simultaneously receiving updates from one master scoreboard.
How to Run the Application
The easiest way to run the scoreboard in either slave
or master mode is to utilize the pre-built Main
classes provided in the scoreboard.fx2 package
directory. Here's a partial list of those classes and
To see how a master scoreboard can
update a slave scoreboard, just start up the first of these two
main classes, Main and MainRemote on the same
- Main.java - This will run the scoreboard in the
default (master) mode and open up an IP socket on the default
host (localhost) and port (2011). All scoreboard updates
will be sent over that defined socket.
- MainRemote.java - This will run an instance of a
slave or remote scoreboard. It will open up and listen in
on the default host (localhost) and port (2011) IP Socket. As
XML updates are received over the IP socket, the scoreboard
display will change accordingly.
The following main classes
demonstate different remote scoreboard clients
- MainRemoteClockOnly.java - It is possible to
configure a slave or remote client to display only a subset of
the master scoreboard's components. This remote or slave
instance of the scoreboard displays only the clock and listens
in on the default IP socket host and port.
- MainRemoteLED.java - The scoreboard source is
architected in such a way that with minimal work, an alternate
implementation of the look and feel can be implemented. In
this example, a remote scoreboard display has digits with an LED
segment look and feel. This display will listen in on the
default IP socket host and port.
The following main classes use
multicast sockets rather than IP sockets. In general, using multicast sockets
is not recommended as experience has shown, they tend to be
filtered out by all sorts of networking equipment.
- MainMulticast.java - Similar to Main.java,
this instance instead uses a default multicast socket and port
to communicate rather than a standard IP socket.
- MainMulticastRemote.java - The multicast socket
alternative to MainRemote.java.
By running any of the main classes found in the scoreboard.fx2
package directory with the -help or --help
argument, the following description of command-line switches is
displayed to standard output. As we progress through this
document, the meaining of certain options will become more evident:
-ConfigURL:URL (default: scoreboard/config/config.xml in Scoreboard.jar)
URL pointing to XML file describing remote client configuration
Show socket connection info at bottom of scoreboard display
-DumpConfig:[true or false] (default false)
Dump layout of scoreboard in XML (for client customization)
-help or --help
Print this screen for command-line argument options and exit
-host:IP_ADDRESS (default: localhost)
Specify IP Address of socket
Run as a scoreboard controller (server)
-MulticastAddr:IP_ADDRESS (default: 220.127.116.11)
Use multicast socket and specify its IP address
-port:PORT_NUMBER (default 2011)
Specify port for socket connection
Run as a remote scoreboard client
Run in full screen mode for a TV (with padding for overscan)
-unlitOpacity:[0-100] (default 10)
Change opacity of unlit scoreboard bulbs
Use IP sockets (with defaults) for scoreboard updates
Use multicast sockets (with defaults) for scoreboard updates
Organization of the Source Code
Here's a list of the relevant packages, and a brief description of
- scoreboard.common - Contains the constants,
interfaces and enums that are used throughout the source code
- scoreboard.common.networking - Contains common
networking code primarily related to IP and Multicast socket
communication. Nearly all of these classes are abstract,
and need to be implemented for a specific runtime platform (e.g.
Swing vs. JavaFx). For this version of the source, JavaFX
implementations are found in the scoreboard.fx2.networking
package described below.
- scoreboard.common.xml - Classes related to the XML
processing for this application. In particular, the XMLSpec.java
file found in this package defines, in java, the XML rules for
scoreboard update and configuration.
- scoreboard.config - Used to house sample XML
configuration files describing remote scoreboard layout and
configuration. There is no Java source in this directory.
- scoreboard.fx2 - This is where the various main Java
class files are located as described in the How to Run the Application section of
- scoreboard.fx2.framework - The heart of the
Scorebaord source code, this is where a great deal of the logic
for the scoreboard is contained. Many, but not all, of the
Java classes found in this package are abstract, and need to be
extended in order to create a real scoreboard
implementation. In particular, the look and feel of
scoreboard digits must be defined. Two such implementations
exist for this version of the code. They can be found in
the scoreboard.fx2.impl.bulb and scoreboard.fx2.impl.led
packages that follow.
- scoreboard.fx2.impl.bulb - In this implementation,
each scoreboard digit is comprised of 27 light bulbs that are
turned on and off to display the various numeric values.
It is meant to look like traditional light bulb based
- scoreboard.fx2.impl.led - The scoreboard digits for
this implementation, are comprised of 7 LED segments that are
turned on and off to display various numeric values.
- scoreboard.fx2.networking - This package contains the
JavaFX implementation of the abstract classes found in the scoreboard.common.networking
package. The reason for the abstraction layer here has to
do with the fact that UI platforms (like Swing and JavaFX)
require that work be done on the main thread. Each
platform achieves this in a slightly different way. In
JavaFX, the Platform.runLater() method has to be
utilized, while Swing, for example, requires use of the SwingUtilities.invokeLater()
- scoreboard.fx2.util - Contains trivial utility class
specific to JavaFX
A Little More
Detail On the scoreboard.fx2.framework Package
The figure below represents a class hierarchy diagram of the
- The abstract classes found in scoreboard.fx2.framework
- of which most are directly or indirectly derived from the
JavaFX base Parent class. In order to create an
alternate scoreboard implementation, the following lowest level
abstract classes must be extended: Digit, SingleDigit,
TwoDigit, Penalty, Clock and HockeyScoreboard.
The last class, HockeyScoreboard, could be replaced
with another abstract class (e.g. BasketballScoreboard)
that has a different look and behavior.
- The implementation classes found in scoreboard.fx2.impl.bulb
- These are the emboldend classes named with a "Bulb" prefix,
found at the bottom of the diagram. They represent the
classes used to implement scoreboard digits with a light bulb
look and feel.
- The implementation classes found in scoreboard.fx2.impl.led
- These are the emboldend classes named with an "LED" prefix,
found at the bottom of the diagram. They represent the
classes used to implement scoreboard digits with an LED segment
look and feel.
- There is some keyboard input support for this version of the
application. For example, the user can press the
<SPACE> bar to toggle starting and stopping the
clock. Additionally, the user can use the left and right
arrow keys to switch focus between digits of the same
- This source was derived originally from a project written in
the now defunct JavaFX Script. At the time of the
original writing, JavaFX Script was still in its early stages
and the work on layout managers was still in a state of
flux. Hence, the decision was made not to use any JavaFX
LayoutManager and instead rely on absolute coordinate
positioning of scoreboard components. The JavaFX 2.x
version of the Scoreboard application that exists here still
has those constraints. The unfortunate consequences are
that a lot of tedious positioning and sizing of components
must take place.
- There are two sets of defined XML attributes used for this
application. One is used to describe and configure the layout
of a remote (slave) scoreboard client, where an informal
description of the specification can be found in the scoreboard.config.ConfigXMLSpec.xml
file. As referenced above, no JavaFX LayoutManager was used,
so some very primitive layout semantics are part of this
spec. The second set of XML attributes describe what a
scoreboard update looks like. A sample of possible
scoreboard update attributes can be found at scoreboard.config.UpdateXMLSpec.xml.
- The scoreboard.images directory/package contains
JPEG images of scoreboard digits. Not used for this
version of the source, the images could be used to
implement yet another version of the scoreboard that simply
displays an image associated with a digit value. A old
version of this application originally written in JavaFX
Script has an implementation with images, because it was much
faster than the rendered bulb and LED components. With
JavaFX 2.x, performance is much improved and the need for
image based displays was no longer needed.
- The scoreboard.util.sounds directory/package MP3
file representing a buzzer sound that could be used to sound a
horn either manually or automatically when the clock reaches
zero. The horn hs not been fully implemented for this
version of the scoreboard.