From bowman@cc.gatech.edu Fri Apr 9 15:31:25 1999 Date: Fri, 9 Apr 1999 15:30:18 -0400 (EDT) From: Doug Bowman To: Blair MacIntyre Subject: project writeup CS 6395 Programming Project #1 Button Palette for UNIX Commands This assignment is to build a program which will construct a small user interface based on its command line arguments. This interface will consist of one window containing a series of buttons. When pressed, each button will execute a UNIX command (as indicated by the command line arguments). The command line arguments will be parsed by a skeleton program provided for you and translated into a series of messages sent to an object. Your assignment is to write a Java class which responds to these messages in order to construct then run this interface. You should make use of the Swing user interface toolkit for this assignment. Interface Appearance You may choose to organize your interface as either a row or column of buttons. The window containing this row or column should be sized to fit the buttons requested. The exact appearance of each button is controlled by arguments to the program (and hence messages sent to your object class). The appearance may be defined by a string that is used to construct a label, or by three files providing bitmap images. In the case of the three images, the first two bitmaps control the "normal" appearance of the button. These bitmaps are the "image" and "mask" bitmaps and are used in a stencil fashion where pixels are drawn from the image bitmap at each location where the mask bitmap is black. Pixels corresponding to points where the mask bitmap is white are left untouched. The third -- "invert" -- bitmap is used to produce a highlight when the button in pressed by XORing its image over the normal image of the button. Note that in Swing buttons may have both labels and icons - for this program we will do only one or the other. Some sample icon files will be provided to you. Command Line Arguments For your reference, the arguments accepted by the skeleton program include the following: -x Specify x position of resulting window -y Specify y position of resulting window -l Give text to construct button label -i Indicate bitmap file for button image -m Indicate bitmap file for button mask -v Indicate bitmap file for button inverter -c Provide command to be executed by button Reasonable defaults should be provided for the position of the resulting interface and for the appearance of any button that has not been assigned an image bitmap or label. If multiple -l, -i, -m, and/or -v arguments are given, later arguments take precedent over earlier ones. Similarly, if no command is given for a button, pressing it should cause no action (other than the normal feedback of the button). The size of the overall interface should be adjusted to contain the specified buttons (perhaps with a small border). In addition to the buttons specified by the command line arguments, you should supply an additional button which causes the interface to exit. Message Protocol The skeleton program provided to you will parse the command line arguments listed above and translate them into a series of messages sent to an object that you create. This object should be of a subclass of the abstract Java class "button_maker" found in the file "button_maker.java". Your class should be called "my_button_maker". The methods set_x_pos() and set_y_pos() will be called zero or more times to establish the position of the overall window. For each button that is to be created, start_new_button() will be called first, followed by zero or more calls to the various set_button_*() routines used to establish the button's appearance and behavior. Once all buttons have been created, end_buttons() will be called. This will be your signal to finish constructing the interface and to invoke the toolkit main event loop in order to start processing events for the interface. Note that the set_x_pos() and set_y_pos() methods can be invoked at any time and the various set_button_*() routines for each button can come in any order, multiple times, or not at all. It is important that you create a sensible interface in all cases. To provide encapsulated access to your subclass of button_maker, you will be asked to write a constructor to serve as the interface to your code. The constructor will just create a single object of your class and return a pointer to it. The skeleton program will call this routine once ("new my_button_maker") to obtain an object of your class then send the messages outlined above to that object. Turn In Source code will need to be submitted in electronic form. Exact arrangements for this will be posted to the class newsgroup. Hints You will need to find Java/Swing classes that allow you to set up a window, place a container, create buttons with icons and labels, do the proper masking operations, and call UNIX system commands (similar to "system" in C). -- Doug Bowman, Ph.D. Candidate College of Computing, GVU Center, Georgia Tech Room 388 CRB, (404) 894-5104 bowman@cc.gatech.edu http://www.cc.gatech.edu/~bowman/