⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rz.java~2~

📁 风机在线监测系统,采用sqlserver数据库,有问题联系我
💻 JAVA~2~
字号:
package java2d;

import java.awt.*;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.sql.Connection;

public class RZ 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 RZ() {
        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("S2", "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 + -