PICS User Interface Demo Code in Java

Design and Architecture


A Parser is necessary to read and contruct corresponding data structures from application/pics-service machine-readable as defined in PICS specification.

At the lowest level, StreamTokenizer from java.io is used to tokenize the inputstream. PICSTokenizer is a wrapper around StreamTokenizer, providing high-level PICS-specific parsing services. It is used by Service, Category, Enum, Filter and Range. For example, StreamTokenizer.checkVersion() verifies the version number of the pics-service to be 1.0 or 1.1; StreamTokenizer.nextPair(String,int) reads the value of a pair in parentheses.

Service has a constructor with a single parameter of Inputstream. A PICSTokenizer is constructed from the Inputstream, which is not used again. Service, with the help of PICSTokenizer, parses the pics-service according to the PICS specification, gathering information of rating-system, rating-service and so on. In the process, intances of Category are created, recursively if necessary.

Category optionally contains instances of Enum, which represents a single labeled value.

Service, Category and Enum are the core data structures to represent and manipulate pics-service machine-readable.

Filter and Range have similar constructors to parse filter descriptions.

The parsing action can be reversed by calling toString() in these objects.

User Interface

The java.awt package is used to create the user interface. The UI is dynamically generated from the objects Service, Category, Enum , Filter and Range, which are contructed from an inputstream.

There are two options for displaying labeled values. The default is list, which has the advantage of showing a variable number of label values in a fixed area. However, the user can choose to display labeld values with checkboxes, which is more intuitive and convenient to use.

Gridlayout is used to partition the main window for the categories. There is a description area at the bottom of the window. Scrollable panel is the most complicated part of the user interfaces. Since the windows size is fixed, the windows will not be able to fit all the necessary interface widgets if there are too many categories. Scrollable panel is implemented to let the user scroll through the categories. Cardlayout is used instead of dynamic generation in order to improve the smoothness of scrolling.

Notes on Filters

The basic structure of the Filter is similar to that of Label. There're two main differences. There are two styles for setting the fitering action of labeled values. In the default mode, there is an 'allow' checkbox and a 'block' checkbox with each labeled values. The program prevents the user from checking both checkboxes. Pressing the key 'enter' will set all the smaller-value checkboxes to allow and all the larger-value checkboxes to block. The user can also choose to display the labled values as single radioboxes, where check represents allow and uncheck represents block. A mouse click will check all smaller-value checkboxes and uncheck all larger-value checkboxes. The second difference is the user interfaces for inputing ranges.

Ching Law
Created: 1 July, 1996
Last updated: 1 September, 1996