Question: Please use explanations in the code. Thank you. Make a collage The first file you will create is PSA4A.java. This file will choose a picture,

Please use explanations in the code. Thank you.

Make a collage

The first file you will create is PSA4A.java. This file will choose a picture, and copy it twice. This will allow you to have 3 copies of the picture. Then you will call a filter method on each picture. Then you will send the 3 pictures to a collage method that will put them all on one picture. You may pick any filter for two of the three methods (as long as they are two different filters). The third method must be a mirror filter, which can be found in your book. The collage method will take in all three pictures and copy them onto a canvas (blank

picture) that is the exact size of all three put together (more on that later). Overall this part of the assignment will put three filtered pictures next to each other on one picture.

Filter Methods: Two of your choosing + mirror vertically or horizontally

Add three methods to Picture.java. Each of these methods should change only its calling object (i.e. this).

Choose your favorite two filters, they can be ones that you create yourselves or ones you find in your textbook.

Your third filter should be either a horizontal or a vertical mirror image. Again, you can find these in your book (pp. 135-136).

These methods are not specified other than you must change the calling object, we are encouraging you to be creative. But note that Problem 2 of this assignment (Picture Flip) might take some more time. You will have a chance in the next assignment to take this collage and make it better. Method: collage

This method in Picture.java should take in 3 parameters. They are the pictures that will be put onto the calling object.

The method header should be: public void collage(Picture p1, Picture p2, Picture p3)

collage should have 3 sets of nested for loops.

The first loop: Outer Loop: for(sourceX = 0, targetX = 0; sourceX < pic1.getWidth(); sourceX++, targetX++) Inner Loop: for(sourceY = 0, targetY = 0; sourceY < pic1.getHeight(); sourceY++, targetY++) Inside the Loop: sourcePixel is pic1's pixel at (sourceX, sourceY). targetPixel is calling object's pixel (targetX, targetY). Change targetPixel's color to sourcePixel's color.

The other two loops are exactly the same except:

Outer Loop 2: for(sourceX = 0, targetX = pic1.getWidth(); sourceX < pic1.getWidth(); sourceX++, targetX++)

Outer Loop 3: for(sourceX = 0, targetX = 2*pic1.getWidth(); sourceX < pic1.getWidth(); sourceX++, targetX++)

o Use FileChooser.pickAFile() to pick a file and create a Picture object based on that file.

PSA4 Is below:

/* Filename: PSA4A.java

*

* Description: This class is designed to...

*

*/

public class PSA4A

{

//The line below is magic, you don't have to understand it (yet)

public static void main (String[] args)

{

// Add your code for PSA4A here and then delete this comment

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!