Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.geom.*;
- import javax.swing.*;
- import java.util.*;
- public class Display extends Frame {
- int xmou = 400; //set the center of circle
- int ymou = 400; //set the center of circle
- int x = xmou; //x position of Second's hand
- int y = ymou; //y position of second's hand
- double theta = -0.1047; //theta for second's hand
- double the = -0.1047; //theta for creating outer circle
- double thetan = -0.0; //theta for numbers of Radar
- int xn = xmou; //x position of Radar numbers
- int yn = ymou; //y position of Radar numbers
- int pn, bn; //perpendicular and base of Radar numbers
- int num = 0; //for writing the numbers
- int h = 340;
- public class Interface {
- public Interface(Graphics2D g) {
- Shape border = new Ellipse2D.Float(50.0f, 50.0f, 700.0f, 700.0f);
- Shape circle = new Ellipse2D.Float(55.0f, 55.0f, 690.0f, 690.0f);
- Shape square = new Rectangle2D.Double(0, 0, 800, 800);
- g.draw(square);
- g.fill(square);
- g.draw(circle);
- g.setPaint(Color.black);
- g.fill(circle);
- g.setPaint(Color.green);
- g.fill(border);
- g.setPaint(Color.black);
- g.fill(circle);
- }
- }
- public class Building {
- public Building(Graphics2D g) {
- Shape walls = new Rectangle2D.Double(300, 300, 100, 300);
- g.draw(walls);
- g.setPaint(Color.red);
- g.fill(walls);
- }
- }
- public class Aircraft {
- public Aircraft(Graphics2D g) {
- int bx = 500, by = 500;
- Shape body = new Ellipse2D.Float(bx, by, 20, 20);
- g.draw(body);
- g.setPaint(Color.pink);
- g.fill(body);
- }
- }
- public void paint(Graphics g) {
- Graphics2D ga = (Graphics2D) g;
- Interface i = new Interface(ga);
- Building r = new Building(ga);
- Aircraft a = new Aircraft(ga);
- for (int p = 0; p < 360; p++) {
- int xocir = xmou; //x position of outer circle
- int yocir = ymou; //y position of outer circle
- int pocir, bocir; //perpendicular and base of outer circle
- pocir = (int) (Math.sin(the) * (h + 23));
- bocir = (int) (Math.cos(the) * (h + 23));
- xocir = xocir - pocir;
- yocir = yocir - bocir;
- the = the - 0.1047;
- g.setColor(Color.BLUE);
- g.drawLine(xocir + 5, yocir + 5, xocir, yocir);
- //g.setColor(Color.BLACK);
- if (p % 5 == 0) {
- num++;
- if (num > 1) {
- num = 1;
- }
- xn = xmou;
- yn = ymou;
- if (thetan <= -6.28318531) {
- thetan = 0.0;
- }
- thetan = thetan - 0.0872;
- pn = (int) (Math.sin(thetan) * (h + 20));
- bn = (int) (Math.cos(thetan) * (h + 20));
- xn = xn - pn;
- yn = yn - bn;
- g.drawString("" + num, xn - 3, yn + 5);
- }
- }
- //for drawing Radar hands
- g.setColor(Color.BLACK);
- // g.drawLine(xmou, ymou, xm, ym); //drawing minute's hand
- // g.drawLine(xmou, ymou, xh, yh); //drawing hour's hand
- g.setColor(Color.RED);
- g.drawLine(xmou, ymou, x, y); //drawing second's hand
- }
- public static void main(String args[]) {
- Frame frame = new Display();
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent we) {
- System.exit(0);
- }
- });
- frame.setSize(800, 800);
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement