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,...
In Java Develop, test, and execute a graphics application for simulations using Java. Create a Java...
In Java Develop, test, and execute a graphics application for simulations using Java. Create a Java application. Given a set of events, choose the resulting programming actions. Understand the principles behind Java. Understand the basic principles of object-oriented programming including classes and inheritance. Deliverables .java files as requested below. Requirements Create all the panels. Create the navigation between them. Start navigation via the intro screen. The user makes a confirmation to enter the main panel. The user goes to the...
Using JAVA: This assignment is about aggregation and class collaboration. You will create several Classes that...
Using JAVA: This assignment is about aggregation and class collaboration. You will create several Classes that will be part of an overall class named InstrumentDisplay. The classes are FuelGage, Odometer, MilesSinceLastGas, and CruisingRange. The FuelGage should assume a 15 gallon tank of gasoline and an average consumption of 1 gallon every 28 miles. It should increment in 1 gallon steps when you "add gas to the tank". It should decrement by 1 every 28 miles. It should display its current...
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...
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...
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: 1. Upon execution, the application shall display a brief welcome message to the user to let her know she is running the currency converter application. 2. 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...
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.
Assignment 1: JAVA Classes, Objects, and Constructors The goal of this assignment is to get you...
Assignment 1: JAVA Classes, Objects, and Constructors The goal of this assignment is to get you familiar with some of the most used JAVA syntax, as well as constructors objects, objects calling other objects, class and instance attributes and methods. You will create a small program consisting of Musician and Song classes, then you will have Musicians perform the Songs. Included is a file “Assignment1Tester.java”. Once you have done the assignment and followed all instructions, you should be able to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT