<< Chapter < Page Chapter >> Page >
Learn how to use shapes to clip images during the drawing process.

Revised: Mon Apr 04 10:32:52 CDT 2016

This page is included in the following Books:

Table of contents


This module is one of a series of modules designed to teach you about Object-Oriented Programming (OOP) using Java.

The program described in this module requires the use of the Guzdial-Ericson multimedia class library. You will find download, installation, and usageinstructions for the library at Java OOP: The Guzdial-Ericson Multimedia Class Library .

Viewing tip

I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the Figures and Listings while you are reading about them.



  • Listing 1 . The driver class named Prob04.
  • Listing 2 . Beginning of the class named Prob04Runner.
  • Listing 3 . Clip the picture and display your name.
  • Listing 4 . The method named clipToEllipse.
  • Listing 5 . Complete program listing.


In this module, you will learn how to use shapes to clip images during the drawing process.

Program specifications

Write a program named Prob04 that uses the class definition shown in Listing 1 and Ericson's media library along with the image file named Prob04a.jpg (see Figure 1 ) to produce the graphic output images shown in Figure 2 and Figure 3 . Don't forget to display your name in the output image as shown.

Figure 1 - Input file named Prob04a.jpg.

Image of a beach scene

Figure 2 - First output image.

First output image

Figure 3 - Second output image.

Second output image shows the first output image clipped by an ellipse.

New classes

You may define new classes as necessary to cause your program to behave as required, but you may not modify the class definition for the class named Prob04 shown in Listing 1 .

Rotate, mirror, and clip

The program rotates a Picture object by 35 degrees with no scaling. Then it does a four-way mirror on the rotated picture. Finally, itclips the image to an elliptical format as shown in Figure 3 .

Required output text

In addition to the two output images shown above, your program must display your name and the other line of text shown in Figure 4 .

Figure 4 - Required text output.
Display your name here. Picture, filename None height 404 width 425

Discussion and sample code

Will discuss in fragments

I will discuss and explain this program in fragments. A complete listing of the program is provided in Listing 5 near the end of the module.

The driver class named Prob04

The driver class containing the main method is shown in Listing 1 .

Listing 1 - The driver class named Prob04.
public class Prob04{ public static void main(String[]args){ new Prob04Runner().run();}//end main method }//end class Prob04

If you have been studying the earlier modules in this collection, no explanation of Listing 1 should be required.

Questions & Answers

what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
yes that's correct
I think
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
how nano science is used for hydrophobicity
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
what is differents between GO and RGO?
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?