CS 161 Homework 5 - Sampler Quilt

Due Wed Mar 06 at 2:00pm

Overview

In this assignment, you will write a program that draws a picture of a particular type of quilt called a sampler quilt, which is composed of several different block types that illustrate a variety of quilting styles. You will use the java.awt graphics library to generate a drawing such as the one below:

The quilt consists of five patterns, illustrated by the first 5 patches in the top row:

  1. A "log cabin" block consisting of a nested pattern of rectangles
  2. A bullseye deisgn of concentric circles
  3. A hybrid pattern combining elements of the log cabin and the bullseye
  4. A patch with a written message
  5. A design of your choosing (indicated by a question mark in this diagram)--you are free to replace this pattern with whatever design you like

You can use whatever colors you want for these designs; hopefully your quilt will look less garish than mine! More details about how to create each of these designs are given below.

This assignment should be completed individually. You are welcome to ask for help (either from me or from your classmates), but remember the Gilligan's Island rule!

Objectives

Necessary Files

You should download and extract the BlueJ project from the Homework5.zip file. This project includes the beginnings of your Quilt class to provide an example and get you started. It also includes a README.txt file that you will need to complete.

Details

To create this program, you will be making a single Java class called Quilt. I have provided the beginnings of this class for you, so you don't need to start from scratch. In this class you will define methods to draw each patch, calling this methods from a single paint() method in order to paint a picture of the quilt. More details about the program can be found below, and an example documentation can be found at the bottom of the page.

Applets and Graphics

The Patch Grid

Log Cabin Patch

Bullseye Patch

Hybrid Patch

Text Patch

Personal Patch

Documentation & Style

Timeline

You may be thinking there is a lot to do for this assignment---and you'd be right. This is not an assignment you can just do over the weekend--get started early! Try writing a pattern each day, and then by the due date you'll be all finished!

As a basic plan of attack: try getting the pattern to just show up in the first box (with rx and ry of 0). Then see if you can adjust the parameters and have the pattern show up in ANY box. Once this works, your pattern is finished and you can move on to the next. Once you have all the patterns created, fill in the paint() method so that it draws all of the patterns on the quilt. You can then fix any remaining bugs (and maybe finalize your color scheme) before turning in the assignment.

Submitting

Be sure to complete the provided README.txt file with details about your program.

Upload the entire BlueJ project to the Hwk5 folder on the submission folder on hedwig. Make sure you upload your work to the correct folder!. This assignment is due at the start of class on Wed March 06.

Grading

This assignment will be graded on approximately the following criteria:

Documentation



Class Quilt


public class Quilt extends java.applet.Applet

An applet that draws a picture of a sampler quilt. Note that the applet should be displayed in a 500x700 window.

Author:
YOUR NAME HERE

Constructor Summary
Quilt()
          An EMPTY constructor (will not be used be directly used)
 
Method Summary
 void drawBullseyePattern(java.awt.Graphics g, int rx, int ry)
          Draws a bullseye pattern at the given coordinates
 void drawGrid(java.awt.Graphics g)
          Draws an grid on the given Graphics object
 void drawHybridPattern(java.awt.Graphics g, int rx, int ry)
          Draws a hybrid pattern at the given coordinates
 void drawLogCabinLayer(java.awt.Graphics g, int rx, int ry, int width, int height)
          Draws a layer of the log cabin at the given coordinates
 void drawLogCabinPattern(java.awt.Graphics g, int rx, int ry)
          Draws a log cabin pattern at the given coordinates
 void drawTextPattern(java.awt.Graphics g, int rx, int ry)
          Draws a hybrid pattern at the given coordinates
 void drawYOURNAMEPattern(java.awt.Graphics g, int rx, int ry)
          Draws a personal pattern at the given coordinates
 void paint(java.awt.Graphics g)
          Repaints the applet.
 

Constructor Detail

Quilt

public Quilt()
An EMPTY constructor (will not be used be directly used)

Method Detail

drawBullseyePattern

public void drawBullseyePattern(java.awt.Graphics g,
                                int rx,
                                int ry)
Draws a bullseye pattern at the given coordinates

Parameters:
g - The graphics object to draw on
rx - the relative x-origin
ry - the relative y-origin

drawGrid

public void drawGrid(java.awt.Graphics g)
Draws an grid on the given Graphics object

Parameters:
g - the Graphics object to draw on.

drawHybridPattern

public void drawHybridPattern(java.awt.Graphics g,
                              int rx,
                              int ry)
Draws a hybrid pattern at the given coordinates

Parameters:
g - The graphics object to draw on
rx - the relative x-origin
ry - the relative y-origin

drawLogCabinLayer

public void drawLogCabinLayer(java.awt.Graphics g,
                              int rx,
                              int ry,
                              int width,
                              int height)
Draws a layer of the log cabin at the given coordinates

Parameters:
g - The graphics object to draw on
rx - the relative x-origin
ry - the relative y-origin
width - the width (short side length) of the layer
height - the height (long side length) of the layer

drawLogCabinPattern

public void drawLogCabinPattern(java.awt.Graphics g,
                                int rx,
                                int ry)
Draws a log cabin pattern at the given coordinates

Parameters:
g - The graphics object to draw on
rx - the relative x-origin
ry - the relative y-origin

drawTextPattern

public void drawTextPattern(java.awt.Graphics g,
                            int rx,
                            int ry)
Draws a hybrid pattern at the given coordinates

Parameters:
g - The graphics object to draw on
rx - the relative x-origin
ry - the relative y-origin

drawYOURNAMEPattern

public void drawYOURNAMEPattern(java.awt.Graphics g,
                                int rx,
                                int ry)
Draws a personal pattern at the given coordinates

Parameters:
g - The graphics object to draw on
rx - the relative x-origin
ry - the relative y-origin

paint

public void paint(java.awt.Graphics g)
Repaints the applet. This is your "main" method for drawing.

Overrides:
paint in class java.awt.Container
Parameters:
g - the Graphics context on which the applet is painted