资源简介
珍贵的毕业设计,让我想起大学的美好时光,CSDN变得很Sx,我是说真的
代码片段和文件信息
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
//坐标轴
class Axis
{ // 坐标逻辑结构
private int X;// 横坐标
private int Y;// 纵坐标
private int Length;// 坐标轴长度
private int Count;// 刻度的个数
private int Step;// 刻度的步长
int getX()
{
return X;
}
void setX(int X)
{
this.X = X;
}
int getY()
{
return Y;
}
void setY(int Y)
{
this.Y = Y;
}
int getLength()
{
return Length;
}
void setLength(int Length)
{
this.Length = Length;
}
int getCount()
{
return Count;
}
void setCount(int Count)
{
this.Count = Count;
}
int getStep()
{
return Step;
}
void setStep(int Step)
{
this.Step = Step;
}
}
class ReadIn
{
static int readParam() throws IOException /*可通过输入数据进行测试*/
{
String s;
int n;
System.out.println(“Input X: “);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
s = br.readLine();
n = Integer.parseInt(s);
return n;
}
}
class Canva extends JPanel implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = -8102945966461157745L;
JButton btn1 btn2btn3btn4;
JLabel jlb1;
TextField jtf1;
boolean isDrawGAK = false;
boolean isDrawK=false;
boolean isInit=true;
public Gak a=new Gak();
int XXXYXLengthXCountXStep;
public Canva()
{
btn1 = new JButton(“遗传K均值聚类算法“);
btn2 = new JButton(“K均值算法“);
jlb1=new JLabel(“E 的值为:“);
jtf1=new TextField(“显示E的值!“);
add(btn1);
add(btn2);
add(jlb1);
add(jtf1);
btn1.addActionListener(this);
btn2.addActionListener(this);
a.InitPop();
Axis axisX = new Axis();
axisX.setX(100);
axisX.setY(600);
axisX.setCount(21);
axisX.setLength(600);
axisX.setStep(25);
XX = axisX.getX();
XY = axisX.getY();
XLength = axisX.getLength();
XCount = axisX.getCount();
XStep = axisX.getStep();
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{ double E;
String p;
if (e.getSource() == btn1)
{
isDrawGAK = true;
a.gak();
E=a.funcE();
p=String.valueOf(E);
jtf1.setText(p);
}
if (e.getSource() == btn2)
{
isDrawGAK = true;
a.Kzhi();
E=a.funcE();
p=String.valueOf(E);
jtf1.setText(p);
}
this.repaint();
this.setSize(1000 700);
}
public void paint(Graphics g)
{ int xy;
super.paint(g);
int Height = 5;
// 画横轴
g.drawLine(XX XY XX + XLength XY);
for (int i = 0; i < XCount; i++)
{
g.drawLine(XX + i * XStep XY XX + i * XStep XY - Height);
int j = i;
String p = String.valueOf(j);
g.drawString(p XX + i * XStep XY + 20);
}
// 画纵轴
g.drawLine(XX XY XX XY - XLength + 100);
for (int i = 0; i < XCount; i++)
{
g.drawLine(XX XY - i * XStep XX + Height XY - i * XStep);
int j = i;
Strin
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11247 2010-06-13 09:53 Gak.java
文件 4800 2010-06-12 16:31 DrawAxis.java
----------- --------- ---------- ----- ----
16047 2
- 上一篇:AD8138中文手册
- 下一篇:拉普拉斯特征映射算法,简单易懂
评论
共有 条评论