⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frame1.java

📁 常见函数绘图 正余弦
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
           double a = Double.parseDouble(A);
           double w = Double.parseDouble(W);
           double t = Double.parseDouble(T);
           Graphics g = this.jPanel1.getGraphics();
           for (double xofcos = -16; xofcos < 16; ) {

               double y = a * Math.cos(w *xofcos + t);
               Point l = new Point(0, 0);
               l.setLocation(245+(xofcos)*15, 240-y*15);
               double nexty = a * Math.cos(w *(xofcos + 0.01) + t);
               Point nextl = new Point(0, 0);
               nextl.setLocation(245+(xofcos + 0.01)*15, 240-nexty*15);
               g.drawLine(l.x, l.y, nextl.x, nextl.y);
               xofcos = xofcos + 0.01;
           }
           for (int i=-8; i<=8; i++){
               Point pi = new Point(0, 0);
               pi.setLocation(245+i*3.1415*15, 247);
           g.drawString(i + "Pi", pi.x, pi.y);
           }
           g.drawString("1", 245, 225);
           g.drawString("5", 245, 240-75);
           g.drawString("-1", 245, 255);
           g.drawString("-5", 245, 240+75);

       }

void drawsin (String A, String W, String T){

                  double a = Double.parseDouble(A);
                  double w = Double.parseDouble(W);
                  double t = Double.parseDouble(T);
                  Graphics g = this.jPanel1.getGraphics();
                  for (double xofsin = -16; xofsin < 16; ) {

                      double y = a * Math.sin(w *xofsin + t);
                      Point m = new Point(0, 0);
                      m.setLocation(245+(xofsin)*15, 240-y*15);
                      double nexty = a * Math.sin(w *(xofsin + 0.01) + t);
                      Point nextm = new Point(0, 0);
                      nextm.setLocation(245+(xofsin + 0.01)*15, 240-nexty*15);
                      g.drawLine(m.x, m.y, nextm.x, nextm.y);
                      xofsin = xofsin+0.01;
                  }
                  for (int i=-4; i<=4; i++){
                        Point pi = new Point(0, 0);
                        pi.setLocation(245+i*3.1415*15, 247);
                        g.drawString(i + "Pi", pi.x, pi.y);
                  }
                  g.drawString("1", 245, 225);
                  g.drawString("5", 245, 240-75);
                  g.drawString("-1", 245, 255);
                  g.drawString("-5", 245, 240+75);
              }
void drawexpa (String A){
                  double a = Double.parseDouble(A);
                  Graphics g = this.jPanel1.getGraphics();
                  for (double xofexpa = -16; xofexpa < 16; ){

                       double y = Math.pow(xofexpa, a);
                       Point l = new Point();
                       l.setLocation(245+xofexpa*15, 240-y*15);
                       double nexty = Math.pow(xofexpa+0.2, a);
                       Point nextl = new Point();
                       nextl.setLocation(245+(xofexpa+0.2)*15, 240-nexty*15);
                       g.drawLine(l.x, l.y, nextl.x, nextl.y);
                       xofexpa = xofexpa+0.2;
                  }
                  for (int i= -10; i<=10; i++){
                          Point n = new Point();
                          n.setLocation(245+i*15, 247);
                          g.drawString(i+"", n.x, n.y);
                  }
                  g.drawString("1", 245, 225);
                  g.drawString("5", 245, 240-75);
                  g.drawString("-1", 245, 255);
                  g.drawString("-5", 245, 240+75);
                }
void drawexpx (String A){
                  double a = Double.parseDouble(A);
                  Graphics g = this.jPanel1.getGraphics();
                  for (double xofexpx = -16; xofexpx < 16; ){

                  double y = Math.pow(a, xofexpx);
                  Point l = new Point();
                  l.setLocation(245+xofexpx*15, 240-y*15);
                  double nexty = Math.pow(a, xofexpx+0.2);
                  Point nextl = new Point();
                  nextl.setLocation(245+(xofexpx+0.2)*15, 240-nexty*15);
                  g.drawLine(l.x, l.y, nextl.x, nextl.y);
                  xofexpx = xofexpx+0.2;
                  }
                  for (int i= -10; i<=10; i++){
                          Point n = new Point();
                          n.setLocation(245+i*15, 247);
                          g.drawString(i+"", n.x, n.y);
                  }
                  g.drawString("1", 245, 225);
                  g.drawString("5", 245, 240-75);
                  g.drawString("-1", 245, 255);
                  g.drawString("-5", 245, 240+75);

}
void drawlog (String A){
                  double a = Double.parseDouble(A);
                  Graphics g = this.jPanel1.getGraphics();
                  for (double xoflog = 0; xoflog < 16; ){

                  double y = Math.log(xoflog)/Math.log(a);
                  Point l = new Point();
                  l.setLocation(245+xoflog*15, 240-y*15);
                  double nexty = Math.log(xoflog+0.2)/Math.log(a);
                  Point nextl = new Point();
                  nextl.setLocation(245+(xoflog+0.2)*15, 240-nexty*15);
                  g.drawLine(l.x, l.y, nextl.x, nextl.y);
                  xoflog = xoflog+0.2;
                  }
                  for (int i= -10; i<=10; i++){
                          Point n = new Point();
                          n.setLocation(245+i*15, 247);
                          g.drawString(i+"", n.x, n.y);
                  }
                  g.drawString("1", 245, 225);
                  g.drawString("5", 245, 240-75);
                  g.drawString("-1", 245, 255);
                  g.drawString("-5", 245, 240+75);
                }
void drawseg(String X, String X1, String X2){
              Graphics g = this.jPanel1.getGraphics();
              if(jRadioButtoncos.isSelected()){
                  String awtofcos = jTextFieldawtofcos.getText();
                  if (!(awtofcos.compareTo("")==0) && !(awtofcos.compareTo("A,W,T")==0)){
                         int firstcomaofcos = awtofcos.indexOf(",");
                         int secondcomaofcos = awtofcos.indexOf(",", firstcomaofcos + 1);
                         String Aofcos = awtofcos.substring(0, firstcomaofcos);
                         String Wofcos = awtofcos.substring(firstcomaofcos + 1, secondcomaofcos);
                         String Tofcos = awtofcos.substring(secondcomaofcos + 1);
                         if (!(Aofcos.compareTo("")==0) && !(Wofcos.compareTo("")==0) && !(Tofcos.compareTo("")==0)) {
                                          drawcos(Aofcos, Wofcos, Tofcos);}
                         else {}}
                   else{} }
                else {if(jRadioButtonsin.isSelected()){
                            String awtofsin = jTextFieldawtofsin.getText();
                            if (!(awtofsin.compareTo("") == 0) &&!(awtofsin.compareTo("") == 0)) {
                                int firstcomaofsin = awtofsin.indexOf(",");
                                int secondcomaofsin = awtofsin.indexOf(",",firstcomaofsin + 1);
                                String Aofsin = awtofsin.substring(0, firstcomaofsin);
                                String Wofsin = awtofsin.substring(firstcomaofsin + 1,
                                                                                  secondcomaofsin);
                                String Tofsin = awtofsin.substring(secondcomaofsin +1);
                                if (!(Aofsin.compareTo("") == 0) &&
                                                                !(Wofsin.compareTo("") == 0) &&
                                                                              !(Tofsin.compareTo("") == 0)) {
                                        drawsin(Aofsin, Wofsin, Tofsin);
                                 } else {}}
                             else {}  }


                        else{if(jRadioButtonexp.isSelected()){
                                  String aofexpx = jTextFieldaofexpx.getText();
                                  if (!(aofexpx.compareTo("") == 0)) {drawexpx(aofexpx);}
                                  else {}}
                               else{ if(jRadioButtonxn.isSelected()){
                                        String aofexpa = jTextFieldaofexpa.getText();
                                         if (!(aofexpa.compareTo("") == 0)) {drawexpa(aofexpa);}
                                         else {}}
                                     else{if(jRadioButtonxn.isSelected()){
                                             String aofexpa = jTextFieldaofexpa.getText();
                                             if (!(aofexpa.compareTo("")==0)){drawexpa(aofexpa);}
                                             else {}}
                                           else{if(jRadioButtonln.isSelected()){
                                                  String aoflog = jTextFieldaoflog.getText();
                                                  if(!(aoflog.compareTo("")==0)){drawlog(aoflog);}
                                                  else {}}
                                                else {if (jRadioButtonfour.isSelected()){
                                                   String aoffour = jTextFieldaoffour.getText();
                                                   if(!(aoffour.compareTo("")==0)){drawfour(aoffour);}
                                                   else {}}
                                              }}}}}}


         }
void drawfour (String A){
                Graphics g = this.jPanel1.getGraphics();
                Double a = Double.parseDouble(A);
                if (jRadioButtonplus.isSelected()){
                    for (double xofplus = -16; xofplus < 16; ){

                    double y = xofplus+a;
                    Point l = new Point();
                    l.setLocation(245+xofplus*15, 240-y*15);
                    double nexty = xofplus+a;
                    Point nextl = new Point();
                    nextl.setLocation(245+(xofplus+0.01)*15, 240-nexty*15);
                    g.drawLine(l.x, l.y, nextl.x, nextl.y);
                    xofplus = xofplus+0.01;
                    }
                    for (int i= -10; i<=10; i++){
                         Point n = new Point();
                         n.setLocation(245+i*15, 247);
                         g.drawString(i+"", n.x, n.y);
                    }
                 g.drawString("1", 245, 225);
                 g.drawString("5", 245, 240-75);
                 g.drawString("-1", 245, 255);
                 g.drawString("-5", 245, 240+75);
                }
                else {if (jRadioButtonminus.isSelected()){
                    for (double xofminus = -16; xofminus < 16; ){

                    double y = xofminus-a;
                    Point l = new Point();
                    l.setLocation(245+xofminus*15, 240-y*15);
                    double nexty = xofminus-a;
                    Point nextl = new Point();
                    nextl.setLocation(245+(xofminus+0.01)*15, 240-nexty*15);
                    g.drawLine(l.x, l.y, nextl.x, nextl.y);
                    xofminus = xofminus+0.01;
                    }
                    for (int i= -10; i<=10; i++){
                         Point n = new Point();
                         n.setLocation(245+i*15, 247);
                         g.drawString(i+"", n.x, n.y);
                    }
                 g.drawString("1", 245, 225);
                 g.drawString("5", 245, 240-75);
                 g.drawString("-1", 245, 255);
                 g.drawString("-5", 245, 240+75);
                }
                 else{if (jRadioButtondivide.isSelected()){
                    for (double xofdivide = -16; xofdivide < 16; ){

                    double y = xofdivide/a;
                    Point l = new Point();
                    l.setLocation(245+xofdivide*15, 240-y*15);
                    double nexty = xofdivide/a;
                    Point nextl = new Point();
                    nextl.setLocation(245+(xofdivide+0.01)*15, 240-nexty*15);
                    g.drawLine(l.x, l.y, nextl.x, nextl.y);
                    xofdivide = xofdivide+0.01;
                    }
                    for (int i= -10; i<=10; i++){
                         Point n = new Point();
                         n.setLocation(245+i*15, 247);
                         g.drawString(i+"", n.x, n.y);
                    }
                 g.drawString("1", 245, 225);
                 g.drawString("5", 245, 240-75);
                 g.drawString("-1", 245, 255);
                 g.drawString("-5", 245, 240+75);
                }
                else{if (jRadioButtonmultiple.isSelected()){
                    for (double xofmultiple = -16; xofmultiple < 16; ){

                    double y = xofmultiple*a;
                    Point l = new Point();
                    l.setLocation(245+xofmultiple*15, 240-y*15);
                    double nexty = xofmultiple*a;
                    Point nextl = new Point();
                    nextl.setLocation(245+(xofmultiple+0.01)*15, 240-nexty*15);
                    g.drawLine(l.x, l.y, nextl.x, nextl.y);
                    xofmultiple = xofmultiple+0.01;
                    }
                    for (int i= -10; i<=10; i++){
                         Point n = new Point();
                         n.setLocation(245+i*15, 247);
                         g.drawString(i+"", n.x, n.y);
                    }
                    g.drawString("1", 245, 225);
                    g.drawString("5", 245, 240-75);
                    g.drawString("-1", 245, 255);
                    g.drawString("-5", 245, 240+75);
                    }
                }}}


}
}


class Frame1_jButtondraw_mouseAdapter extends MouseAdapter {
    private Frame1 adaptee;
    Frame1_jButtondraw_mouseAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
    }

    public void mousePressed(MouseEvent e) {
        adaptee.jButtondraw_mousePressed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -