December 21, 2006 12:07 PM

Wrapping Up the Semester

Well, the exams are all graded and final grades are submitted. I enjoyed this semester; I hope you did, too. Media computation was a fun way to learn about computation more generally, and a little about programming in Java, and a little bit about computer science. I hope that during those times when the course got tough you still felt like your hard work was worth it, that you were learning something interesting and valuable. At times this semester I may have sounded like a cheerleader, but I really do mean all I said about computer science -- it is a discipline that is at the edge of forward progress in every other discipline; it is redefining our lives as we live them; it is creating new possibilities for expression and for doing.

Good luck in CS II or wherever next semester finds you. I'd love to hear from you as you continue your studies at the university.

And please do stop by to pick up your final exam. Those things take up a lot of space in my file drawer!


Posted by Eugene Wallingford | Permalink | Categories: General

December 07, 2006 4:53 PM

Session 28

Today we wrapped up the course.

We looked at an images page generator and then extended it to post real thumbnails produced by our own Picture class.

Then I closed the circle on the course by demonstrating a very simple steganography program, implemented using a Picture class augmented with hide() and recover() methods. This code is far from bulletproof (hide() can create an RGB value out of the range 0..255, and recover() tries to read from pixels that do not hide text), but it shows the idea well -- and serves as a great place for you to jump off on your own programming fun!

I closed with a short presentation of some key Big Ideas from the course this semester. Media computation is a useful end in its own right, but we also saw many of the most important ideas from CS, including representation, algorithm, and layers of abstraction.

Here are the slides I used today, along with a script of some of my Dr. Java interactions.

Our next time together is the final exam, at 3:00 PM next Thursday, December 14. It will cover material from both midterms and a bit of Chapter 13 that didn't make it onto Exam 2. Same format, somewhat longer (but nowhere near twice as long, though you'll have twice as much time).

Homework 8, is due Saturday afternoon. Though I'll be out of town most of tomorrow and all day Saturday, I will be within e-mail reach, so feel free to send your q$a.uestions Electronic submission only, no print-out required.


Posted by Eugene Wallingford | Permalink | Categories: Sessions

December 05, 2006 2:42 PM

Session 27

Today was a day of review. We listened to some wonderfully doctored voices from Homework 5. Then we looked at Exam 2. The scores were much lower than I expected, which means that I almost certainly misjudged what we had prepared you to do well. Don't worry too much about those low scores -- I will take the results from Exam 2 into account when I assign grades at the end of the semester. Finally, we closed our review by looking at Homework 7, especially some very cool images produced by you all with your graphics interpreters. My discussion of the solutions focused on how we can use helper methods to make our interpreter more flexible. If the code for drawing circles and squares is implemented in separate methods, then we can call them as a part of other helper methods. The result can be some rather interesting commands that are implemented in terms of simpler commands!

I planned to show you a web page generator for an images thumbnails page, but I managed to delete it before getting to class. Then I couldn't find it. That's how the day went... Of course, upon returning to my office, I found it: ImagePageGenerator.java. Take a look at it before next class. Run it, using the path to your mediasources directory, and see the web page it generates right into your mediasources directory. Here is the index.html that the program generated for my mediasources directory.

The ending of the day was perfect: In what was either the stupidest move of my teaching career or a sign of great boldness and confidence -- and trust in you -- I closed this session with stduent evaluations. I doubt you'll encounter many other professors who will return an exam with an average grade of 43% and do student evals the same day!

Here are the slides I used today when discussing the exam questions. Study those questions and solutions!

For next time, read Section 13.3 and study the images-page generator class. And don't forget Homework 8, which is due Saturday afternoon. Yes, Saturday afternoon -- electronic submission only, no print-out required.


Posted by Eugene Wallingford | Permalink | Categories: Sessions

December 02, 2006 9:36 AM

Homework 8: Generating a Web Page of Your Own Design

Extend our PageGenerator class to generate a web page of your personal design. Your generator must add at least two new features to the page. Here are some possible features you might add:

  • Read a headline from a favorite news site, such as Reddit, Sports Illustrated, or ABC, and display it on your page. Use the same sort of "scavenger hunt" as I did to locate the day's cartoon on the FoxTrot home page.
  • Display a list or table of all the sound files in a directory, as links that the user can follow to play the sound. (You can use a standard <A HREF=""></A> tag for the link.)
  • Add thumbnails of all or some subset of the images in a given directory, with links to the full image.

If you have ideas of other features that you would like to add, just ask!!

Additionally, you may also modify the existing methods of the generator to rearrange the page, change its presentation, etc. (Such changes won't count toward your assigned quota of two unless they are substantial and I approve them as such in advance.)

This assignment is worth 20 points.

Extra Credit Opportunities

Add more than two new features... (2 points)

Any other ideas?

Deliverables

By the 4:00 PM on Saturday, December 9, submit a zip file of a directory that contains these files:

  • PageGenerator.java
  • two different web pages generated by your program, from two different days
  • a short write-up of your additions to the generator
following the submission instructions for the course.

For this assignment, you do not need to submit a printout. We will grade from the electronic submission alone.


Posted by Eugene Wallingford | Permalink | Categories: Homework

November 30, 2006 2:10 PM

Session 26

Today we turned our string and file skills to a practical media computation task: the generation of a web page. The pages we create are "dynamic" in the sense that they rely on content that changes: the comic strip on a web page out on the web, and a randomly-selected quote from a file of quotes.

You can download all the material from class -- sample web pages, the Java programs, and the quotes file we used -- in this .zip file.

For next time, read Chapter 13 and study the PageGenerator class. And don't forget Homework 7, which is due tomorrow afternoon. You can bring the print-out to 305 ITT, the department office, any time. If I'm in, you can bring it on back; otherwise, the secretary will put it in my mailbox.


Posted by Eugene Wallingford | Permalink | Categories: Sessions

November 28, 2006 1:01 PM

Session 25

The main event today was our second exam. We spent the first few minutes learning how to create a double-clickable application (with a custom icon, no less!) for a Java program. We used our FoxTrotDownloader from last session as our demonstration program. You can follow along with the discussion on this tutorial page.

In class on Thursday, we will begin our discussion of generating web pages to complement our image and sound files. Be sure to read the first half of Chapter 13 to prepare.

Don't forget that Homework 7 is due on Friday afternoon. We will have one more assignment this semester, running from this Friday to the last day of classes.


Posted by Eugene Wallingford | Permalink | Categories: Sessions

November 21, 2006 2:42 PM

Homework 7: Drawing Pictures from a Simple Language

Write a class named GraphicsInterpreter that reads a sequence of graphics commands from a text file. The class should have a method named interpret that

  • takes a filename as input,
  • reads the commands contained in the file, and
  • returns a Picture on which the commands have been executed.

The method should create a blank 640x480 picture on which to drwa.

There are at least three kinds of commands:

  • line x1 y1 x2 y2

    The line command draws a straight line. For example, "line 10 20 300 400" draws a line from (10, 20) to (300, 400).

  • circle x y d

    The circle command draws, yes, a circle. For example, "circle 100 200 50" draws a circle whose center point is (100, 200) and whose radius is 50.

  • a command of your own design! It can draw a figure, write, text, ....

This assignment is worth 20 points.

You can use this main method for your class:

     public static void main( String[] args )
     {
       GraphicsInterpreter artist = new GraphicsInterpreter();
       String filename = FileChooser.getMediaPath( "commands.txt" );
       Picture p = artist.interpret( filename );
       p.show();
     }

Extra Credit Opportunities

Make it so that we can initialize a GraphicsInterpreter with a particular picture. If the object is created with a picture, then it draws on the given picture. If not, it uses a blank canvas. (1 point)

Create a commands.txt file that produces a picture that does something useful. For example, I could imagine a sequence of commands that create a poster to advertise a meeting. (1 point)

Deliverables

By the 4:00 PM on Friday, December 1, submit a zip file of a directory that contains these files:

  • GraphicsInterpreter.java
  • two different files that test your class, one named commands.txt
  • a Picture created by your program from commands.txt
following the submission instructions for the course.

For this assignment, you need to submit only one printout -- GraphicsInterpreter.java.


Posted by Eugene Wallingford | Permalink | Categories: Homework

November 21, 2006 2:39 PM

Session 24 -- Files and Objects

Being the last day before our second midterm, and the last day before a well-deserved break from classes, we mostly wrapped up some details today. We explored reading text files, and saw that the process bears a similarity to writing text files. We fiddled a bit more with strings and e-mail addresses, too.

Here are the slides (PDF) I used and a sanitized script of some of our Dr. Java interactions. We produced several classes: Student, StudentReader, and ProspectReader.

For a little bonus, I offered a program that reads not text, but an image, and not from a file, but from a URL! I don't expect you to be able to write this kind of code, especially the method that reads and writes the image. But you should be able to see some familiar structure in the code. If you want to have fun with web sites of your own choice, then do! Here is my FoxTrotDownloader.

For next time, prepare for the exam. It will focus on material since the last exam through Chapter 12 of the textbook.

Homework 7 will be posted in a matter of minutes!


Posted by Eugene Wallingford | Permalink | Categories: Sessions

November 16, 2006 2:10 PM

Session 23

Today, students laughed at me for being old. But I don't feel too bad. I am just glad that you all know how to make .zip files!

We expanded on our Die class example from last time to create a PowerBallEntry class. Why write a lot of code in a main() when we can create an object with that behavior? In Computer Science II, you will learn that there are great reasons to put all of your behavior in objects! For now, we see just one: it is a lot easier to reuse the behavior when we can create an object that does it.

From there, we ran one last test, to demonstrate just how hard it is to pick a winner in Powerball... Run EasyWinner -- but don't be in a hurry; it will probably take a while.

Finally, we began to explore splitting strings using a Student class. We left an open question: emailDomain() works for "@cs.uni.edu" but not "@gmail.com". Your job: fix it!

Here are the slides (PDF) I used and a script of some of our Dr. Java interactions.

For next time, start reading Chapter 13 of the textbook. Our second midterm exam will be Tuesday, November 28 -- a week from our next session, and the class day after Thanksgiving. Homework 7 will be posted next session.


Posted by Eugene Wallingford | Permalink | Categories: Sessions

November 14, 2006 4:18 PM

Session 22

Today, we extended our Die class to produce a sequence of unique values. Along the way, I hope we learned a bit about designing a method to perform a task with several layers of complexity.

We then revisited a method for DiffSound that writes the object to a file. It exposed many of the elements of writing files in Java -- which we will soon do much of, when generating web pages!

Here are the slides (PDF) I used and a script of some of our Dr. Java interactions. In addition to the Die and DiffSound classes, we also produced a simple program to mirror a String.

For next time, finish reading Chapter 12 of the textbook.

Note 1. Our second midterm exam will be Tuesday, November 28 -- the first class day after Thnaksgiving.

Note 2. Your next homework assignment is due next time.


Posted by Eugene Wallingford | Permalink | Categories: Sessions

November 09, 2006 3:01 PM

Homework 6: Creating a Simple Slideshow Program

Quick Overview

Your task this week is to write your first new class, one that represents simple slideshow objects. A slideshow consists of a collection of pictures to display and a collection of sounds to play. In the simplest form of slideshow, your program will play one sound file for each picture it displays.

Details, Details

  • Create a class named Slideshow and save it to a file named Slideshow.java.
  • A Slideshow keeps track of an array of Pictures and an array of Sounds. The class should have a constructor that lets users pass two arrays when creating a new Slideshow object.
  • Slideshow should have a method named show() that plays the slideshow. It should display each picture in its array, one at a time.
  • While a picture is showing, your object should play the corresponding sound file. In order to stop your program from proceeding while the sound is playing, be sure to use the blockingPlay() method of the Sound.
  • To display the pictures, start with an empty "canvas", a blank picture into which you can copy each of the images. After copying the image to display onto the canvase, ask the canvas to repaint.
  • You could use a large canvas, so that it is big enough to hold all of the images. If you do this, you could copy each pisture into the upper lefthand corner of the canvas or (better!) into the center of the canvas.
  • Alternatively, you could use a canvas of some convenient fixed size, say, a square of 800x800 or a rectangle of 640x480. If you do this, you should scale the picture to be displayed, making it either larger or smaller. To do this, you can use the scaling code from class or textbook.
  • Your class should have a main() method that creates a slideshow and shows it.
  • Use helper methods whereever you think appropriate to make your code easier to write, read, or understand.
  • Your function must retrieve the image files it uses from the directory specified by the media path. To do this you must use getMediaPath(). You must not use setMediaPath() or pickAFile() in your solution.
  • Your Slideshow.show() will use the show() and repaint() methods from the Picture class.

How We Will Grade Your Assignment

This assignment is worth 20 points.

We will...

  1. ... retrieve your submission from the submission system.
  2. ... put your Slideshow, Picture, and Sound classes into the bookClasses directory and all of your images and sounds into another folder.
  3. ... set the media path to the folder containing your images, using setMediaPath().
  4. ... open your Slideshow class in Dr. Java and compile it.
  5. ... execute your Slideshow class's main() method.
  6. ... watch your demonstration slideshow.
  7. ... use your Slideshow class to create and show a slideshow using our own images and sounds.

Extra Credit Opportunities

None yet. But I will appreciate demonstration slideshows that tell a nice story!

I am also inclined to consider extra credit for a slideshow that offers a second way to display a slideshow, where each sound is accompanied by multiple pictures, say, four pictures shown during a longer sound clip. A simple version of this would have n > 1 pictures for each sound, and each picture is shown for sound.length/n samples. If you want to give this a try, contact me!

Deliverables

By the 8:00 AM on Thursday, November 16, submit these files:

  • Slideshow.java
  • Picture.java
  • Sound.java
  • all of the images and sounds you use to in your demo slideshow
following the submission instructions for the course.

For this assignment, you need to submit only one printout -- Slideshow.java. You do not need to submit printouts of Picture.java or Sound.java (or of your images and sounds) -- but you must submit them all electronically.

You must submit your Picture and Sound classes, even if they don't contain any methods other than the original versions from your CD. This way, we don't have to worry about problems with different versions of those classes.


Posted by Eugene Wallingford | Permalink | Categories: Homework

November 09, 2006 2:58 PM

Session 21

Today, we learned some new Java (Random) and wrote another class (Die). Along the way, discussed class features and class design. By the time we reached our final version of Die, we had created a useful and flexible kind of object and a main() method that exercises it. We learned why and how to write a main() method.

We then moved on to the idea of a file. Along the way, we looked at the idea of javadoc and generated javadoc for our DiffSound and Sound files -- check out the result. Take a look at the javadoc for the Random class at the Java 1.4.2 javadoc site; you can find Random by scrolling down to java.util and finding it on that page, or click on All Classes link at the top of the page and scroll down to Random. The javadoc we generated for DiffSound and Sound looks just the same as Sun's!

Next time, we will look at files in more detail and start to generate text files for use on the web. We may even see Elvis Presley and George Carlin again!

Here are the slides (PDF) I used and a script of some of our Dr. Java interactions, including some material we didn't quite reach today. We'll use them next time. In addition to the Die class, we also just began to look at a new DiffSound class that knows how to write itself to a file.

For next time, finish reading Chapter 12 of the textbook.

Note 1. Recall that we pushed our first exam back one week, which means that we will want to pushd our second exam back a week, too. Exam 2 was originally scheduled for next Tuesday, November 14. We will not have the exam then; it will not happen until (at least) Tuesday, November 21.

Note 2. Your next homework assignment will be posted within a few minutes. Really!


Posted by Eugene Wallingford | Permalink | Categories: Sessions

November 07, 2006 2:33 PM

Session 20

Today, we spent a little more time discussing encoding and compression. We developed code that demonstrates how pixels are often represented, using a single int to encode three integer values in the range [0..255]. Then we implemented a decompress() method for our DiffSound objects and found that our compression is lossy but results in spoken sounds that can be understood.

Here are the slides (PDF) I used and a script of some of our Dr. Java interactions, and the files we produced:

  • a Pixel class that knows how to encode and decode itself,
  • a DiffSound class that now knows how to decompress itself, replete with javadoc comments, and
  • a version of Sound that compresses sounds more faithfully.

You can check out the javadoc generated automatically from the comments in Sound and DiffSound. We'll look at that briefly at the top of our next session.

For next time, begin reading Chapter 12 of the textbook. And watch for your next homework assignment -- I plan to post it no later than tomorrow morning bright and early!


Posted by Eugene Wallingford | Permalink | Categories: Sessions

November 02, 2006 3:10 PM

Session 19

Today, we returned manipulated sounds, but we did not play them. Instead, we did processed sounds as big arrays of sample values. We focused on how to store a bosy of data in less space, which is known as compression. We wrote our own algorithm for compressing sounds and then created a new kind of object to represent our encoding: DiffSound.

Here are the slides (PDF) I used and a script of some of our Dr. Java interactions, and the files we produced:

Read Chapter 10 of the textbook for our next session. I should have your next homework assignment ready by then.


Posted by Eugene Wallingford | Permalink | Categories: Sessions

October 31, 2006 2:14 PM

Session 18

Welcome back! Oh, wait, I am the one who returned. It's good to see you all again.

Today, we returned to playing with sounds, especially the additive behavior of sounds waves. Adding sound samples arbitrarily doesn't do much for us, but using variations on the theme leads to interesting effects, like blending, chording, and echoes.

Here are the slides (PDF) I used and a script of some of our Dr. Java interactions, and the Sound.java file that we produced.

I didn't tell you much about my week at OOPSLA, today, but we will have an opportunity to discuss some of my activities next week, when we step back from images and sounds to talk about our programs at a higher level.

As is now our pattern, please take a pair of headphones with you to the lab tomorrow, if you have them.

Finish reading Chapter 10 of the textbook for our next session. Your next homework assignment won't come out until then.


Posted by Eugene Wallingford | Permalink | Categories: Sessions