TWiki
>
CS111 Web
>
CS111Fall2013
>
CodeF13
>
AssignmentsF13
>
Lab06f13
(2013-10-07, Main.troy)
(raw view)
E
dit
A
ttach
---+++ CS 111 - Program Design I ---+++ <a name="Lab_6"></a> Lab 6 ---+++ <a name="Lab_Assignment"></a> <a name="Lab_Assignment"></a> Lab Assignment Due: Tuesday 10/8/2013 by 11:59 pm For this lab assignment, complete the following: 1 Prompt the user for an picture and open that picture. 1 Once the picture has been opened, add a simple text message to the bottom left side of the picture. 1 Diplay the picture. 1 Then prompt the user for a filename to save the modified picture and save the picture in that file. You should use the *pickAFile()* method from the <a target="_top" href="http://www.cs.uic.edu/%7Ei101/doc/FileChooser.html">FileChooser</a> class to prompt the user for the picture and for the filename to same the modified image. To add the text message, use the <a target="_top" href="http://www2.cs.uic.edu/%7Ei101/doc/SimplePicture.html#addMessage%28java.lang.String,%20int,%20int%29"> addMessage ()</a> method of the Picture class. This method takes 3 parameters: 1 *message* - The text message to the added to the picture. 1 *xpos* - the pixel position of the left side of the string 1 *ypos* - the pixel position of the bottom of the string We want the text to be on the bottom left side of the picture. Let us put it 20 pixels over from the left edge of the the picture and 20 pixels above the bottom edge of the picture. The *xpos* value is simple, that will be 20. However, we must calculate the *ypos* value. Fortunately, the <a target="_top" href="http://www2.cs.uic.edu/%7Ei101/doc/Picture.html">Picture</a> class has a method <a target="_top" href="http://www2.cs.uic.edu/%7Ei101/doc/SimplePicture.html#getWidth%28%29"> getWidth()</a> method and a <a target="_top" href="http://www2.cs.uic.edu/%7Ei101/doc/SimplePicture.html#getHeight%28%29"> getHeight()</a> method. Each of these return the distance in pixels across the width (which is the X direction) or the height (which is the Y direction) of the picture. The coordinate position of (0,0) is in the upper left corner of the picture. Thus to calculate the value for the *ypos* for the addMessage() method, we need to subtract 20 from the height of the picture. The message that you put in the picture can really be anything you want. If you can't think of anything interesting, just put "CS 111 - Lab 6" followed by your name. This sort of idea is normally used to add a caption to a picture or to add a copyright statement. Note: you should only be adding copyright statements to pictures that you took/created yourself. To display the picture, you can use either the show () method or the explore () method from the Picture class. To save the picture, you can use pickAFile () to prompt the user for a filename. Then use the write () methodfrom the Picture class. The following is an example a before and after picture: <img alt="" src="http://www.cs.uic.edu/~i101/labs/africaFromSpace.gif" /> <img alt="" src="http://www.cs.uic.edu/~i101/labs/africaFromSpaceLab6.gif" /> 1 Be sure to change comment with the name of the author to contain the following: * your name * your NET-ID * day and time of your CS 111 lab section (i.e. Friday at 9:00) * A description of the project. ---+++ <a name="How_assignments_should_be_submit"></a> <a name="How_assignments_should_be_submit"></a> How assignments should be submitted You are also to submit the Java file electronically via the Assignment link in Blackboard for this lab. You are to name your file with the lab number and your netID. Please only submit source code file (the *.java* file, not the *.class* file nor the *.java~* file). -- Main.troy - 2013-10-04
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r2 - 2013-10-07 - 18:11:21 - Main.troy
CS111
Web Page Spr 18
Syllabus Spr 18
Lecture Notes Spr 18
Sample Code Spr 18
Assignments Spr 18
[edit this menu
]
Log In
CS 111 Main Page
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
ABOUT US
Our Department
Recent News
Contact Us
ACADEMICS
Prospective Students
Undergraduate
CS Minor
Graduate
Courses
RESEARCH
Overview
By Faculty
Labs
PEOPLE
Faculty
Adjuncts
Staff
Students
Alumni
Copyright 2016 The Board of Trustees
of the University of Illinois.
webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF