Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. public class Panel extends JPanel implements MouseListener, KeyListener, Runnable, ActionListener {
  2. static Scanner scn=new Scanner(System.in);
  3. static Random r1=new Random();
  4. Polygon p1;
  5. static ArrayList <Integer> list2=new ArrayList<Integer>();
  6. static ArrayList <Integer> list=new ArrayList<Integer>();
  7. static ArrayList <Double> list1=new ArrayList<Double>();
  8. int b[]=new int[5];
  9. int c[]=new int[5];
  10. int x3=300;
  11. int yn=0;
  12. int y3=500-60;
  13. int r=50;
  14. int cx=-50;
  15. static int xx=0;
  16. static int xy=0;
  17. static int x1=0;
  18. static int x2=0;
  19. static int xn=scn.nextInt();
  20. int cx1=-30;
  21. boolean ll=false;
  22.  
  23. JLabel l1;
  24.  
  25. double Xlast;
  26. Timer timer = new Timer(10, this);
  27. int dX;
  28. public Panel(){
  29. addMouseListener(this);
  30. addKeyListener(this);
  31. l1=new JLabel("");
  32. add(l1);
  33. timer.start();}
  34. int k[]={-3, -2, -1, 0, 1, 2, 3};
  35.  
  36.  
  37.  
  38. static double Phi(double x)
  39. {
  40. return -2 * x + 6 + x * x*0.07;
  41. }
  42. private double f( int x){
  43. return -2 * x + 6 + x * x*0.07;
  44. }
  45. private double f1(int x){
  46. return -2 * x + 6 + x * x*0.07;
  47. }
  48.  
  49.  
  50.  
  51.  
  52. public void Math(){
  53. for(int tt=0; tt<b.length; tt++){
  54. xn=scn.nextInt();
  55. b[tt]=xn;
  56. for( x1=-700, x2=-699; x2<=500; x1++, x2++){
  57.  
  58. if(b[tt]==x1){
  59.  
  60.  
  61. yn=(int)-(f(x1))+y3;
  62. c[tt]=yn;
  63. System.out.println(yn);
  64. System.out.println(x1);
  65. p1=new Polygon(new int[]{b[0],b[1], b[2], b[3], b[4]}, new int[]{c[0], c[1], c[2], c[3], c[4]}, 5);
  66.  
  67.  
  68. }}
  69. }
  70.  
  71.  
  72.  
  73. }
  74. public void actionPerformed(ActionEvent e) {
  75.  
  76.  
  77.  
  78.  
  79. if(ll==false){
  80. cx++;
  81. if(cx==500){
  82. timer.stop();
  83. }}
  84. if(ll==true){
  85. cx1++;
  86. if (cx1 == 500){
  87. timer.stop();
  88. }}
  89.  
  90. repaint();
  91. }
  92.  
  93. public void paint(Graphics g){
  94. super.paint(g);
  95.  
  96.  
  97.  
  98. g.drawPolygon(p1);
  99. for( x1=-700, x2=-699; x2<=cx; x1++, x2++){
  100.  
  101. if(xn==x1){
  102. g.drawLine(x1+x3, (int)-(f(x1))+y3, x1+x3+10, (int)-(f(x1))+y3);
  103.  
  104. }
  105.  
  106.  
  107.  
  108. g.drawLine(x1+x3, (int) (-(f(x1))+y3), x2+x3, (int) (-(f1(x2)) +y3));
  109.  
  110. }
  111.  
  112.  
  113. for(int ii=0; ii<k.length; ii++){
  114. for(int y1=0, y2=-1; y2<=1800; y1=y1+100,y2= y2+100){
  115.  
  116. g.drawLine(0, y1, 1800, y2);
  117.  
  118. }
  119. }
  120.  
  121. g.drawString("4", 325, 100);
  122. g.drawString("2", 325, 300);
  123. g.drawString("3", 325, 200);
  124. g.drawString("1", 325, 400);
  125. g.drawString("0", 325, 500);
  126. g.drawString("-1", 325, 600);
  127. g.drawString("-2", 325, 700);
  128. g.drawString("-3", 325, 800);
  129. g.drawString("0", 300, 525);
  130. g.drawString("2", 500, 525);
  131. g.drawString("1", 400, 525);
  132. g.drawString("-1", 200, 525);
  133. g.drawString("-2", 100, 525);
  134. g.drawString("-3", 0, 525);
  135.  
  136.  
  137. for( xx=0, xy=-1; xy<=1800; xx=xx+100, xy=xy+100){
  138. g.drawLine(xx, 0, xy, 1800);
  139.  
  140. }
  141.  
  142. for(int y1=0, y2=-1; y2<=1800; y1=y1+100,y2= y2+100){
  143. if(y1==100){
  144.  
  145. }
  146. g.drawLine(0, y1, 1800, y2);
  147.  
  148. }
  149.  
  150.  
  151.  
  152.  
  153.  
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement