Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Panel extends JPanel implements MouseListener, KeyListener, Runnable, ActionListener {
- static Scanner scn=new Scanner(System.in);
- static Random r1=new Random();
- Polygon p1;
- static ArrayList <Integer> list2=new ArrayList<Integer>();
- static ArrayList <Integer> list=new ArrayList<Integer>();
- static ArrayList <Double> list1=new ArrayList<Double>();
- int b[]=new int[5];
- int c[]=new int[5];
- int x3=300;
- int yn=0;
- int y3=500-60;
- int r=50;
- int cx=-50;
- static int xx=0;
- static int xy=0;
- static int x1=0;
- static int x2=0;
- static int xn=scn.nextInt();
- int cx1=-30;
- boolean ll=false;
- JLabel l1;
- double Xlast;
- Timer timer = new Timer(10, this);
- int dX;
- public Panel(){
- addMouseListener(this);
- addKeyListener(this);
- l1=new JLabel("");
- add(l1);
- timer.start();}
- int k[]={-3, -2, -1, 0, 1, 2, 3};
- static double Phi(double x)
- {
- return -2 * x + 6 + x * x*0.07;
- }
- private double f( int x){
- return -2 * x + 6 + x * x*0.07;
- }
- private double f1(int x){
- return -2 * x + 6 + x * x*0.07;
- }
- public void Math(){
- for(int tt=0; tt<b.length; tt++){
- xn=scn.nextInt();
- b[tt]=xn;
- for( x1=-700, x2=-699; x2<=500; x1++, x2++){
- if(b[tt]==x1){
- yn=(int)-(f(x1))+y3;
- c[tt]=yn;
- System.out.println(yn);
- System.out.println(x1);
- 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);
- }}
- }
- }
- public void actionPerformed(ActionEvent e) {
- if(ll==false){
- cx++;
- if(cx==500){
- timer.stop();
- }}
- if(ll==true){
- cx1++;
- if (cx1 == 500){
- timer.stop();
- }}
- repaint();
- }
- public void paint(Graphics g){
- super.paint(g);
- g.drawPolygon(p1);
- for( x1=-700, x2=-699; x2<=cx; x1++, x2++){
- if(xn==x1){
- g.drawLine(x1+x3, (int)-(f(x1))+y3, x1+x3+10, (int)-(f(x1))+y3);
- }
- g.drawLine(x1+x3, (int) (-(f(x1))+y3), x2+x3, (int) (-(f1(x2)) +y3));
- }
- for(int ii=0; ii<k.length; ii++){
- for(int y1=0, y2=-1; y2<=1800; y1=y1+100,y2= y2+100){
- g.drawLine(0, y1, 1800, y2);
- }
- }
- g.drawString("4", 325, 100);
- g.drawString("2", 325, 300);
- g.drawString("3", 325, 200);
- g.drawString("1", 325, 400);
- g.drawString("0", 325, 500);
- g.drawString("-1", 325, 600);
- g.drawString("-2", 325, 700);
- g.drawString("-3", 325, 800);
- g.drawString("0", 300, 525);
- g.drawString("2", 500, 525);
- g.drawString("1", 400, 525);
- g.drawString("-1", 200, 525);
- g.drawString("-2", 100, 525);
- g.drawString("-3", 0, 525);
- for( xx=0, xy=-1; xy<=1800; xx=xx+100, xy=xy+100){
- g.drawLine(xx, 0, xy, 1800);
- }
- for(int y1=0, y2=-1; y2<=1800; y1=y1+100,y2= y2+100){
- if(y1==100){
- }
- g.drawLine(0, y1, 1800, y2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement