• 大小: 6KB
    文件类型: .java
    金币: 1
    下载: 0 次
    发布日期: 2021-05-21
  • 语言: Java
  • 标签: java  图形学  

资源简介

private double t=0.0,ts=0.0; private double px[][]=new double[999][999]; private double py[][]=new double[999][999]; private int i=0,j=0,k,x,y,sum=0; private Button button_Caste,button_Clear,button_OK; private int flag1=0,flag2=0,flag3=0; private Dialog dialog; private Label label_dialog,label; private TextField text;

资源截图

代码片段和文件信息

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Casteljau extends frame implements WindowListenerComponentListenerMouseListenerActionListener
{//polygon change
    private double t=0.0ts=0.0;
    private double px[][]=new double[999][999];
    private double py[][]=new double[999][999];
    private int i=0j=0kxysum=0;
    private Button button_Castebutton_Clearbutton_OK;
    private int flag1=0flag2=0flag3=0;
    private Dialog dialog;
    private Label label_dialoglabel;
    private TextField text;
    
public Casteljau()
{//initialize windows
super(“Bezier曲线的递推(de Casteljau)算法“);
this.setSize(800600);
this.setLocation(250100);
this.setLayout(new FlowLayout());//windows mediacy
this.setBackground(Color.lightGray);

button_Caste=new Button(“Casteljau“);
this.add(button_Caste);
button_Caste.addActionListener(this);

button_Clear=new Button(“Clear“);
this.add(button_Clear);
button_Clear.addActionListener(this);

dialog=new Dialog(this“错误“true);
dialog.setSize(24080);
label_dialog=new Label(“没有给定位置矢量“Label.CENTER);
dialog.add(label_dialog);
dialog.addWindowListener(this);

label=new Label(“求给定 t 坐标“);
this.add(label);


text=new TextField(10);
text.setEditable(true);
this.add(text);

button_OK=new Button(“OK“);
this.add(button_OK);
button_OK.addActionListener(this);

this.addComponentListener(this);
this.addWindowListener(this);
this.addMouseListener(this);
this.setVisible(true);

}

public void paint(Graphics g){//draw Axes
          
  
           if(flag1==1)
           {
            g.setColor(Color.blue);
            g.fillOval(x-5y-51010);
           }        
                                
}

   public void update(Graphics g){//repaint the point
   
        if(flag1==1)
        {
        g.setColor(Color.blue);
            g.fillOval(x-4y-488);
            }
            
            if(flag2==1)
        {    
            g.setColor(Color.red);
            for(int i=0;i            {g.drawLine((int)px[i][0](int)py[i][0](int)px[i+1][0](int)py[i+1][0]);
            //time delay
             for(int l=0;l<100000;l++)
   for(int t=0;t<4000;t++)
         {}
        }
                 
        t=0.0;
            while(t<=1.0)
            {            
            for(k=0;k            for(i=0;i            {point(pxikt);
             point(pyikt);}
             g.setColor(Color.black);           
             g.fillOval((int)px[0][sum-1]-1(int)py[0][sum-1]-122);           
             t=t+0.001;
            }
            }
            
            if(flag1==0&&flag2==0)
            {    g.setColor(Color.lightGray);
             g.fillRect(00800800);
             }
            
            if(flag3==1)
            {
             ts=Doubl

评论

共有 条评论