Computer Science 275.001

Interaction Programming

Fall 2006

Visual Basic

Programming Assignment #3

Due: Thursday, September 21, 2006

(Due in drop-box by 1:00 PM)

(zipped files)


 


The last of your VB2005 assignments in this course (before starting our design
programming assignments) concerns additional interface controls, including
menus and progress indicators, as well as recursion and pixel operations. The
single form in this application will display a county map of the state of Illinois
(retrieved from an external file) and allow the user to display demographics
(retrieved from a second external file) either by selecting an individual county
or by indicating that statewide information is desired. 
When the application form initially appears, the bitmap containing the state map
is displayed, as well as a simple set of instructions, as illustrated in the figure below.
The user may select an individual county by using the mouse to click
within its borders on the displayed map. A recursive algorithm (described
below) is then used to fill all of the white pixels within the selected county’s
borders with a highlight color. Once that has been accomplished, coordinate
data from another external text file is examined to determine the precise
county which was selected. With the identity of the selected county available,
the appropriate demographic data is displayed, as illustrated in the figure below. 
A menu will be provided to enable the display of a particular field of the
demographic data for the entire state (e.g., per capita income, percentage
of residents younger than 18). All county information for the specified
field will then be examined and the corresponding range of values will be
split into equal quarters. The county maps will then be filled using a
color-coded legend, as illustrated below.
Unfortunately, running the recursive fill algorithm for so many counties
(utilizing the coordinates from the second external text file) takes a minute
or two, so a progress indicator (in green at the bottom of the central figure
above) will be included to assure the user that the application is in fact still executing. 
Three particular features of this assignment merit further discussion. First, the
recursive fill algorithm merely utilizes the coordinates of the picture box’s MouseClick
event handler, e.X() and e.Y(), to determine whether the corresponding pixel color
values of a bitmap bmp (CInt(bmp.GetPixel(x,y).R()), CInt(bmp.GetPixel(x,y).G()),
CInt(bmp.GetPixel(x,y).B())) are all high enough to indicate that the user
clicked inside a county (i.e., each value should be greater than 250). If so, the
algorithm should use SetPixel to change the pixel’s color to the highlight color
and then recursively visit the pixel to the left, the pixel to the right, the pixel
below, and the pixel above the current pixel and do the same thing.
The second notable feature involves the progress indicator, which should be
set to continuously increment as each county’s quartile is determined and its
part of the bitmap is filled.
Finally, the design decision to use the left side of the form for three purposes
(displaying the instructions, displaying one county’s demographics, or displaying
the color-coded legend for statewide demographic data) may be implemented
via either VB2005’s design toolkit or coded control variables, whichever you find easier to use.

Note that this design involves the following five event handlers:

Ÿ      Loading the form – initially, the instructions are displayed, while the county-specific and statewide components are hidden. This event handler should also retrieve all external file data, storing the county data in an array of appropriately defined structures and placing the original bitmap in the picture box.

Ÿ      Performing a mouse-click on the picture box to select a particular county (as described above). If the image is clicked outside of all counties, then the form should return to its base mode (i.e., the instructions displayed and no counties highlighted).

Ÿ      Clicking on one of the four menu headers – a single event handler should cover this, with the form returning to its base mode in preparation for the possibility of a menu item being selected.

Ÿ      Clicking on one of the menu items – a single event handler should also cover all eleven of these possible events, with the text of the selected menu item determining which demographic field must be examined (i.e., range determined, quarters computed, county maps filled one by one while the progress indicator advances, and color-coded bitmap and legend displayed). Note that “Total Population” occurs under the “Race” menu header, preceded by a menu separator.

Ÿ      Clicking the exit button to terminate the application.

As always, keep your code modular and well-documented.

The image and text files that you need for this assignment are available on the department server at:

Engineering/Classes/Fall 2006/CS/CS275/Assignments/VBPA3

Note that the course information in the text file CourseListings.txt is formatted as follows: the county name; the total population; the percentage of the population under 18 years old; the percentage of the population 65 years old or older; the percentage of black, American Indian, Asian, and Hispanic residents; the percentage of residents who are high school graduates; the percentage who have bachelors degrees; the per capita income (in dollars); the percentage of the population living in poverty; and the total land area in the county (in square miles). Each of these pieces of data is on a line by itself, and the information about each pair of consecutive counties is separated by a blank line.

The coordinate information in Coordinates.txt includes the county name and the x- and y-coordinates of a particular pixel in the IllinoisCounties.bmp image that is interior to that county.

Remember that your entire project folder is due on your drop-box by 1:00 PM on Thursday, September 21, 2006.