?? lz.java
字號:
package java2d;
import java.awt.*;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.sql.Connection;
public class LZ extends AnimatingSurface {
//public long sleepAmount = 500;
private Connection con;
private String samptime, disptime;
private int aw, ah;
private int columnInc;
private int pts[];
private int ptNum;
private float rtd;
private double doubleResult;
private Rectangle graphOutlineRect = new Rectangle();
private Rectangle2D BartRect = new Rectangle2D.Float();
private Rectangle2D muRect = new Rectangle2D.Float();
private Line2D graphLine = new Line2D.Float();
private Color graphColor = new Color(46, 139, 87);
private Color mfColor = new Color(0, 100, 0);
private float rectW = (float) 30;
public LZ() {
setBackground(Color.white);
name = "風機左Z";
if (Java2Demo.connection != null) {
con = Java2Demo.connection;
}
}
public void reset(int w, int h) {
}
public void step(int w, int h) {
}
private void getdata() {
if (Java2Demo.datapool != null) {
rtd = Java2Demo.datapool.getdataF("S1", "high_frequency_table");
realdata = rtd;
samptime = Java2Demo.datapool.getdataT("high_frequency_table");
disptime = samptime.substring(11, 19);
System.out.println(disptime);
}
}
public void render(int w, int h, Graphics2D g2) {
g2.setBackground(Color.gray);
g2.clearRect(0, 0, w, h);
g2.setColor(graphColor);
//draw grahpicoutlinerect
int graphX = 20;
int graphY = 60;
//int graphW=w-graphX-5;
int graphW = w - graphX - 20;
int graphH = h - graphY - 20;
//
//System.out.println("the width is:"+graphW);
// int LT=graphW/2;
graphOutlineRect.setRect(graphX, graphY, graphW, graphH);
g2.draw(graphOutlineRect);
int graphRow = graphH / 10;
//draw row...
/*for (int j = graphY; j <= graphH+graphY; j += graphRow) {
graphLine.setLine(graphX,j,graphX+graphW,j);
g2.draw(graphLine);
}*/
int plotY = graphY + 5 * graphRow;
int barX = graphX + graphW / 2 - 30;
g2.draw3DRect(barX, graphY, (int) rectW, graphH, false);
g2.setColor(Color.black);
g2.fill3DRect(barX + 2, graphY + 2, (int) rectW - 4, graphH - 4, false);
//繪刻度
for (int i = 0; i < 10; i++) {
g2.drawLine(barX, graphY + i * graphRow, barX - 4,
graphY + i * graphRow);
}
g2.drawLine(barX, graphY + graphH, barX - 4, graphY + graphH);
for (int i = 5; i >= 0; i--) {
g2.drawString("" + i, barX - 13, graphY + (5 - i) * graphRow + 4);
}
//plot
g2.setColor(Color.yellow);
g2.drawString("風機左Z方向 位移實時棒圖 單位:毫米", graphX + graphW / 4,
graphY / 2);
//get data
getdata();
//float rectX=(float)(graphX+graphW/2-40);
float data = (rtd * graphH / 20);
float rectY = (data > 0) ? (plotY - data) : plotY;
Intro.surface.changeColor(g2,
Intro.surface.alarm(Math.abs(rtd),
Java2Demo.al1, Java2Demo.al2));
BartRect.setRect(barX + 12, rectY, 6, Math.abs(data));
//g2.draw(BartRect);
g2.fill(BartRect);
//set samptime
g2.setColor(Color.yellow);
g2.drawString(disptime, graphX + graphW - 27, graphY + graphH + 12);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -