Question

In: Computer Science

Your task for this assignment is use the Java Canvas and Graphics classes to create an example of a computer generated image.

Your task for this assignment is use the Java Canvas and Graphics classes to create an example of a computer generated image. This is an opportunity for you to explore computer graphics and exercise some individual creativity. 

You should submit well-documented code, and once your program is done, create a presentation of your program. The presentation can be a PowerPoint or Word document, or something created with similar software. It could be a PDF file. 

Tell us what your prject is and how it works. Consider briefly discussing what happened in the process of exploration and design for your project? How does your code work? How did you use other features of Java, such as branching routines or loops in your work? Tell us about the thoughts behind your finished work. What influenced your work? 

Your work can be as simple or as complex as you would like, but be careful about taking on something that will be too time consuming. If you decide to work on figurative art, It might help to start with a single idea or concept, such as snowfall in the city, or along the Schuylkill. Abstract or figurative art can both be static or dynamic. Imagine how, for example, the Bedroom Window example at the end of this chapter could be subtly dynamic by havng flashing lights or twinkling stars. 

Ask me if you are not sure about something or if you run into trouble. 

Your finished image for this project should be suitable for a general audience.

Solutions

Expert Solution

GIVEN THAT:--

  • Program:

    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.EventQueue;
    import java.awt.Graphics;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    
    public class TryoutOval {
    
        public static void main(String[] args) {
            new TryoutOval();
        }
    
        public TryoutOval() {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
                    }
    
                    JFrame frame = new JFrame("Testing");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.add(new TryoutPanel(Color.RED));
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    
        public class TryoutPanel extends JPanel {
    
            private Color myColor;
    
            public TryoutPanel(Color c) {
                myColor = c;
            }
    
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(400, 400);
            }
    
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
    
                int centerX = 280;
                int centerY = 300;
    
                int radius = 50;
                int diameter = radius * 2;
    
                int x = centerX - radius;
                int y = centerY - radius;
    
                g.setColor(Color.BLACK);
                g.drawRect(x, y, diameter, diameter);
                g.drawLine(x, y, x + diameter, y + diameter);
                g.drawLine(x + diameter, y, x, y + diameter);
    
                g.setColor(myColor);
                g.drawOval(x, y, diameter, diameter);
    
                g.fillOval(centerX - 5, centerY - 5, 10, 10);
    
            }
        }
    
    }
    

    Sample output:


Related Solutions

Your task is to modify the program from the Java Arrays programming assignment to use text...
Your task is to modify the program from the Java Arrays programming assignment to use text files for input and output. I suggest you save acopy of the original before modifying the software. Your modified program should: contain a for loop to read the five test score into the array from a text data file. You will need to create and save a data file for the program to use. It should have one test score on each line of...
For this assignment, you are to use the business model canvas to create four (4) canvases...
For this assignment, you are to use the business model canvas to create four (4) canvases on different business concepts Make sure to include the following in the margins as per the video. 1)Key Trends 2) Industry Trends 3) Market Forces 4) Marco-economic forces
Your goal for this assignment is to create a wiki-style page in your Canvas Group space...
Your goal for this assignment is to create a wiki-style page in your Canvas Group space that highlights your plant's basic biology and anatomy. Use your group discussion forum this week to plan this page with your group members. Expectations for this assignment include: 1. at least one image (more is fine) that highlights what your plant looks like (actual + anatomy) 2. a written description of your plant's anatomy, highlighting the plant organ(s) of your plant that have been used by human civilization,...
Your task is to create a Java application that converts a specified amount of one currency...
Your task is to create a Java application that converts a specified amount of one currency into another currency for a user. The application must meet the following requirements: Upon execution, the application shall display a brief welcome message announcing that the user is running the currency converter application. The application shall allow a user to convert amounts between any two of the following currencies: United States Dollars (USD), British Pounds (GBP), Swiss Francs (CHF), and Indian Rupees (INR). The...
This is a programming assignment!!! Start with the Assignment3.java source code posted to Canvas. This code...
This is a programming assignment!!! Start with the Assignment3.java source code posted to Canvas. This code outputs the programmer’s name , prompts the user to enter two numbers (integers) and outputs their sum. Note: When you run the program, it expects you to enter two integer values (a counting or whole number like 1, 216, -35, or 0) Make the following changes/additions to the code: On line 11, change the String myName from “your full name goes here!!!” to your...
Use Java GUI create following: Task 1: A basic UI with a button and a TextField,...
Use Java GUI create following: Task 1: A basic UI with a button and a TextField, when you press the button, set the button text to the current text field contents. Task 2: set the text field text to the mouse coordinates when that same button is pushed.
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes each in its own file Student.java, StudentList.java, and Assign5Test.java. Copy your code from Assignment 4 into the Student.java and StudentList.java Classes. Assign5Test.java should contain the main method. Modify StudentList.java to use an ArrayList instead of an array. You can find the basics of ArrayList here: https://www.w3schools.com/java/java_arraylist.asp In StudentList.java, create two new public methods: The addStudent method should have one parameter of type Student and...
Assignment Task Java Object Orientated GUI CQ Real Estate (CQRE) has requested you to create a...
Assignment Task Java Object Orientated GUI CQ Real Estate (CQRE) has requested you to create a Swing based Java GUI application to cater their needs. Whenever CQRE receives a property sale offer from the seller, it assigns an employee exclusively to that sale offer and then lists it for sale. When the prospective buyers provide their offers for buying these properties, CQRE maintains the details of those purchase offers. You may note that there can be many purchase offers for...
Create a moderately complex java program that utilises 2 or more classes. Within these classes: -...
Create a moderately complex java program that utilises 2 or more classes. Within these classes: - have one that defines an exception - have that exception throw(n) in one method and handled in another -has the program continue even if the user inputs incorrect data -be creative/unique in some way
Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes each in...
Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes each in its own file Student.java, StudentList.java, and Assign5Test.java. Copy your code from Assignment 4 into the Student.java and StudentList.java Classes. Assign5Test.java should contain the main method. Modify StudentList.java to use an ArrayList instead of an array. You can find the basics of ArrayList here: https://www.w3schools.com/java/java_arraylist.asp In StudentList.java, create two new public methods: The addStudent method should have one parameter of type Student and should add...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT