Question
Ill rate you high!!! Collage : Write a program that uses at least 3 pictures to create a collage. These three pictures can each be
Ill rate you high!!!
Collage : Write a program that uses at least 3 pictures to create a collage. These three pictures can each be duplicated in the collage. Every picture should have at least one filter applied to it; you can apply more than one filter to a picture if you like.
Filter Methods: At least three methods, one of which must be unique.
Add at least one new filter method to Picture.java that does not come from the textbook. Your new method must use an if statement. (Think of the cool things you can do with if statements!) You also must say in your comment for the method whether your if statement is based on the location (coordinates) of the pixel, the color of the pixel, or both.
Method: createCollage
This method should have as many parameters as you have filtered pictures.
This method should return a picture, which is the final collage.
This method should be static. A method that is designated static means that it is a Class
method (as opposed to an object method). Class methods are not invoked on an object, but instead use the class name dot method name. For example, you may have used Math.abs() or Math.pow(). You can read more about static methods on page 326 of your textbook.
The method header will look like this (you may have more parameters if you would like):
public static
The first thing that you should do in this method is create a new picture that will be at least either 684x504 pixels (landscape) or 504x684 pixels (portrait). The 7inx95in.jpg in your mediaSources folder just happens to be 504x684 pixels so you can use that if you want. We have also provided 9x12.jpg and 12x9.jpg (on Blackboard) if you want something bigger than 7inx95in.jpg. You may use a larger picture, but if you use personal files you should consider using a photo-editing program like Picasa or Photoshop to resize them: very large pictures may cause problems with Dr. Java.
Note: you should not choose pictures of all the same size and put them side-by-side. You can choose pictures that will make it easy to put them all on one canvas, but make it interesting. There are ways of writing your for loops to design some pretty interesting and good looking pictures. Some people have written their for loops so that their pictures came out diagonal, upside down, or in interesting positions around the canvas.
Testing createCollage:
Create a file called PSA5.java in your PSA5/bookClasses folder.
In PSA5.java you will choose at least three pictures. So that your collage comes out right, you
may hard code which pictures and then include them with your submission (see instructions below). You can design your program so that it accepts any picture, but this is not necessary; just something that might be fun to experiment with.
You may show the original pictures if you want, but only after they have been filtered.
Filter each image.
Call the createCollage method and save the picture to a file named
Picname_PSA5.jpg. Your code should look similar to the following:
Picture collage = Picture.createCollage(pic1, pic2, pic3);
collage.write("./LastName1_LastName2_PSA5.jpg");
PICTURE.JAVA
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.text.*;
import java.util.*;
import java.util.List; // resolves problem with java.awt.List and java.util.List
/**
* A class that represents a picture. This class inherits from
* SimplePicture and allows the student to add functionality to
* the Picture class.
*
* Copyright Georgia Institute of Technology 2004-2005
* @author Barbara Ericson ericson@cc.gatech.edu
*/
public class Picture extends SimplePicture
{
///////////////////// constructors //////////////////////////////////
/**
* Constructor that takes no arguments
*/
public Picture ()
{
/* not needed but use it to show students the implicit call to super()
* child constructors always call a parent constructor
*/
super();
}
/**
* Constructor that takes a file name and creates the picture
* @param fileName the name of the file to create the picture from
*/
public Picture(String fileName)
{
// let the parent class handle this fileName
super(fileName);
}
/**
* Constructor that takes the width and height
* @param width the width of the desired picture
* @param height the height of the desired picture
*/
public Picture(int width, int height)
{
// let the parent class handle this width and height
super(width,height);
}
/**
* Constructor that takes a picture and creates a
* copy of that picture
*/
public Picture(Picture copyPicture)
{
// let the parent class do the copy
super(copyPicture);
}
/**
* Constructor that takes a buffered image
* @param image the buffered image to use
*/
public Picture(BufferedImage image)
{
super(image);
}
////////////////////// methods ///////////////////////////////////////
/**
* Method to return a string with information about this picture.
* @return a string with information about the picture such as fileName,
* height and width.
*/
public String toString()
{
String output = "Picture, filename " + getFileName() +
" height " + getHeight()
+ " width " + getWidth();
return output;
}
public static void main(String[] args)
{
String fileName = FileChooser.pickAFile();
Picture pictObj = new Picture(fileName);
pictObj.explore();
}
} // this } is the end of class Picture, put all new methods before this
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started