Assignment Two - Research School of Computer Science

Australian National University
College of Eng. and Comp. Science
Research School of Computer Science
COMP6700
Assignment 2
Motion Picture Titles
Due 11:59pm EST on Saturday, May 30, 2015
Total mark: 15
Abstract
The second assignment requires you to complete an unfinished program which uses the JavaFX API to create a
simple graphic simulation. It will include effects of transition and animation (when the graphics scene changes
with time), and control elements which allow to select, play, pause, reverse and clear the transition during
the program execution (menu, buttons, check box). It will also require formatting (of a text which will be
read from a file) to make a plainly formatted text to look like a poetry verses. Together, these represent first,
second and third tasks of the assignment. The first two are to done with the use of JavaFX API, while the last
one is a general programming problem which involves design and implementation of a simple algorithm. Two
small bonus parts are also included to enhance visual effect of the program and make it more versatile.
This assignment covers most of the topics we discuss in Blocks 1–5. The completion of the project require a
substantial self-study of how to program a rich graphic application using JavaFX API (references are provided).
The estimated effort is 12-14 hours of work including studying relevant APIs.
Introduction
This program will create a simple graphic simulation of the opening “text crawl” in the sci-fi series Star Wars
(and also its parodies made as three hour-long off-shoots in the Family Guy cartoon series 1 ). The effect of
the crawls is in the rolling text which enters the screen at the bottom and recedes into the space. The original
program only demonstrates the technique of displaying a short text (crawl’s title, subtitle and prefix), and
the effect of translating and transforming it to create an illusion of moving and receding. Your task is to
implement the “rolling text” effect for the whole content of the crawl which is either formatted into verses
or should be formatted beforehand. The effect should resemble the actual movie opening (see [3] YouTube
video, or conduct the web search to find and watch other episodes and simulations (yes, this kind of problem
has been popular in programming pursuits); use the search key “star wars crawl”).
1
Family Guy is notorious for its irreverent, totally politically incorrect humour. If this kind of comedy is offensive to you, I apologise.
1
Background: JavaFX: controls, layout, css-styling, graphics and effects
JavaFX is a rich set of classes to create a multi-windowed application which can display a set of graphically
rich control elements, shapes and complex dynamics of changing and moving. We discuss the basic aspects of
graphics programming, the use of widgets to control graphical user interface, and the creation and manipulation of rich graphics in an application in Block-5 of lectures. You should study the lecture slides of the Block-5
and the JavaFX examples. More references are provided at the end.
JavaFX API (plus SDK tools including the Scene Builder program) can be used to create:
• an application layout as a collection of containers and control elements
• a programmed response to signal which a user can generated using control elements
• enhanced visual appearance of the user interface with css-files
• various “dynamic” effects when the graphical shapes and other components change their properties
(colours, size, form, position etc) continuously in the course of application run
• 3D graphic with basic (but not too sophisticated like in, eg, OpenGL) object manipulation
Different parts (javafx sub-packages) of the API are used in the above programming aspects; you should
familiarise yourself with the JavaFX API structure, and study basic examples of how they are used from the
JavaFX Tutorial.
What is already done?
The starting point for your work is a program consisting of the following classes and an fxml-file:
1. ass2.StarWarsCrawler – the main class which is also javafx.applicaton.Application class (every
JavaFX application must contain one); it creates the scene and displays and transform (move and change
size) a text object. The control is achieved via a simple key-press event handler (the upper-arrow key)
which causes the text shape to move upwards and reduce its size thus producing the effect of the crawl.
A part of your task is to replace this simple control mechanism with a continuous time crawl effect. This
class also needs to include the control elements (menu and a few buttons) to allow the user select a
crawl text, start and pause the crawl, reverse it, and clear the scene.
2. ass2.Controller.java — the automatically generated (currently empty) class; you may ignore and
leave it unchanged unless you decide to use fxml-based layout (in which case all the control elements
will be declared in the view.CrawlView.fxml layout file, normally generated by the tools like Scene
2
Builder). It is not the assignment requirement to use fxml-based approach (since we do not have
necessary time to discuss this aspect of JavaFX programming in detail).
3. crawlreader.CrawlReader — the model part of the program (in the Model-View-Controller architecture sense); it allows the client program (the ass2.StarWarsCrawler class) read the crawl text and
reformat it (if it is not formatted originally) in a form of verses to fit the crawl screen display. The
method ass2.crawlreader.CrawlReader.makeVerses() which performs this (re-)formatting is not
implemented yet.
To facilitate the code use (in an IDE-neutral way), I provide a Makefile to simplify the compilation, execution,
and also generation of documentation (using javadoc tool). The Makefile use is explained in the README
file. The ass2.propereties file and a number of files which contain the crawl texts are also provided since
they are required by the program. You will not need the Makefile if you decide (and you should!) to use
an IDE, but, please, do not change the package declarations (for the existing classes) when you extend the
program.
The Tasks
You are asked to implement the following effects:
1. (warming up) Add a 20 or 30 small star-like objects to the black sky background; make the distribution
in size and location random; choose your own colours and dimensions.
2. Transition and Animation (the crawl effect) — at the start, make the program display the prefix (“A long
time ago, in a galaxy far, far away....”) which fades-in, stays in full intensity for a few seconds, and then
fades-out; choose the large font size, proprtional to the screen dimensions. Then make the program
to run the crawl, emulating the well known effect (see, for example,[3]); the crawl text has to be in a
“canonical” versed form.
3. Control elements — add the following menu and button controls to manipulate the program execution:
• Episode-menu which allows to choose a crawl text from the available episodes (including the
parodies); the texts are contained in the correspondingly named files in the directory resources;
in the “Apprentice” mode (see below), the application should choose the crawl file which contains
the text already formatted in verses. Later, when you implement the “Master” mode and switch the
application into it by checking the control box Master, the menu selection must result in choosing
the file with unformatted text, which will be first formatted by the model (see below), and only
then fed into the view to crawl.
• Four horizontally aligned buttons: Play, Pause, Reverse and Clear which have control effect
consistent with their names.
• Master check box which allows to switch the mode from “Apprentice” (unchecked) to “Master”
(checked). When the program in the “Apprentice” mode, it can properly display the crawl text if it
originally was formatted as verses already; these formatted crawls are in the files resources/StarWars-1.txt
and so on. In “Apprentice” mode, the program will open one of these files when a menu selection is
made. If you switch into the “Master” mode, the program can take the unformatted crawl, convert
it into verses and the display as the moving crawl. The plain (unformatted) crawl text files are
resources/StarWars-1_nonversed.txt and so on; it is these files which the program must open
when the corresponding menu selection is made.
4. Text reformatting (to get the verses-like form if the original crawl text was not formatted). This is done
when the method ass2.crawlreader.CrawlReader.makeVerses is implemented. Your should call this
method and give the actual parameters values which will result in formatting the verses like they are in
the “versed” version AND produce the all-equal-line-length feature (absent in the “versed” files) by using
two or more white-spaces instead of one (see the video [3] and the picture above). This even-length
feature should be the “master stroke”; if you will not implemented it, your mark will be one point less
than the maximum.
5. Frills bonus: as another animation effect, implement the effect of twinkling stars which you have created
and placed on the sky.
3
6. “Dynamic” menu: make the program first read the contents of the resources directory and identify all
crawl text files (counting versed and non-versed versions of the same episode as one, of course) in it,
and then create the menu item controls in the Episode menu. With such feature, your program will be
able (without code modification and recompiling) to display crawls from the newly added episodes 2 .
The suggested look of the controls and their layout can be seen on the two pictured below. You are free to use
a different style and geometric arrangement.
The Marking Guide
The marks will be awarded in accordance with the following scheme:
1. 1 point — for randomly added stars (not too many);
2. 1 point — for fade-in/fade-out prefix display;
3. 2 points — for adding functioning Episode menu which (whence an episode is selected) starts rolling
the crawl;
4. 3 points — for making an animated crawl from the first line to the last disappearing into infinity (“like
in the movie”);
5. 3 points for adding functioning control buttons (as shown) above and making the Play, Stop and Clear
work as naturally expected;
6. 2 points for making the Reverse control button work as naturally expected;
7. 3 points for implementing the mode switching by adding a functioning Master check box control element (as described above) and implementing (in model) the verse formatting method ass2.crawlreader.makeVerses
and using it (in the main class) before feeding the crawl to display; the mark will not exceed 2 points if
the even-length-line feature of the verse formatting will be left out;
Bonus 1 point — for adding (correctly) programmed Episode menu items construction (as described above);
Bonus 1 point — for making the stars twinkle.
Submission: the GitLab
The project work and submission will be done via the use of a Git repository which you will create, clone,
modify (by copying the original code and adding your own) and push. The detailed instructions of how to
use Git and the project source code management and submission are explained in detail in the Lab 7. The Git
repository (and submission) will also include your homework 7 and 8.
Let me know if there are problems with submission (preferably before the deadline).
2
Like the Episode Seven currently in production (God help us!).
4
Last Remarks
If you notice an error (typo, poor language, ambiguity or contradiction) in this document let me know
as soon as possible, so I can correct it for everyone’s benefit.
Send an email or come and see the lecturer or your tutor for consultation if you need to discuss the assignment
and/or your work.
References
[1] JavaFX API
[2] JavaFX Tutorial
[3] (One of) the 1997 Star Wars Episode opening crawl
Alexei Khorev
version 1.0, May 3, 2015
(type corrected )version 1.1, May 17, 2015
5