在前面
sellhis
import java
import java
import java
import java
import java
import java
import java
public class sellhis extends Applet{
static int Len;
int leftMargine=
int rightMargine=
int topMargine=
int buttomMargine=
int width
int minStickLength=
int majStickLength=
int minStick=
int majStick;
String title;
String xTitle=
String xCode[];
float yData[]
String MaxPce;
boolean Mouse_Move;
int x
Label label[]=new Label[
boolean mouse_move=false;
public void init() {
width=this
height=this
w=width
h=height
setSize(width
Color bc=new Color(
setBackground(bc);
setLayout(null);
for(int I=
label[I]=new Label();
label[I]
this
if(I==
label[I]
if(I==
label[I]
if(I==
label[I]
}
try{
title=getTitle(getParameter(
}
catch(Exception e){
System
System
}
try{
xCode=Subicode(getParameter(
Len=xCode
hx=w/Len;
}
catch(Exception e){
System
System
}
try{
yData=Substr(getParameter(
}
catch(Exception e){
System
System
}
try{
xPce=Substr(getParameter(
MaxPce=getMaxVal(xPce);
majStick=Integer
}
catch(Exception e){
System
System
}
try{
addMouseListener(new MouseAdapter(){
public void mouseReleased(MouseEvent evt){//檢測釋放鼠標按鍵事件
setCursor(Cursor
Point ioc=evt
X=ioc
Y=ioc
//repaint();
}
});
addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent evt){
Point ioc=evt
if((ioc
setCursor(Cursor
else
setCursor(Cursor
}
public void mouseMoved(MouseEvent evt){ //檢測鼠標移動事件
Point ioc=evt
X=ioc
Y=ioc
Graphics gten;
gten=getGraphics();
gten
gten
int Axsis;
if(ioc
Axsis=(X
//在以下區域內
label[
label[
float pcent=(xPce[Axsis]/
label[
}
catch(Exception err){
}
try{
if(y
gten
if(Y >topMargine & Y< h+topMargine)
gten
if(x
gten
if(X >leftMargine & X< w+leftMargine)
gten
x
y
}
finally{
gten
}
}
}
});
}
catch(Exception e)
{
System
System
}
}
public void paint(Graphics g){
try{
g
g
g
g
int x
int totalStick=(majStick
x
dy=h/((majStick
for(int I=
y
y
x
if(I%minStick==
x
g
}
g
}
for(int I=
hy=(int)((xPce[I]/
y
float pcent=(xPce[I]/
Color pceCololr=new Color(
g
g
g
if(I%
g
else
g
g
//g
//g
//g
}
Color titleColor=new Color(
g
g
g
}
catch(Exception e){
System
System
}
}
public static float[] Substr(String str){
int I=
StringTokenizer st = new StringTokenizer(str
int len=untTokens();
float[] val=new float[len];
while(st
val[I]=Integer
I++;
}
return val;
}
public static String[] Subicode(String str){
int I=
StringTokenizer st = new StringTokenizer(str
int len=untTokens();
String[] val=new String[len];
while(st
val[I]=st
I++;
}
return val;
}
public static String getMaxVal(float[] Maxval){
int I;
float result;
result=Maxval[
for(I=
}
return Float.toString(result);
}
public String getTitle(String str){
String title;
title=str.substring(0,4)+"年"+str.substring(4,6)+"月賣空股票統計";
return title;
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19647.html