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

📄 globalcontrols.java

📁 风机在线监测系统,采用sqlserver数据库,有问题联系我
💻 JAVA
字号:
package java2d;import java.awt.*;import java.awt.image.BufferedImage;import javax.swing.JPanel;import javax.swing.border.EtchedBorder;import javax.swing.border.TitledBorder;/** * Global Controls panel for changing graphic attributes of * the demo surface. */public class GlobalControls extends JPanel {    Surface surf;    public GlobalControls() {        setLayout(new GridBagLayout());        setBorder(new TitledBorder(new EtchedBorder(), "报警信息"));        add(surf = new Surface());    }    public class Surface extends JPanel implements Runnable {        public float al1 = (float) 7.0;        public float al2 = (float) 9.5;        public Thread thread;        private BufferedImage bimg;        private Font font = new Font("serif", Font.BOLD, 18);        public Surface() {            //setBackground(Color.black);        }        public Dimension getMinimumSize() {            return getPreferredSize();        }        public Dimension getMaximumSize() {            return getPreferredSize();        }        public Dimension getPreferredSize() {            return new Dimension(135, 315);        }        public void drawLed(Graphics2D g, int type, int x, int y) {            switch (type) {            case 1:                g.setColor(new Color(0, 255, 0));                break;            case 2:                g.setColor(new Color(255, 255, 255));                break;            case 3:                g.setColor(new Color(251, 251, 19));                break;            case 4:                g.setColor(new Color(255, 0, 0));                break;            default:                g.setColor(new Color(0, 255, 0));            }            g.fillOval(x, y, 20, 20);        }        public int alarm(float val, float al1, float al2) {            int type = 1;            if (val >= al1 && val < al2) {                type = 3;            } else            if (val >= al2) {                type = 4;            } else            if (val < al1) {                type = 1;            } else {                type = 2;            }            return type;        }        public void paint(Graphics g) {            if (bimg != null) {                g.drawImage(bimg, 0, 0, this);            }        }        public void start() {            thread = new Thread(this);            thread.setPriority(Thread.MIN_PRIORITY);            thread.setName("AlarmInformation");            thread.start();        }        public synchronized void stop() {            thread = null;            notify();        }        public void run() {            Thread me = Thread.currentThread();            while (thread == me && !isShowing() || getSize().width == 0) {                try {                    thread.sleep(500);                } catch (InterruptedException e) {                    return;                }            }            Dimension d = getSize();            bimg = (BufferedImage) createImage(d.width, d.height);            Graphics2D big = bimg.createGraphics();            big.setFont(font);            FontMetrics fm = big.getFontMetrics();            int ascent = fm.getAscent();            int descent = fm.getDescent();            while (thread == me && isShowing()) {                //big.setBackground(getBackground());                big.setBackground(Color.black);                big.clearRect(0, 0, d.width, d.height);                float[] H = new float[7];                float[] L = new float[7];                if (Java2Demo.datapool != null) {                    H = Java2Demo.datapool.getdataF("high_frequency_table");                    L = Java2Demo.datapool.getdataF("low_frequency_table");                }                big.setColor(Color.black);                int ssH = 1;                drawLed(big, alarm(H[2], al1, al2), 5, 8);                big.drawString("风机左X方向", 30, 25);                drawLed(big, alarm(H[0], al1, al2), 5, 38);                big.drawString("风机左Y方向", 30, 55);                drawLed(big, alarm(H[4], al1, al2), 5, 68);                big.drawString("风机左Z方向", 30, 85);                drawLed(big, alarm(H[3], al1, al2), 5, 98);                big.drawString("风机右X方向", 30, 115);                drawLed(big, alarm(H[1], al1, al2), 5, 128);                big.drawString("风机右Y方向", 30, 145);                drawLed(big, alarm(H[5], al1, al2), 5, 158);                big.drawString("风机右Z方向", 30, 175);                drawLed(big, alarm(L[0], al1, al2), 5, 188);                big.drawString("风机左温度", 30, 205);                drawLed(big, alarm(L[1], al1, al2), 5, 218);                big.drawString("风机右温度", 30, 235);                drawLed(big, alarm(L[2], al1, al2), 5, 248);                big.drawString("电机左温度", 30, 265);                drawLed(big, alarm(L[3], al1, al2), 5, 278);                big.drawString("电机右温度", 30, 295);                repaint();                try {                    thread.sleep(500);                } catch (InterruptedException e) {                    break;                }            }            thread = null;        }    } // End Surface}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -