II. Requirements Req1. When the program initially loads, it should have the following appearance. 900 TCSS 305 Assignmen
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
II. Requirements Req1. When the program initially loads, it should have the following appearance. 900 TCSS 305 Assignmen
Req2.1. The file selection dialog should open in the current directory as shown below (use relative addressing). Req2.2. If the user later pushes the "Open" or "Save As..." button again, it should open the same folder where the file chooser was left previously Req2.3. If the user cancels the file chooser, the contents of the window should be left unchanged Req.3. When the user selects a file, the system shall load the image data contained in that file and displays that image in the center of the window. Note that, the window resizes to exactly fit the image and buttons, if the image is too large, this may make some of the buttons appear outside the screen area. This is expected behavior, and you do not need to handle it in any special way Haty Req3.1. When an image is loaded, all buttons shall become enabled (as shown on the next page). Req3.2. Your window shall be resizable. As the window is resized, any loaded image shall remain centered both horizontally and vertically. Ever Comp Req4. Clicking each filter button shall cause a modification of the image: flipping, sharpening, softening, etc. Req.4.1. These operations do not modify the original image file, they just change the onscreen appearance. Req5. Applying more than one filter to an image shall have a cumulative effect. Req6. If the user chooses a file that does not contain valid image data, the program shall display an error message dialog (as shown on the next page). The selectie de contain a pe 1 stad file
special way Ma Shpelepipe H Req3.1. When an image is loaded, all buttons shall become enabled (as shown on the next page). Req3.2. Your window shall be resizable. As the window is resized, any loaded image shall remain centered both horizontally and vertically. Req4. Clicking each filter button shall cause a modification of the image: flipping, sharpening, softening, etc. Req.4.1. These operations do not modify the original image file, they just change the onscreen appearance. Req5. Applying more than one filter to an image shall have a cumulative effect. Req6. If the user chooses a file that does not contain valid image data, the program shall display an error message dialog (as shown on the next page). The an Req6.1. The message should also display the name of the selected file. " Req7. If the "button is used while an image is already open, a new image may be selected, and it shall replace the displayed current image. Only one image can be open and displayed for editing at a time. Open. Req.8. If the user chooses "close Image", the displayed image shall close, all buttons shall disable except the "open. "button, and the GUI shall resize to its initial size and appearance. Req.9. When the GUI window is closed by clicking the window's close icon, the application shall terminate and exit. Page
III. Implementation Guidelines: 1. You will write a class named SnapShopGUI in the gui package that contains the implementation of your graphical user interface. You may also write additional helper classes, if you find it necessary. Your class may extend JFrame, but this is not required (if you do not extend Frame, you will have to store a 3Frame as an instance field). Do one or the other, but not both 2. The constructor to your class must require no parameters, and must not display the GUI on the screen; instead, your class must contain a method named start() that performs all necessary work to create and show the GUI on the screen Note that this does not mean that all the work should be performed in the start() method itself, the start() method should call other methods to create various parts of the user interface (buttons, panels), set up event handlers, etc. Note that the main method in the SnapshopGUI class calls the GUI constructor and then calls start(). 3. You do not need to write your own code to apply different types of transformation filters on the currently displayed image. Do this by using the instructor-provided filter classes. Note that a single filter object can (and should) be used multiple times; you must not create more than one of each type of filter object. 4. You should use all three options in implementing your action listeners: Lambda Expressions; inner classes, and regular classes (implementing interfaces) and (ie., actionPerformed()) methods. In other words, you should show at least one implementation case for each option in your code. Among them the lambda expressions are more compact and precise, and will increase the readability of your code. 5. As you may guess you may need to implement equals, hashCode, tostring, compareTo, and compare methods for some classes to make them testable and reach the target test coverage level since your JUnit tests will require comparing of some objects. Page
Page remod resent the INDIG UPHE uns does not mean that on the work should be performed in the star start() method should call other methods to create various parts of the user interface (buttons, panels), set up event handlers, etc. Note that the main method in the SnapShopGUT class calls the GUI constructor and then calls start(). 3. You do not need to write your own code to apply different types of transformation filters on the currently displayed image. Do this by using the instructor-provided filter classes. Note that a single filter object can (and should) be used multiple times; you must not create more than one of each type of filter object. 4. You should use all three options in implementing your action listeners: Lambda Expressions; inner classes; and regular classes (implementing interfaces) and (ie., actionPerformed()) methods. In other words, you should show at least one implementation case for each option in your code. Among them the lambda expressions are more compact and precise, and will increase the readability of your code. 5. As you may guess you may need to implement equals, hashCode, tostring, compareTo, and compare methods for some classes to make them testable and reach the target test coverage level since your JUnit tests will require comparing of some objects. 6. Verification & Testing of Your Application. (OPTIONAL/BONUS) You have already seen an example test plan in HW#07 and completed and followed the given plan to write your JUnit 5 tests for the application you had developed. Prepare a similar test plan to test your implementation in this assignment and write your JUnit 5 tests based on this plan. The required (or target) JUnit 5 test coverage for the SnapShopGUI class is 30%. Note that your test plan should include appropriate tests for all the methods of the SnapShopGUI class that you are asked to implement in the above sections. BONUS PART: The required test coverage for the SnapShopGUI class is 30%. For each 5% you go above it, you will earn an extra point.
7. The following UML Class Diagram gives a summary of the supplied transformation filter classes in the project folder and their relationships. The SnapShopGUI is constructed by the SnapShopMain class. The GUI uses various filters (implementing the Filter interface) to filter the PixelImages that are composed of Pixels. Default SnapShopMain interface) napshop Rers Filter napshop for EdgeDetect EdgeDelofel ] min e.) Deccaphon) Vinapshop guk SnapShop Canapshop.lters FiVerticale snapshop likers Abstract This is the class you my deabled buton my tex Flovenica Abbacitet will write. snapchop fillers GrayscaleFiter actor Pedomed 1 SnapShopGULJ sta Gunca) canapshop.filters: WeightedFilter snapshop.image Pixelmage Med WegeedFan napshop.filters FipHorizontalier oneData d lood FigHacontaffet savel... PaData] canapshop fillers: Sharpeel der Sharpen anapshop filters Sollenfilter #Sattered snapshop image Pixel MAX COLOR VALUE IN MIN COLOR VALUE NUM CHANNELS anapshop fillers EdgeHighlightFiter Edgeghym ber E gerent pefied Pak P Blue selGreen) selfied 8. Provided Files: The following classes and interfaces are provided for your use. You must not modify these files when writing your program - unless you have a strong rationale for doing that. Note that the provided classes have other methods beyond what is listed, but the listed methods are all you need. Page <
Page < snapshop fillers Sharpen Re napshop Fillers Sollend der Shop Sobert1 canapshop ters EdgeHighlightFiles EdgeHighligFe() I gett F# Pack. Paol Bluet seGreent selfied 8. Provided Files: The following classes and interfaces are provided for your use. You must not modify these files when writing your program- unless you have a strong rationale for doing that. Note that the provided classes have other methods beyond what is listed, but the listed methods are all you need Interface Filter: public interface Filter ( Applies this filter to the given image. public void filter (Pixelimage the Image); Seturns & text description of this filter, such as "Edge Highlight". public String getDescription(); The following classes implement the Filter interface. All have a no-argument constructor. public class EdgeDetectFilter implements Filter public class EdgeHighlightPilter implemente Filter public class FlipHorizontalFilter implements Filter public class FlipVerticalFilter implements Filter save PeDati nagshop.image: Pael MAX COLOR VALUE MIN COLOR VALUE NUM CHANNELS pent onfed
public class GrayscalePilter implements Filter public class Sharpenfilter implements Filter public class Softenfilter implements Filter Class Pixel: public class Pixel public Pixel() constructs a black pixel public Pixel (int theRed, int theGreen, int theBlue) // RGB values, 0-255 public int getRed (), getGreen (), getBlue () public void setRed (int theRed), setGreen (int theGreen), setBlue (int theBlue) Class PixelImage: public class Pixelimage ( // Loads an image from the given tile and returns it. Throwa an exception Lt the file cannot be read, public static PixelImage load (File thefile) throws IOException // Saves this image to the given file. Throws an exception if the file cannot be written. public void save (File the File) throws IOException Methods to get and set the 20 grad of pixels that comprise this image.. The first dimension is the rowa (v), the second is the columns (x)... public Pixel[] [] getPixelData() public void setPixelData (Pixel [] [] the Data) Class SnapshopMain: Page <
Loads an image from the given file and returns is. 77 Throws an exception if the file cannot be read. public static PixelImage load (File theFile) throws IOException VYSaves this image to the gives tile. // Throws an exception if the file cannot be written. public void save (File the file) throws IOException Vy Hethods to get and set the 20 grid of pixels that comprise this image. The first dimension in the rowe (y), the second la the columna (x). public Pixel [] [] getPixelData() public void setPixelData (Pixel [] [] theData) public class SnapShopMain ( Runa your program by constructing a SnapshopGUI object. You must write the SnapShopGUI class. public static void main (String... theArgs) IV. Implementation Hints 1. Display an image on the GUI by setting it to be the icon of an onscreen JLabel. A JLabel's icon is set by calling its setIcon method. The setIcon method accepts an ImageIcon object as a parameter. An ImageIcon object can be constructed by passing a Pixel Image as the parameter. Note that you should not create a new label every time you change the image, but instead should change the icon of the label you already have) Here is an example that creates a new label and sets its icon: Class SnapshopMain: Page <
Page PixelImage image PixelImage.load(new File("apple.jpg")); JLabel label = new JLabel(); label.setIcon (new ImageIcon (image)); 2. Use a Jihooaer for your file selection dialog. A save dialog can be shown by calling showSaveDialog object, and an open dialog can be shown by calling ahowOpenDialog. You can ask for the file the user selected by calling the e method on the rilechooser. on a Note that your program should create only one eileChooser object and reuse it repeatedly. 3. If image loading fails, catch the IOException and use a Joptioneane to display an error message dialog like the one shown above. 4. When an image is selected and loaded, call the pack method on your rame to make it resize itself to fit the image and buttons. If the image is too large, pack may make your window larger than the screen; and that is acceptable. (We won't test the program with images that are that large.) After packing the rame, set a minimum so that it cannot be resized too small to display the size on the came equal to the current size of the image or the buttons. 5. Try to design and implement an efficient way of creating filter objects and their corresponding buttons. Ideally, it should take you exactly one line of code to create each filter and its corresponding button and the button's er(So seven such lines of code for the seven filter button/listener combinations.) The goal here is to make it possible to easily add (or remove) a filter and its corresponding button without making changes to other parts of the project code. 6. Included with the project are some image files that you can use for testing. VI. Submission and Grading: 1. Create your Eclipse project by downloading the pa#02-username-snapshop.zip file from Canvas, importing it into your workspace. Make sure that when we unzip the file, we should get the folder named pa 02-username-snapshot.
size on the came equal to the current size of the rane so that it cannot be resized too small to display the image or the buttons. 5. Try to design and implement an efficient way of creating filter objects and their corresponding buttons. Ideally, it should take you exactly one line of code to create each filter and its corresponding button and the button's (So seven such lines of code for the seven filter/button/listener combinations.) The goal here is to make it possible to easily add (or remove) a filter and its corresponding button without making changes to other parts of the project code. 6. Included with the project are some image files that you can use for testing VI. Submission and Grading: 1. Create your Eclipse project by downloading the pat02-username-snapshop.zip file from Canvas, importing it into your workspace. Make sure that when we unzip the file, we should get the folder named pa#02-username-snapshot. Note that each file that you submit should have a prefix of pa#02-username in order to easily differentiate it from others submissions. 2 Mark the code segments that satisfies the given requirements clearly in your code with an appropriate comment that includes the requirements number (e.g. //#Req1.2 is implemented below/here.) 3 (SUBMISSION A) You must submit the following items at least 2 days before your code submission as part of Submission A ● your project (1.e., assignment) plan ● the proposed technical solution your unit test plan . 4. (SUBMISSION B) Page <
Page You must zip your IntelliJ IDEA project, including all configuration files and all images/icons that were supplied with it (even if you have not changed them from the ones that were distributed) and upload onto Canvas We should be able to import it into IntelliJ IDEA and run your application directly. . Submit a requirements traceability matrix based on the following template to show the completion/validation status of each requirement: Realmen Real Res Mothe NL3 766k ne 10e 12 e 15 Reas Resh Res Line 11 plementation of requireme Validation of requ 15 indicates the starting line number of the relevant code t Nation was comple implementation of the requirement was validated pleted On the validation of the requirement was party indicates that the implementation not completed OR the validation of the requirement was t 5 Part of your program's score will come from ● External correctness: For this assignment, external correctness is measured by the output generated (correct calculations, correct behavior, correct GUIs, completeness of the implementation of the requirements as described, etc.), and can be determined manually or by running automated tests on your code by the instructor. ● Internal correctness: Internal correctness includes meaningful and systematically assigned identifier names, proper encapsulation, avoidance of redundancy, good choices of data representation, the use of comments on particularly complex code sections, and the inclusion of JavaDoc headers on your classes. Internal correctness also includes whether your source code follows the stylistic guidelines. This includes t criteria such as the presence of Javadoc comments on every method and field (even the private ones!), . the use of variable names, spacing, indentation, and bracket placement specified in the class coding standard, and . (optional*) the absence of certain common coding errors that can be detected by the IntelliJ Analyze Code tool. intoral correctness also includes avoidance of redundancy, because it is easy for GUI code to the filter buttons). In particular, Line 105