java program of following attachment
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 nowThis is a popular solution!
Step by stepSolved in 2 steps
- Java Assignment: Experiment with naming rules in Java Does the language use static or dynamic scoping? Can scopes nest? Are they open or closed? Does the scope of a name encompass the entire block in which it is declared, or only the portion after the declaration? How does one declare mutually recursive types or subroutines? Can subroutines be passed as parameters, returned from functions, or stored in variables? If so, when are referencing environments bound? Justify your answers with suitable code snippet and its output.arrow_forwardQUESTION 5 Competition synchronization constructs in Java are provided by the Object class. True Falsearrow_forwardjava A time series is represented a list of time/value pairs Write a function that takes two time series and outputs a new series of the summation of themarrow_forward
- The term "dynamic programming" refers to a mathematical optimisation method that involves breaking down a complex problem into smaller subproblems and solving them recursively.arrow_forwardExamples are quite useful for describing the review process for software structuresarrow_forwardQ) Distinguish between abstract class and interface in java languagearrow_forward
- Examples are quite useful for describing the review process for software structuresarrow_forwardWhat does it mean to "fight the impulse to code" in the context of the programming adage?arrow_forwardExplain whether or not explicit declaration has a greater effect than implicit declaration in large-scale applications.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education