Here's the scenario: you've been asked to prepare to write
a class called ImageCollection. To do this, you'll want to explore
Squeak for the different tools you might be able to use to implement the
services ImageCollection is supposed to provide. You won't
be writing any new code during this lab (after all, we DID just have
a midterm...). For each section below, you'll be finding a relevant
method in Squeak that either you could use directly to provide the
service or you could modify to provide the service. When you find these
methods, you'll copy and paste them into a Workspace window. At the end
of the lab, you'll copy and turn in the entire contents of your
Workspace. The lab is due before class on Thursday.
For this part, you need to locate a method that pops up a
dialog box to ask the user a question and read a response. This happens
in several places in Squeak, so it should be pretty easy to find. When
you find this method being called somewhere, copy the entire method you
found it in and paste it into your Workspace.
Hint: This pop-up window is similar to the window you'll
see when you select "add new file" from the File List browser. The
File List browser an instance of class FileList. There are several
other places you can find this type of window - go hunting!
For this part, you need to locate a method that will provide
a progress bar while some operation is being performed. You may think
there won't be any single method to do this, but recall that you've seen
these progress bars in several places (when you fileIn code, for example)
- Squeak comes with more ready-to-use tools (toys?) than you think! When
you find this method, copy the calling method and add it to your
Workspace.
Hint: In general, when you're looking for something to
accomplish a particular task in Squeak, a good idea is to start with
where you've seen that task being accomplished before. Remember that
Squeak is written in itself, and OOP stresses code reuse!
For this part, you need to locate a method to which you can
provide a filename and which gives you back a suitable object. When you
find this method, copy its selector to your Workspace (note this is
different from the previous two parts - here you're trying just to find
the method to use, rather than find an example of its use
somewhere in Squeak).
Hint: Well, you're dealing with images, and you
need to find a method that will read them. That ought to be
enough information...
For this part, you need to locate a method to which you can
provide:
Hint: Actions like the one you would need to perform in
displayImage:withTitle: are frequently found in class methods.
Look for example categories.
The Why
In this lab you'll learn more about the Squeak Smalltalk programming
system. You'll become great friends with the System Browser and hopefully
become a little more comfortable working with both Squeak and Smalltalk.
The difficult thing about learning Squeak is that the progamming
environment seems so "huge" - there's so much stuff
to learn about and learn how to use. What you'll come to realize is
this difficult thing is actually Squeak's biggest asset - there's so much
stuff to learn about and learn how to use! In very rough terms,
more stuff = more power = more things you can do with
Squeak, once you learn your way around. This lab should get you off to a
good start.
The How (at least part of it...)
There is a tutorial on how to find information in Smalltalk at
http://pbl.cc.gatech.edu/cs2390/469.html.
Browse through this FAQ and do some sample of your own. For example,
after reading the FAQ you should be able to find the answers to questions
like these:
Note: you do not need to answers these questions for the lab, although
(especially in the case of Squeak!) practice does make perfect.
The What
Armed with your new knowledge, you're going to embark on a great quest:
finding some gems in Squeak. The FAQ linked above and your experience in
the first 3 labs should give you all the knowledge you need to accomplish
your mission.
Part 0
Since you've been doing lots of different things in Squeak since the
beginning of the quarter, and everything in your Workspace window gets
saved when you save your image, let's open a new Workspace window for you
to paste the code you find into. Left-click on the Squeak desktop and
choose open...Workspace. You may want to click on the titlebar and
rename this new Workspace so that you can tell it apart from your
original one.
Part 1
ImageCollection loads a collection of images and will display one on
command. The first method you would have to write is loadImages.
loadImages will need to get some input from the user; for
example, the user would need to tell ImageCollection how many images it
should read. To do this, a window is displayed with an appropriate label
(i.e. "How many images will be read?").
Part 2
Once loadImages has the information it needs, it should actually
load the images. Since images can be large and the entire reading
operation might take a while, ImageBlaster should display a progress bar
while it loads the images. The progress bar should increment by 1 for
each image that ImageBlaster reads.
Part 3
In order to display an image, Squeak has to retrieve the image from the
file system and store it internally somehow. This means that Squeak must
have some way to read in an image, given a filename, and return some
object that is an internal representation of that image.
Part 4
Assuming that the images are stored somewhere in ImageCollector, the user
will ask to display an image using the displayImage:withTitle:
method. This method needs to display the image in a window with a
titlebar, given the object that represents the image (you'll figure out
what this object is when you solve Part 3). Squeak has made so many
things easy for us so far - maybe you can get this accomplished too
without too much trouble.
and which will display the image in a window with an appropriate title.
When you find this method, copy its selector to your Workspace.
General Hints:
It will take some hunting to find the answers, and some may take several
minutes if you are unlucky. Read the FAQ thoroughly because it will
provide you with many clues on how to find things. Most widgets are
started up by class methods, such make sure you look at both instance and
class methods. Some classes override methods found in superclasses. Make
sure you look at a classes' superclass; read the FAQ for easy ways to do
this.Turnin
Same as always
Questions/comments/concerns to your TA or
Rodney