QuestionQuestion

The PolkaDots project makes use of the Canvas class and the Circle class from the Shapes project.
Write the PolkaDots code.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.*;

/**
* Canvas is a class to allow for simple graphical drawing on a canvas. This is
* a modification of the general purpose Canvas, specially made for the BlueJ
* "shapes" example.
*
* @author:
* @author:
*
* @version: 1.6 (shapes)
*/
public class Canvas {

   
    // Note: The implementation of this class (specifically the handling of
    // shape identity and colors) is slightly more complex than necessary. This
    // is done on purpose to keep the interface and instance fields of the
    // shape objects in this project clean and simple for educational purposes.

    private static Canvas canvasSingleton;

    /**
    * Factory method to get the canvas singleton object.
    */
    public static Canvas getCanvas() {
       if (canvasSingleton == null) {
            canvasSingleton = new Canvas("BlueJ Shapes Demo", 300, 300,
                   Color.white);
       }
       canvasSingleton.setVisible(true);
       return canvasSingleton;
    }

    // ----- instance part -----
    private JFrame frame;
    private CanvasPane canvas;
    private Graphics2D graphic;
    private Color backgroundColour;
    private Image canvasImage;
    private List objects;
    private HashMap shapes;

    /**
    * Create a Canvas.
    *
    * @param title title to appear in Canvas Frame
    * @param width the desired width for the canvas
    * @param height the desired height for the canvas
    * @param bgClour the desired background colour of the canvas
    */
    private Canvas(String title, int width, int height, Color bgColour) {
       frame = new JFrame();
       canvas = new CanvasPane();
       frame.setContentPane(canvas);
       frame.setTitle(title);
       canvas.setPreferredSize(new Dimension(width, height));
       backgroundColour...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats