?? java2demo.java~1~
字號:
package java2d;import java.awt.*;import java.awt.event.*;import java.util.*;import java.awt.font.TextLayout;import java.awt.font.FontRenderContext;import javax.swing.*;import javax.swing.border.*;import java.sql.*;public class Java2Demo extends JPanel{ static plotArray pArray; static plotArrayLY pArrayLY; static plotArrayRX pArrayRX; static plotArrayRY pArrayRY; static float al1=(float)7.0; static float al2=(float)9.5; static Connection connection; static dataPool datapool; static Java2Demo demo; static GlobalControls controls; static MemoryMonitor memorymonitor; static PerformanceMonitor performancemonitor; static JTabbedPane tabbedPane; static JLabel progressLabel,welcome,title; static JProgressBar progressBar; static DemoGroup group[]; static Color backgroundColor; static Intro intro; private ResourceBundle bundle; int textLocation ; String text; javax.swing.Timer timer; static String[][] demos0 = { {"振動", "風機左X", "風機左Y", "風機右X", "風機右Y"}, {"位移", "風機左Z", "風機右Z",}, {"溫度", "風機左", "風機右", "電機左","電機右"}, {"電流","電流1","電流2","電流3"}, {"電壓","電壓"} }; static String[][] demos = { {"振動", "LX", "LY", "RX", "RY"}, {"位移", "LZ", "RZ",}, {"溫度", "FL", "FR", "DL","DR"}, {"電流","C1","C2","C3"}, {"電壓","dianya"} }; private GlobalPanel gp; /** * Construct the Java2D Demo. */ public Java2Demo() { pArray=new plotArray(); pArrayLY=new plotArrayLY(); pArrayRX=new plotArrayRX(); pArrayRY=new plotArrayRY(); textLocation = 0; datapool=new dataPool(); connection=datapool.con; System.out.println("Java2Demo's connection has been initated!"); setLayout(new BorderLayout()); setBorder(new EtchedBorder()); bundle = null; text = getString("welcome.text"); welcome.setFont(new Font("serif", Font.BOLD+Font.ITALIC, 40)); title.setFont(new Font("serif", Font.BOLD+Font.ITALIC, 50)); title.setText("武鋼煉鐵廠 在線監測系統"); progressBar.setMaximum(text.length()+5); timer = new javax.swing.Timer(100, createTextLoadAction()); timer.start(); intro = new Intro(); progressBar.setValue(progressBar.getValue() + 1); UIManager.put("Button.margin", new Insets(0,0,0,0)); controls = new GlobalControls(); memorymonitor = new MemoryMonitor(); performancemonitor = new PerformanceMonitor(); GlobalPanel gp = new GlobalPanel(); tabbedPane = new JTabbedPane(); tabbedPane.setFont(new Font("serif", Font.PLAIN, 12)); tabbedPane.addTab("", new J2DIcon(), gp); tabbedPane.addChangeListener(gp); group = new DemoGroup[demos.length]; for (int i = 0; i < demos.length; i++) { // progressLabel.setText("Loading demos." + demos[i][0]); group[i] = new DemoGroup(demos[i][0]); tabbedPane.addTab(demos0[i][0], null); progressBar.setValue(progressBar.getValue() + 1); } while(textLocation!=28){} timer.stop(); timer = null; add(tabbedPane, BorderLayout.CENTER); } public String getString(String key) { String value = "nada"; if(bundle == null) { bundle = ResourceBundle.getBundle("welcome"); } try { value = bundle.getString(key); } catch (MissingResourceException e) { System.out.println("java.util.MissingResourceException: Couldn't find value for: " + key); } return value; } public Action createTextLoadAction() { return new AbstractAction("text load action") { public void actionPerformed (ActionEvent e) { if(textLocation<text.length()) { welcome.setText(welcome.getText()+text.substring(textLocation, textLocation+1)); progressBar.setValue(progressBar.getValue() + 1); textLocation++; System.out.println(""+textLocation); } } }; } public void start() { pArray.start(); pArrayLY.start(); pArrayRX.start(); pArrayRY.start(); if (tabbedPane.getSelectedIndex() == 0) { intro.start(); } else { group[tabbedPane.getSelectedIndex()-1].setup(false); if (memorymonitor.surf.thread == null) { memorymonitor.surf.start(); } if (performancemonitor.surf.thread == null) { performancemonitor.surf.start(); } } } public void stop() { if (tabbedPane.getSelectedIndex() == 0) { intro.stop(); } else { memorymonitor.surf.stop(); // performancemonitor.surf.stop(); int i = tabbedPane.getSelectedIndex()-1; group[i].shutDown(group[i].getPanel()); } datapool.closeConnection(); pArray.stop(); pArrayLY.stop(); pArrayRX.stop(); pArrayRY.stop(); } static void addToGridBag(JPanel panel, Component comp, int x, int y, int w, int h, double weightx, double weighty) { GridBagLayout gbl = (GridBagLayout) panel.getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = x; c.gridy = y; c.gridwidth = w; c.gridheight = h; c.weightx = weightx; c.weighty = weighty; panel.add(comp); gbl.setConstraints(comp, c); } /** * The Icon for the Intro tab. */ static class J2DIcon implements Icon { private static Color blue = new Color(94, 105, 176); private static Color black = new Color(20, 20, 20); private static Font font = new Font("serif", Font.BOLD, 12); private FontRenderContext frc = new FontRenderContext(null,true,true); private TextLayout tl = new TextLayout("主界面", font, frc); public void paintIcon(Component c, Graphics g, int x, int y ) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setFont(font); if (tabbedPane.getSelectedIndex() == 0) { g2.setColor(blue); } else { g2.setColor(black); } tl.draw(g2, x, y + 15); } public int getIconWidth() { return 40; } public int getIconHeight() { return 22; } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -