Java的出现,给证券行业发展带来了新的机遇.这里我以java写的一个走势力图为例:
package charts;

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;


public class charts extends Applet ...{
static int LEN;
static int Xo, Yo; // 坐标原点(Xo,Yo)
static int X2, Y2; // X轴顶点坐标(Xo,Yo)
static final int X1 = 50, Y1 = 30; // Y轴顶点坐标(Xo,Yo)
static int Yunit, Xunit;
static float Unit;
static String Xstr, Ystr; // 接收从Html传进X轴Y轴的数据
static int[] Xval;
static int[] Yval;
static float[] Y = new float[5];
static int Xmax, Xmin;
static float Ymax, Ymin;
static int[] Yvalue;
static int[] Xvalue;


public void init() ...{
// setBackground(Color.gray);
int width = this.getBounds().width;
int height = this.getBounds().height;
setSize(width, height);
Xstr = getParameter("xValue");
Ystr = getParameter("yValue");
Xval = Substr(Xstr);
Yval = Substr(Ystr);
LEN = Xval.length;
Yvalue = new int[LEN];
Xvalue = new int[LEN];
Xo = 50;
Yo = height - 30;
X2 = width - 30;
Y2 = Yo;
Yunit = (height - 100) / 4;
Xunit = (width - 100) / LEN;
Ymax = getMaxVal(Yval);
Ymin = getMinVal(Yval);
float tempy = ((float) Ymax - (float) Ymin) / 4;
Y[0] = Ymin; // Y轴坐标刻度
Y[1] = Ymin + tempy;
Y[2] = Ymin + tempy * 2;
Y[3] = Ymin + tempy * 3;
Y[4] = Ymax;
Unit = (float) (Yunit * 4) / ((float) Ymax - (float) Ymin);
Yvalue = getY(Yunit, tempy, Ymin, Yval);
}


public static int[] getY(int unit, float diff, float ymin, int[] value) ...{
int I = 0; // unit=Yunit; diff=temp; ymin=Ymin
int[] result = new int[LEN];
for (I = 0; I < LEN; I++)
result[I] = (int) (Yo - ((4 * unit) / (diff * 4)) * (value[I] - ymin));
return result;
}


public void paint(Graphics g) ...{
g.setColor(Color.red);// 坐标原点(30,290)
g.drawLine(Xo, Yo, X1, Y1); // Y轴
int I;

for (I = 0; I < 5; I++) ...{
g.drawLine(Xo, Yo - Yunit * I, Xo - 5, Yo - Yunit * I); // Y
g.drawString(Float.toString(Y[I]), Xo - 38, Yo - Yunit * I);
}
g.drawLine(X1, Y1, X1 - 5, Y1 + 5); // Y轴左箭头
g.drawLine(X1, Y1, X1 + 5, Y1 + 5); // Y轴右箭头

g.drawLine(Xo, Yo, X2, Y2); // X轴
// System.out.println("");

for (I = 0; I < LEN; I++) ...{
g.drawLine(Xo + Xunit * I, Yo, Xo + Xunit * I, Yo + 5); // X
// System.out.print((Xo+Xunit*I)+" ");
g.drawString(Integer.toString(Xval[I]), Xo + Xunit * I - 6, Yo + 20);
}
g.drawLine(X2, Y2, X2 - 5, Y2 - 5); // X轴左箭头
g.drawLine(X2, Y2, X2 - 5, Y2 + 5); // X轴右箭头

g.setColor(Color.black);
g.drawString("Y", X1 - 20, Y1);
g.drawString("X", X2, Y2 + 20);
for (I = 0; I < LEN - 1; I++)
g.drawLine(Xo + Xunit * I, Yvalue[I], Xo + Xunit * (I + 1), Yvalue[I + 1]);
}


public static int[] Substr(String str) ...{
int I = 0;
StringTokenizer st = new StringTokenizer(str, ",");
int len = st.countTokens();
int[] val = new int[len];

while (st.hasMoreTokens()) ...{
val[I] = Integer.parseInt(st.nextToken());
I++;
}
return val;
}


public static int getMaxVal(int[] Maxval) ...{
int I, result;
result = Maxval[0];

for (I = 0; I < Maxval.length; I++) ...{
if (result < Maxval[I])
result = Maxval[I];
}
return result;
}


public static int getMinVal(int[] Minval) ...{
int I, result;
result = Minval[0];

for (I = 0; I < Minval.length; I++) ...{
if (result > Minval[I])
result = Minval[I];
}
return result;
}
}





































































































































