MainUI.java 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. package com.its.pis.ui;
  2. import com.intellij.uiDesigner.core.GridConstraints;
  3. import com.intellij.uiDesigner.core.GridLayoutManager;
  4. import com.intellij.uiDesigner.core.Spacer;
  5. import com.its.app.utils.SysUtils;
  6. import com.its.pis.domain.NET;
  7. import com.its.pis.entity.TbPisInfr;
  8. import com.its.pis.global.AppRepository;
  9. import com.sun.management.OperatingSystemMXBean;
  10. import lombok.Getter;
  11. import lombok.extern.slf4j.Slf4j;
  12. import javax.swing.Timer;
  13. import javax.swing.*;
  14. import javax.swing.border.MatteBorder;
  15. import javax.swing.plaf.FontUIResource;
  16. import javax.swing.table.DefaultTableCellRenderer;
  17. import javax.swing.table.TableCellRenderer;
  18. import javax.swing.table.TableColumnModel;
  19. import javax.swing.text.StyleContext;
  20. import java.awt.*;
  21. import java.awt.datatransfer.Clipboard;
  22. import java.awt.datatransfer.StringSelection;
  23. import java.awt.event.ActionEvent;
  24. import java.awt.event.ActionListener;
  25. import java.awt.event.MouseAdapter;
  26. import java.awt.event.MouseEvent;
  27. import java.io.File;
  28. import java.io.IOException;
  29. import java.lang.management.ManagementFactory;
  30. import java.util.List;
  31. import java.util.*;
  32. @Slf4j
  33. @Getter
  34. public class MainUI {
  35. private static MainUI _instance = null;
  36. private SubUIController subUIController = null;
  37. private JFrame jFrame = null;
  38. private final OperatingSystemMXBean osBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
  39. private Timer timer;
  40. private Long tick = Long.valueOf(0);
  41. private TbPisInfr selObj = null;
  42. private CtlrSttsTableModel ctlrSttsTableModel = null;
  43. private TableCellRenderer cellRenderer = new CtlrSttsTableCellRenderer();
  44. private JPanel rootPanel;
  45. private JPanel pnlCtlr;
  46. private JPanel pnlLog;
  47. private JPanel pnlLogTitle;
  48. private JPanel pnlCtlrTitle;
  49. private JButton btnLogDirOpen;
  50. private JButton btnLogPause;
  51. private JCheckBox chkLogPause;
  52. private JLabel lblSystime;
  53. private JPanel pnlStatusBar;
  54. private JTable tblCtlrList;
  55. private JTextArea taLog;
  56. private JButton btnLogCopy;
  57. private JLabel lblTotal;
  58. private JLabel lblError;
  59. private JLabel lblCpuRate;
  60. private JLabel lblMemoryUsage;
  61. private JPanel pnlControl;
  62. private JButton btnImage;
  63. private JButton btnInitialize;
  64. private JButton btnRlTimeRequest;
  65. private JButton btnDisconnect;
  66. private JTextField txtName;
  67. private JTextField txtId;
  68. public static MainUI getInstance() {
  69. return _instance;
  70. }
  71. public void displaySystime() {
  72. lblSystime.setText(" " + SysUtils.getSysTimeStr() + " ");
  73. updateCommSttsTotal();
  74. }
  75. public void displayResource() {
  76. //OperatingSystemMXBean osBean = (OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
  77. long memoryUsage = Math.round(((double) (osBean.getTotalPhysicalMemorySize() - osBean.getFreePhysicalMemorySize())) / (double) osBean.getTotalPhysicalMemorySize() * 100.0);
  78. lblMemoryUsage.setText(String.valueOf(memoryUsage));
  79. double cpuLoad = osBean.getSystemCpuLoad();
  80. if (cpuLoad >= 0.0 && cpuLoad <= 1.0) {
  81. lblCpuRate.setText(String.valueOf(Math.round(cpuLoad * 100.0)));
  82. } else {
  83. lblCpuRate.setText("---");
  84. }
  85. // if (osBean instanceof com.sun.management.OperatingSystemMXBean) {
  86. // com.sun.management.OperatingSystemMXBean nativeOsBean = (com.sun.management.OperatingSystemMXBean)osBean;
  87. // log.error("CPU LOAD: {}", Math.ceil(nativeOsBean.getSystemCpuLoad() * 100.0));
  88. // }
  89. // else {
  90. // log.error("You're not using Oracle Java nor using the native library. You won't be able to read some native data");
  91. // }
  92. }
  93. public MainUI(JFrame jFrame) {
  94. System.setProperty("awt.useSystemAAFontSettings", "false"); // AntiAliasing false
  95. this.jFrame = jFrame;
  96. if (_instance == null) {
  97. _instance = this;
  98. subUIController = new SubUIController(jFrame);
  99. subUIController.setVisible(false);
  100. }
  101. //OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
  102. //osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
  103. //osBean = (OperatingSystemMXBean) ManagementFactoryHelper.getOperatingSystemMXBean();
  104. try {
  105. Font font = Font.createFont(Font.TRUETYPE_FONT, new File("fonts/D2Coding.ttc"));
  106. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  107. ge.registerFont(font);
  108. } catch (FontFormatException e) {
  109. } catch (IOException e) {
  110. }
  111. //taLog.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
  112. Font d2font = new Font("D2Coding", Font.PLAIN, 14);
  113. if (d2font != null) {
  114. taLog.setFont(d2font);
  115. }
  116. displaySystime();
  117. displayResource();
  118. timer = new Timer(1000, new ActionListener() {
  119. public void actionPerformed(ActionEvent evt) {
  120. displaySystime();
  121. tick++;
  122. if (tick % 5 == 0) {
  123. displayResource();
  124. }
  125. }
  126. });
  127. timer.start();
  128. chkLogPause.setFocusable(false);
  129. btnLogPause.setFocusable(false);
  130. btnLogDirOpen.setFocusable(false);
  131. btnLogCopy.setFocusable(false);
  132. btnLogPause.addActionListener(new ActionListener() {
  133. @Override
  134. public void actionPerformed(ActionEvent e) {
  135. taLog.setText(null);
  136. }
  137. });
  138. btnLogDirOpen.addActionListener(new ActionListener() {
  139. @Override
  140. public void actionPerformed(ActionEvent e) {
  141. Runtime rt = Runtime.getRuntime();
  142. try {
  143. rt.exec("explorer.exe logs");
  144. } catch (IOException ex) {
  145. throw new RuntimeException(ex);
  146. }
  147. }
  148. });
  149. chkLogPause.addActionListener(new ActionListener() {
  150. @Override
  151. public void actionPerformed(ActionEvent e) {
  152. JTextAreaOutputStream.isLoggingPause = chkLogPause.isSelected();
  153. }
  154. });
  155. btnLogCopy.addActionListener(new ActionListener() {
  156. @Override
  157. public void actionPerformed(ActionEvent e) {
  158. StringSelection stringSelection = new StringSelection(taLog.getText());
  159. Clipboard clpBrd = Toolkit.getDefaultToolkit().getSystemClipboard();
  160. clpBrd.setContents(stringSelection, null);
  161. }
  162. });
  163. tblCtlrList.addMouseListener(new MouseAdapter() {
  164. public void mouseClicked(MouseEvent me) {
  165. // double click
  166. if (me.getClickCount() == 2) {
  167. if (!updateControllerInfo()) {
  168. if (subUIController.isVisible()) {
  169. subUIController.setVisible(false);
  170. }
  171. }
  172. }
  173. }
  174. });
  175. btnDisconnect.addActionListener(new ActionListener() {
  176. @Override
  177. public void actionPerformed(ActionEvent e) {
  178. controlController(1);
  179. }
  180. });
  181. btnRlTimeRequest.addActionListener(new ActionListener() {
  182. @Override
  183. public void actionPerformed(ActionEvent e) {
  184. controlController(2);
  185. }
  186. });
  187. btnInitialize.addActionListener(new ActionListener() {
  188. @Override
  189. public void actionPerformed(ActionEvent e) {
  190. controlController(3);
  191. }
  192. });
  193. btnImage.addActionListener(new ActionListener() {
  194. @Override
  195. public void actionPerformed(ActionEvent e) {
  196. controlController(4);
  197. }
  198. });
  199. }
  200. /**
  201. * 제어기 명령 처리
  202. *
  203. * @param type
  204. */
  205. public void controlController(int type) {
  206. if (selObj == null) {
  207. JOptionPane.showMessageDialog(getRootPanel(), "주차시스템이 선택되지 않았습니다. 목록을 더블클릭하여 주차시스템을 선택하세요.", "주차시스템 선택", JOptionPane.ERROR_MESSAGE);
  208. return;
  209. }
  210. if (selObj.getNetState() == NET.CLOSED) {
  211. JOptionPane.showMessageDialog(getRootPanel(), "주차시스템이 현재 연결이 되어 있지 않습니다.", "주차시스템 연결 상태", JOptionPane.ERROR_MESSAGE);
  212. return;
  213. }
  214. String message, title;
  215. switch (type) {
  216. case 1:
  217. message = "주차시스템과 연결을 종료 하시겠습니까?";
  218. title = "주차시스템 연결 종료";
  219. break;
  220. case 2:
  221. message = "주차장 실시간 정보를 요청 하시겠습니까?";
  222. title = "주차장 실시간 정보 요청";
  223. break;
  224. case 3:
  225. message = "제어기를 초기화 하시겠습니까?";
  226. title = "제어기 초기화";
  227. break;
  228. case 4:
  229. message = "제어기의 정지영상 정보를 요청하시겠습니까?";
  230. title = "제어기 정지영상 요청";
  231. break;
  232. default:
  233. return;
  234. }
  235. if (JOptionPane.showConfirmDialog(getRootPanel(), message, title, JOptionPane.YES_NO_OPTION) != 0) {
  236. return;
  237. }
  238. boolean result = false;
  239. switch (type) {
  240. case 1:
  241. result = selObj.channelClose();
  242. break;
  243. case 2:
  244. result = selObj.requestRlTimeInfo();
  245. break;
  246. case 3:
  247. result = false;//selObj.initialize();
  248. break;
  249. case 4:
  250. result = false;//selObj.stopImage((byte) 0x01);
  251. break;
  252. default:
  253. return;
  254. }
  255. if (!result) {
  256. JOptionPane.showMessageDialog(getRootPanel(), "명령 전송이 실패 하였습니다.", title, JOptionPane.ERROR_MESSAGE);
  257. }
  258. }
  259. public boolean updateControllerInfo() {
  260. if (subUIController.isVisible()) {
  261. subUIController.setVisible(false);
  262. }
  263. int row = tblCtlrList.getSelectedRow();
  264. if (row < 0) {
  265. return false;
  266. }
  267. txtId.setText("");
  268. txtName.setText("");
  269. CtlrSttsTableModel tableModel = (CtlrSttsTableModel) tblCtlrList.getModel();
  270. selObj = tableModel.getControllerInfo(row);
  271. if (selObj != null) {
  272. txtId.setText(selObj.getPIS_NMBR());
  273. txtName.setText(selObj.getPIS_NM());
  274. subUIController.updateInfo(selObj);
  275. if (!subUIController.isVisible()) {
  276. //subUIController.setVisible(true);
  277. }
  278. return true;
  279. }
  280. return false;
  281. }
  282. /**
  283. * 목록 헤더 생성
  284. */
  285. private void initTblListUI(List<TbPisInfr> ctlrList) {
  286. this.ctlrSttsTableModel = new CtlrSttsTableModel(ctlrList);
  287. tblCtlrList.setModel(this.ctlrSttsTableModel);
  288. tblCtlrList.getTableHeader().setOpaque(false);
  289. tblCtlrList.getTableHeader().setBackground(Color.LIGHT_GRAY);
  290. tblCtlrList.setRowMargin(1);
  291. //tblCtlrList.setGridColor(Color.LIGHT_GRAY);
  292. tblCtlrList.setRowHeight(tblCtlrList.getRowHeight() + 5);
  293. //tblCtlrList.setRowSelectionAllowed(true);
  294. //tblCtlrList.setColumnSelectionAllowed(false);
  295. tblCtlrList.setBackground(Color.WHITE);
  296. tblCtlrList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  297. //tblCtlrList.setAutoCreateRowSorter(true); // sorting
  298. //tblCtlrList.addMouseListener(new ListMouseListener(null));
  299. TableColumnModel getColumnModel = tblCtlrList.getColumnModel();
  300. getColumnModel.getColumn(0).setPreferredWidth(30); // "S",
  301. getColumnModel.getColumn(1).setPreferredWidth(50); // "번호",
  302. getColumnModel.getColumn(2).setPreferredWidth(170); // "주차장ID",
  303. getColumnModel.getColumn(3).setPreferredWidth(180); // "명칭",
  304. getColumnModel.getColumn(4).setPreferredWidth(120); // "IP",
  305. getColumnModel.getColumn(5).setPreferredWidth(55); // "PORT",
  306. getColumnModel.getColumn(6).setPreferredWidth(70); // "연결상태",
  307. getColumnModel.getColumn(7).setPreferredWidth(50); // "유형",
  308. getColumnModel.getColumn(8).setPreferredWidth(50); // "주기",
  309. getColumnModel.getColumn(9).setPreferredWidth(100); // "END-POINT",
  310. getColumnModel.getColumn(10).setPreferredWidth(150); // "TOKEN",
  311. getColumnModel.getColumn(11).setPreferredWidth(140); // "connect time",
  312. getColumnModel.getColumn(12).setPreferredWidth(140); // "disconnect time"
  313. getColumnModel.getColumn(0).setMaxWidth(30);
  314. getColumnModel.getColumn(0).setMinWidth(30);
  315. getColumnModel.getColumn(0).setResizable(false);
  316. getColumnModel.getColumn(9).setMinWidth(0); // Must be set before maxWidth!!
  317. getColumnModel.getColumn(9).setMaxWidth(0);
  318. getColumnModel.getColumn(9).setWidth(0);
  319. getColumnModel.getColumn(9).setResizable(false);
  320. getColumnModel.getColumn(10).setMinWidth(0); // Must be set before maxWidth!!
  321. getColumnModel.getColumn(10).setMaxWidth(0);
  322. getColumnModel.getColumn(10).setWidth(0);
  323. getColumnModel.getColumn(10).setResizable(false);
  324. Color color = UIManager.getColor("Table.gridColor");
  325. MatteBorder border = new MatteBorder(1, 1, 0, 0, color);
  326. tblCtlrList.setBorder(border);
  327. DefaultTableCellRenderer centerAlign = new DefaultTableCellRenderer();
  328. centerAlign.setHorizontalAlignment(JLabel.CENTER);
  329. for (int ii = 0; ii < getColumnModel.getColumnCount(); ii++) {
  330. getColumnModel.getColumn(ii).setCellRenderer(cellRenderer);
  331. }
  332. }
  333. public void updateCommSttsTotal() {
  334. int ctlrTotal = 0;
  335. int ctlrError = 0;
  336. for (Map.Entry<String, TbPisInfr> e : AppRepository.getInstance().getPisInfrMap().entrySet()) {
  337. TbPisInfr obj = e.getValue();
  338. ctlrTotal++;
  339. if (!"CMS0".equals(obj.getStts().getCMNC_STTS_CD())) {
  340. ctlrError++;
  341. }
  342. }
  343. lblTotal.setText(" " + ctlrTotal + " ");
  344. lblError.setText(" " + ctlrError + " ");
  345. }
  346. public void LoadControllerInfo() {
  347. SortedMap<Integer, TbPisInfr> ctlrMap = new TreeMap<>();
  348. for (Map.Entry<String, TbPisInfr> e : AppRepository.getInstance().getPisInfrMap().entrySet()) {
  349. TbPisInfr obj = e.getValue();
  350. ctlrMap.put(Integer.valueOf(obj.getPIS_NMBR()), obj);
  351. }
  352. List<TbPisInfr> ctlrList = new ArrayList<TbPisInfr>(ctlrMap.values());
  353. initTblListUI(ctlrList);
  354. updateCommSttsTotal();
  355. }
  356. public void updateCtlrStts(TbPisInfr obj) {
  357. if (this.ctlrSttsTableModel == null) {
  358. return;
  359. }
  360. for (int ii = 0; ii < this.ctlrSttsTableModel.getRowCount(); ii++) {
  361. if (obj.getPIS_NMBR().equals(ctlrSttsTableModel.getValueAt(ii, 1).toString())) {
  362. int modelRow = tblCtlrList.convertRowIndexToModel(ii);
  363. this.ctlrSttsTableModel.setValue(obj, ii, modelRow);
  364. break;
  365. }
  366. }
  367. CtlrSttsTableModel tableModel = (CtlrSttsTableModel) tblCtlrList.getModel();
  368. if (tableModel != null) {
  369. tableModel.fireTableDataChanged();
  370. }
  371. }
  372. {
  373. // GUI initializer generated by IntelliJ IDEA GUI Designer
  374. // >>> IMPORTANT!! <<<
  375. // DO NOT EDIT OR ADD ANY CODE HERE!
  376. $$$setupUI$$$();
  377. }
  378. /**
  379. * Method generated by IntelliJ IDEA GUI Designer
  380. * >>> IMPORTANT!! <<<
  381. * DO NOT edit this method OR call it in your code!
  382. *
  383. * @noinspection ALL
  384. */
  385. private void $$$setupUI$$$() {
  386. rootPanel = new JPanel();
  387. rootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
  388. pnlCtlr = new JPanel();
  389. pnlCtlr.setLayout(new GridLayoutManager(3, 1, new Insets(10, 4, 0, 4), -1, -1));
  390. rootPanel.add(pnlCtlr, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(-1, 280), new Dimension(-1, 280), new Dimension(-1, 280), 0, false));
  391. pnlCtlrTitle = new JPanel();
  392. pnlCtlrTitle.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 2), -1, -1));
  393. pnlCtlr.add(pnlCtlrTitle, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
  394. final JLabel label1 = new JLabel();
  395. Font label1Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label1.getFont());
  396. if (label1Font != null) label1.setFont(label1Font);
  397. label1.setHorizontalAlignment(2);
  398. label1.setHorizontalTextPosition(11);
  399. label1.setIcon(new ImageIcon(getClass().getResource("/static/image/controller.png")));
  400. label1.setText("주차정보 시스템");
  401. pnlCtlrTitle.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  402. final Spacer spacer1 = new Spacer();
  403. pnlCtlrTitle.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
  404. final JLabel label2 = new JLabel();
  405. Font label2Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label2.getFont());
  406. if (label2Font != null) label2.setFont(label2Font);
  407. label2.setText("주차정보시스템 전체: ");
  408. pnlCtlrTitle.add(label2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  409. final JLabel label3 = new JLabel();
  410. Font label3Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label3.getFont());
  411. if (label3Font != null) label3.setFont(label3Font);
  412. label3.setText("통신 이상: ");
  413. pnlCtlrTitle.add(label3, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  414. lblTotal = new JLabel();
  415. Font lblTotalFont = this.$$$getFont$$$("Malgun Gothic", Font.BOLD, 12, lblTotal.getFont());
  416. if (lblTotalFont != null) lblTotal.setFont(lblTotalFont);
  417. lblTotal.setHorizontalAlignment(0);
  418. lblTotal.setHorizontalTextPosition(0);
  419. lblTotal.setText(" -");
  420. pnlCtlrTitle.add(lblTotal, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  421. lblError = new JLabel();
  422. Font lblErrorFont = this.$$$getFont$$$("Malgun Gothic", Font.BOLD, 12, lblError.getFont());
  423. if (lblErrorFont != null) lblError.setFont(lblErrorFont);
  424. lblError.setForeground(new Color(-65536));
  425. lblError.setHorizontalAlignment(0);
  426. lblError.setHorizontalTextPosition(0);
  427. lblError.setText(" -");
  428. pnlCtlrTitle.add(lblError, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  429. final JScrollPane scrollPane1 = new JScrollPane();
  430. pnlCtlr.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
  431. tblCtlrList = new JTable();
  432. Font tblCtlrListFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, tblCtlrList.getFont());
  433. if (tblCtlrListFont != null) tblCtlrList.setFont(tblCtlrListFont);
  434. scrollPane1.setViewportView(tblCtlrList);
  435. pnlControl = new JPanel();
  436. pnlControl.setLayout(new GridLayoutManager(1, 8, new Insets(0, 0, 0, 2), 1, 1));
  437. pnlCtlr.add(pnlControl, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
  438. btnImage = new JButton();
  439. Font btnImageFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnImage.getFont());
  440. if (btnImageFont != null) btnImage.setFont(btnImageFont);
  441. btnImage.setText("정지영상");
  442. pnlControl.add(btnImage, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  443. final Spacer spacer2 = new Spacer();
  444. pnlControl.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
  445. btnInitialize = new JButton();
  446. Font btnInitializeFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnInitialize.getFont());
  447. if (btnInitializeFont != null) btnInitialize.setFont(btnInitializeFont);
  448. btnInitialize.setText("초기화");
  449. pnlControl.add(btnInitialize, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  450. btnRlTimeRequest = new JButton();
  451. Font btnRlTimeRequestFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnRlTimeRequest.getFont());
  452. if (btnRlTimeRequestFont != null) btnRlTimeRequest.setFont(btnRlTimeRequestFont);
  453. btnRlTimeRequest.setText("실시간 주차정보 요청");
  454. pnlControl.add(btnRlTimeRequest, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  455. btnDisconnect = new JButton();
  456. Font btnDisconnectFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnDisconnect.getFont());
  457. if (btnDisconnectFont != null) btnDisconnect.setFont(btnDisconnectFont);
  458. btnDisconnect.setText("연결끊기");
  459. pnlControl.add(btnDisconnect, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  460. txtName = new JTextField();
  461. txtName.setEditable(false);
  462. Font txtNameFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, txtName.getFont());
  463. if (txtNameFont != null) txtName.setFont(txtNameFont);
  464. txtName.setHorizontalAlignment(2);
  465. txtName.setText("제어기 명칭");
  466. pnlControl.add(txtName, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(200, -1), new Dimension(200, -1), new Dimension(200, -1), 0, false));
  467. txtId = new JTextField();
  468. txtId.setEditable(false);
  469. Font txtIdFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, txtId.getFont());
  470. if (txtIdFont != null) txtId.setFont(txtIdFont);
  471. txtId.setHorizontalAlignment(0);
  472. txtId.setText("ID");
  473. pnlControl.add(txtId, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), new Dimension(100, -1), new Dimension(100, -1), 0, false));
  474. final JLabel label4 = new JLabel();
  475. Font label4Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label4.getFont());
  476. if (label4Font != null) label4.setFont(label4Font);
  477. label4.setIcon(new ImageIcon(getClass().getResource("/static/image/select.png")));
  478. label4.setText("선택한 제어기 ");
  479. pnlControl.add(label4, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  480. pnlLog = new JPanel();
  481. pnlLog.setLayout(new GridLayoutManager(2, 1, new Insets(0, 4, 0, 4), -1, -1));
  482. rootPanel.add(pnlLog, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
  483. pnlLogTitle = new JPanel();
  484. pnlLogTitle.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 2), 1, 1));
  485. pnlLog.add(pnlLogTitle, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
  486. final JLabel label5 = new JLabel();
  487. Font label5Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label5.getFont());
  488. if (label5Font != null) label5.setFont(label5Font);
  489. label5.setHorizontalAlignment(2);
  490. label5.setIcon(new ImageIcon(getClass().getResource("/static/image/logging.png")));
  491. label5.setText("시스템 로그");
  492. pnlLogTitle.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  493. final Spacer spacer3 = new Spacer();
  494. pnlLogTitle.add(spacer3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
  495. btnLogDirOpen = new JButton();
  496. Font btnLogDirOpenFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnLogDirOpen.getFont());
  497. if (btnLogDirOpenFont != null) btnLogDirOpen.setFont(btnLogDirOpenFont);
  498. btnLogDirOpen.setHorizontalTextPosition(0);
  499. btnLogDirOpen.setText("로그 폴더");
  500. pnlLogTitle.add(btnLogDirOpen, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  501. btnLogPause = new JButton();
  502. Font btnLogPauseFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnLogPause.getFont());
  503. if (btnLogPauseFont != null) btnLogPause.setFont(btnLogPauseFont);
  504. btnLogPause.setHorizontalTextPosition(0);
  505. btnLogPause.setText("지우기");
  506. pnlLogTitle.add(btnLogPause, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  507. chkLogPause = new JCheckBox();
  508. Font chkLogPauseFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, chkLogPause.getFont());
  509. if (chkLogPauseFont != null) chkLogPause.setFont(chkLogPauseFont);
  510. chkLogPause.setHorizontalAlignment(0);
  511. chkLogPause.setHorizontalTextPosition(11);
  512. chkLogPause.setText("멈춤");
  513. pnlLogTitle.add(chkLogPause, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  514. btnLogCopy = new JButton();
  515. Font btnLogCopyFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnLogCopy.getFont());
  516. if (btnLogCopyFont != null) btnLogCopy.setFont(btnLogCopyFont);
  517. btnLogCopy.setText("복사");
  518. pnlLogTitle.add(btnLogCopy, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  519. final JScrollPane scrollPane2 = new JScrollPane();
  520. Font scrollPane2Font = this.$$$getFont$$$("D2Coding", Font.PLAIN, 12, scrollPane2.getFont());
  521. if (scrollPane2Font != null) scrollPane2.setFont(scrollPane2Font);
  522. pnlLog.add(scrollPane2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
  523. taLog = new JTextArea();
  524. taLog.setBackground(new Color(-16777216));
  525. taLog.setCaretColor(new Color(-1));
  526. taLog.setEditable(false);
  527. Font taLogFont = this.$$$getFont$$$("D2Coding", Font.PLAIN, 14, taLog.getFont());
  528. if (taLogFont != null) taLog.setFont(taLogFont);
  529. taLog.setForeground(new Color(-1));
  530. taLog.setMargin(new Insets(4, 4, 4, 4));
  531. taLog.setText("[10:50:08.561] [ INFO] ************************************************************************************\n[10:50:08.561] [ INFO] ** Center Communication Server Information **\n[10:50:08.561] [ INFO] ** bindAddress: 0.0.0.0\n[10:50:08.561] [ INFO] ** listenPort: 9901\n[10:50:08.561] [ INFO] ** backlog: 1024\n[10:50:08.561] [ INFO] ** acceptThreads: 16\n[10:50:08.561] [ INFO] ** workerThreads: 16\n[10:50:08.561] [ INFO] ************************************************************************************\n");
  532. scrollPane2.setViewportView(taLog);
  533. pnlStatusBar = new JPanel();
  534. pnlStatusBar.setLayout(new GridLayoutManager(1, 7, new Insets(0, 4, 4, 4), -1, -1));
  535. rootPanel.add(pnlStatusBar, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
  536. final Spacer spacer4 = new Spacer();
  537. pnlStatusBar.add(spacer4, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
  538. lblSystime = new JLabel();
  539. Font lblSystimeFont = this.$$$getFont$$$("Malgun Gothic", Font.BOLD, 12, lblSystime.getFont());
  540. if (lblSystimeFont != null) lblSystime.setFont(lblSystimeFont);
  541. lblSystime.setHorizontalAlignment(0);
  542. lblSystime.setHorizontalTextPosition(0);
  543. lblSystime.setText(" 2022-08-04 13:24:33 ");
  544. pnlStatusBar.add(lblSystime, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  545. final JLabel label6 = new JLabel();
  546. label6.setIcon(new ImageIcon(getClass().getResource("/static/image/on.png")));
  547. label6.setText(" ");
  548. pnlStatusBar.add(label6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  549. lblCpuRate = new JLabel();
  550. Font lblCpuRateFont = this.$$$getFont$$$("Malgun Gothic", Font.BOLD, 12, lblCpuRate.getFont());
  551. if (lblCpuRateFont != null) lblCpuRate.setFont(lblCpuRateFont);
  552. lblCpuRate.setHorizontalAlignment(2);
  553. lblCpuRate.setHorizontalTextPosition(0);
  554. lblCpuRate.setText(" ");
  555. pnlStatusBar.add(lblCpuRate, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(40, -1), new Dimension(40, -1), new Dimension(40, -1), 0, false));
  556. lblMemoryUsage = new JLabel();
  557. Font lblMemoryUsageFont = this.$$$getFont$$$("Malgun Gothic", Font.BOLD, 12, lblMemoryUsage.getFont());
  558. if (lblMemoryUsageFont != null) lblMemoryUsage.setFont(lblMemoryUsageFont);
  559. lblMemoryUsage.setHorizontalAlignment(2);
  560. lblMemoryUsage.setHorizontalTextPosition(0);
  561. lblMemoryUsage.setText(" ");
  562. pnlStatusBar.add(lblMemoryUsage, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(40, -1), new Dimension(40, -1), new Dimension(40, -1), 0, false));
  563. final JLabel label7 = new JLabel();
  564. Font label7Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label7.getFont());
  565. if (label7Font != null) label7.setFont(label7Font);
  566. label7.setHorizontalAlignment(0);
  567. label7.setHorizontalTextPosition(0);
  568. label7.setText(" CPU 사용율(%):");
  569. pnlStatusBar.add(label7, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  570. final JLabel label8 = new JLabel();
  571. Font label8Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label8.getFont());
  572. if (label8Font != null) label8.setFont(label8Font);
  573. label8.setHorizontalAlignment(0);
  574. label8.setHorizontalTextPosition(0);
  575. label8.setText(" 메모리 사용율(%):");
  576. pnlStatusBar.add(label8, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  577. }
  578. /**
  579. * @noinspection ALL
  580. */
  581. private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) {
  582. if (currentFont == null) return null;
  583. String resultName;
  584. if (fontName == null) {
  585. resultName = currentFont.getName();
  586. } else {
  587. Font testFont = new Font(fontName, Font.PLAIN, 10);
  588. if (testFont.canDisplay('a') && testFont.canDisplay('1')) {
  589. resultName = fontName;
  590. } else {
  591. resultName = currentFont.getName();
  592. }
  593. }
  594. Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
  595. boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
  596. Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
  597. return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
  598. }
  599. /**
  600. * @noinspection ALL
  601. */
  602. public JComponent $$$getRootComponent$$$() {
  603. return rootPanel;
  604. }
  605. }