?? series.java
字號:
import java.awt.*;
import java.applet.*;
import java.util.*;
class SeriesValue
{
int ID = 0;
float y = 0 ;
float x = 0;
String TextY = new String("");
String TextX = new String("");
boolean Use = false;
SeriesValue()
{
}
SeriesValue(int ID, float x, float y, boolean Use)
{
this.ID = ID;
this.x = x;
this.y = y;
this.Use = Use;
}
};
class Series extends Object
{
Vector Value = new Vector();
private Point Origin = new Point(0,0);
boolean IsVisible = true;
int Type =0; //0 - continued line
Color color = Color.black;
private float MapY = 1;
private float MapX = 1;
private float MaxX = 100;
private float MaxY = 100;
private float MinX = 0;
private float MinY = 0;
String Title = new String("");
void setColor(Color c)
{
color = c;
}
void setMap(float x, float y)
{
MapX = x; MapY = y;
}
void setMaxMinY(float max, float min)
{
MaxY = max>min?max:min; MinY = max<min?max:min;
}
float getMaxY()
{
return MaxY;
}
float getMaxX()
{
return MaxX;
}
float getMinY()
{
return MinY;
}
float getMinX()
{
return MinX;
}
float getMapX()
{
return MapX;
}
float getMapY()
{
return MaxY;
}
void setMaxMinX(float max, float min)
{
MaxX = max>min?max:min; MinX = max<min?max:min;
}
void setOrigin(Point O)
{
Origin = O;
}
void addValue(float x,float y)
{
Value.addElement(new SeriesValue(Value.size(), x, y, true));
}
void addValue(float x,float y,String s)
{
SeriesValue t = new SeriesValue(Value.size(), x, y, true);
t.TextX = s;
Value.addElement(t);
}
void addValue(float x,float y,String Xs,String Ys)
{
SeriesValue t = new SeriesValue(Value.size(), x, y, true);
t.TextX = Xs; t.TextY = Ys;
Value.addElement(t);
}
void setTitle(String s)
{
Title = s;
}
String getTitle()
{
return Title;
}
void draw(Graphics g)
{
int i;
if(Value.size()<=0)
return;
int x ;
int y ;
Vector xy = new Vector();
g.setColor(color);
float tx;
float ty;
boolean tb;
// System.out.println("mapx,y:"+MapX+","+MapY+" x,y:"+MinX+","+MinY);
for(i=0 ; i<Value.size(); i++)
{
ty = ((SeriesValue)Value.elementAt(i)).y;
tx = ((SeriesValue)Value.elementAt(i)).x;
tb = ((SeriesValue)Value.elementAt(i)).Use;
// System.out.println(ty);
if(tx<MinX || tx>MaxX || !tb)
continue;
y = Origin.y - Math.round( (ty - MinY)/MapY );
x = Origin.x + Math.round( (tx - MinX)/MapX );
xy.addElement(new Point(x, y));
}
g.setColor(color);
for(i=0; i<xy.size()-1; i++)
{
g.drawLine(((Point)xy.elementAt(i)).x, ((Point)xy.elementAt(i)).y,
((Point)xy.elementAt(i+1)).x, ((Point)xy.elementAt(i+1)).y);
}
}
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -