Programming Projects 1. Write a program that draws the patterns shown in Figure 3G.33 onto a DrawingPanel. Dinwn y Fauel

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

java program of following attachment

Programming Projects
1. Write a program that draws the patterns shown in Figure 3G.33 onto a DrawingPanel.
& 1inuvu y Fanel
EX
Figure 3G.33
The DrawingPanel's size is 400 x 400 pixels and its background color is eyan. It contains four figures of concentric
yellow circles with black outlines, all surrounded by a green rectangle with a black outline. The four figures on your
DrawingPanel should have the properties shown in Table 3G.7.
Table 3G.7 Circle Figure Properties
Number
Number of
Description
(x, y) position
Size of subfigures
of circles
rows/cols
top left
(0, 0)
100 x 100
5
1x1
bottom left
(10, 120)
24 x 24
5 x 5
top right
(150, 20)
40 x 40
6x6
bottom right
(130, 275)
36 x 36
3
3 x 3
Break down your program into methods for drawing one subfigure as well as larger grids of subfigures, such as the
5 x 5 grid at (10, 120).
Transcribed Image Text:Programming Projects 1. Write a program that draws the patterns shown in Figure 3G.33 onto a DrawingPanel. & 1inuvu y Fanel EX Figure 3G.33 The DrawingPanel's size is 400 x 400 pixels and its background color is eyan. It contains four figures of concentric yellow circles with black outlines, all surrounded by a green rectangle with a black outline. The four figures on your DrawingPanel should have the properties shown in Table 3G.7. Table 3G.7 Circle Figure Properties Number Number of Description (x, y) position Size of subfigures of circles rows/cols top left (0, 0) 100 x 100 5 1x1 bottom left (10, 120) 24 x 24 5 x 5 top right (150, 20) 40 x 40 6x6 bottom right (130, 275) 36 x 36 3 3 x 3 Break down your program into methods for drawing one subfigure as well as larger grids of subfigures, such as the 5 x 5 grid at (10, 120).
Expert Solution
Step 1code

import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.lang.*;
public class TestDrawing extends JFrame {
   int initialx,initialy;
   public TestDrawing(int x,int y){
       this.initialx=x;
       this.initialy=y;
   }
  
   public void Display()
{
setBackground(Color.CYAN);
           setTitle("Drawing Panel");
setSize(400+initialx,400+initialy);
setVisible(true);
           setLocationByPlatform(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
          
}
@Override
public void paint(Graphics g)
{

Graphics2D g2d = (Graphics2D)g;
       drawSquaresD(g,"TL",0,0,100,5,1,1);
       drawSquaresD(g,"BL",10,100,20,4,7,7);
       drawSquaresD(g,"TR",20,20,30,5,6,6);
       drawSquaresD(g,"BR",100,30,30,4,4,4);

}
  
public void drawSquaresD(Graphics g,String p,int x,int y, int size,int n, int r,int c){
       int ir,ic,in;
       switch(p){
           case "BL":
               y=getHeight()-(y+(size*r))-initialy;
               break;
           case "TR":
               x=getWidth()-(x+(size*c))-initialx;
               break;
           case "BR":
               x=getWidth()-(x+(size*c))-initialx;
               y=getHeight()-(y+(size*r))-initialy;
               break;
           case "TL": default:
               break;
       }
       x=x+initialx;
       y=y+initialy;
          
       for(ir=0;ir<r;ir++){
           for(ic=0;ic<c;ic++){
               g.setColor(Color.GREEN);
               int x1,y1;
               x1=x+(ic*size);
               y1=y+(ir*size);
               g.fillRect(x1,y1,size,size);
               int j=0;
               for(in=n;in>0;in--){
                   int sizec=(size/n)*in;
                   int sizecc=((size/2)/n)*j;
                   g.setColor(Color.YELLOW);
                   g.fillOval(x1+sizecc,y1+sizecc,sizec,sizec);
                   g.setColor(Color.BLACK);
                   g.drawOval(x1+sizecc,y1+sizecc,sizec,sizec);
                   j++;
            

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education