Remote Control zum Einschalten des 3D-Druckers und Bewegen der ebCam im Hobbyraum Brand
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

MainPanel.java 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. package ch.spherICIT.main;
  2. import ch.spherICIT.components.switchbtn.SwitchButton;
  3. import com.fazecast.jSerialComm.SerialPort;
  4. import javax.swing.DefaultComboBoxModel;
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JButton;
  7. import javax.swing.JComboBox;
  8. import javax.swing.JComponent;
  9. import javax.swing.JLabel;
  10. import javax.swing.JOptionPane;
  11. import javax.swing.JPanel;
  12. import javax.swing.plaf.FontUIResource;
  13. import javax.swing.text.StyleContext;
  14. import java.awt.Color;
  15. import java.awt.Dimension;
  16. import java.awt.Font;
  17. import java.awt.GridBagConstraints;
  18. import java.awt.GridBagLayout;
  19. import java.awt.Insets;
  20. import java.awt.event.ActionEvent;
  21. import java.awt.event.ActionListener;
  22. import java.awt.event.ItemEvent;
  23. import java.awt.event.ItemListener;
  24. import java.util.ArrayList;
  25. import java.util.HashSet;
  26. import java.util.List;
  27. import java.util.Locale;
  28. import java.util.Optional;
  29. import java.util.Set;
  30. public class MainPanel {
  31. private JPanel mainPanel;
  32. private JLabel serPortLbl;
  33. private JComboBox<CommPort> serPortCboBox;
  34. private JButton serPortOpenBtn;
  35. private JButton serPortCloseBtn;
  36. private JButton setZeroAzBtn;
  37. private SwitchButton relaisPwrBtn;
  38. private SwitchButton camVelocityModeBtn;
  39. private SwitchButton camStepperPwrBtn;
  40. private JLabel relaisPwrLed;
  41. private JLabel camStepperPwrLed;
  42. private JButton logWindowBtn;
  43. private final LogWindow logWindow;
  44. private Set<IConnectionState> connectionStateListeners;
  45. private ActionListener reconnectActionListener;
  46. private List<CommPort> commPorts;
  47. /**
  48. * Konstruktor.
  49. */
  50. public MainPanel() {
  51. this.logWindow = new LogWindow();
  52. this.connectionStateListeners = new HashSet<>();
  53. $$$setupUI$$$();
  54. initCommPorts();
  55. this.reconnectActionListener = new ActionListener() {
  56. @Override
  57. public void actionPerformed(ActionEvent e) {
  58. JOptionPane.showMessageDialog(mainPanel, "Test", "Title", JOptionPane.INFORMATION_MESSAGE);
  59. }
  60. };
  61. this.serPortOpenBtn.addActionListener(new ActionListener() {
  62. @Override
  63. public void actionPerformed(ActionEvent e) {
  64. // connectionStateListeners.iterator().next().connectionStateChanged(new ConnectionStateInfo(ConnectionState.CONNECTING, "", ""));
  65. getSelectedCommPort().get().getSerialPort().get().openPort();
  66. serPortOpenBtn.setEnabled(false);
  67. serPortCloseBtn.setEnabled(true);
  68. }
  69. });
  70. this.serPortCloseBtn.addActionListener(new ActionListener() {
  71. @Override
  72. public void actionPerformed(ActionEvent e) {
  73. // connectionStateListeners.iterator().next().connectionStateChanged(new ConnectionStateInfo(ConnectionState.CONNECTED, "COM4", "v1.2.0"));
  74. getSelectedCommPort().get().getSerialPort().get().closePort();
  75. serPortOpenBtn.setEnabled(true);
  76. serPortCloseBtn.setEnabled(false);
  77. }
  78. });
  79. this.setZeroAzBtn.addActionListener(new ActionListener() {
  80. @Override
  81. public void actionPerformed(ActionEvent e) {
  82. connectionStateListeners.iterator().next().connectionStateChanged(new ConnectionStateInfo(ConnectionState.TIMEOUT, "", ""));
  83. }
  84. });
  85. this.logWindowBtn.addActionListener(new ActionListener() {
  86. @Override
  87. public void actionPerformed(ActionEvent e) {
  88. logWindow.setVisible(true);
  89. }
  90. });
  91. }
  92. private void initCommPorts() {
  93. this.commPorts = new ArrayList<>();
  94. this.commPorts.add(new CommPort(null));
  95. for (SerialPort serialPort : SerialPort.getCommPorts()) {
  96. this.commPorts.add(new CommPort(serialPort));
  97. }
  98. this.serPortCboBox.setModel(new DefaultComboBoxModel(this.commPorts.toArray()));
  99. serPortCboBox.addItemListener(new ItemListener() {
  100. @Override
  101. public void itemStateChanged(ItemEvent e) {
  102. Optional<CommPort> selCommPortOptional = getSelectedCommPort();
  103. if (selCommPortOptional.isPresent() && selCommPortOptional.get().getSerialPort().isPresent()) {
  104. selCommPortOptional.get().getSerialPort().get().openPort();
  105. serPortOpenBtn.setEnabled(false);
  106. serPortCloseBtn.setEnabled(true);
  107. } else {
  108. for (IConnectionState listener : connectionStateListeners) {
  109. listener.connectionStateChanged(new ConnectionStateInfo(ConnectionState.READY, null, null));
  110. serPortOpenBtn.setEnabled(false);
  111. serPortCloseBtn.setEnabled(false);
  112. }
  113. }
  114. }
  115. });
  116. this.serPortCboBox.setSelectedIndex(-1);
  117. }
  118. public void registerConnectionStateListener(IConnectionState connectionStateListener) {
  119. this.connectionStateListeners.add(connectionStateListener);
  120. }
  121. public void removeConnectionStateListener(IConnectionState connectionStateListener) {
  122. this.connectionStateListeners.remove(connectionStateListener);
  123. }
  124. public ActionListener getReconnectActionListener() {
  125. return reconnectActionListener;
  126. }
  127. private Optional<CommPort> getSelectedCommPort() {
  128. return this.serPortCboBox.getSelectedIndex() != -1 ? Optional.of(this.serPortCboBox.getItemAt(this.serPortCboBox.getSelectedIndex())) : Optional.empty();
  129. }
  130. private void createUIComponents() {
  131. this.serPortCboBox = new JComboBox<>();
  132. }
  133. private class CommPort {
  134. private SerialPort serialPort;
  135. /**
  136. * Constructor
  137. *
  138. * @param serialPort serial port from JSerialComm
  139. */
  140. public CommPort(SerialPort serialPort) {
  141. this.serialPort = serialPort;
  142. }
  143. public Optional<SerialPort> getSerialPort() {
  144. return this.serialPort != null ? Optional.of(this.serialPort) : Optional.empty();
  145. }
  146. @Override
  147. public String toString() {
  148. return this.serialPort != null ? this.serialPort.getSystemPortName() : "";
  149. }
  150. }
  151. /**
  152. * Method generated by IntelliJ IDEA GUI Designer
  153. * >>> IMPORTANT!! <<<
  154. * DO NOT edit this method OR call it in your code!
  155. *
  156. * @noinspection ALL
  157. */
  158. private void $$$setupUI$$$() {
  159. createUIComponents();
  160. mainPanel = new JPanel();
  161. mainPanel.setLayout(new GridBagLayout());
  162. final JPanel spacer1 = new JPanel();
  163. GridBagConstraints gbc;
  164. gbc = new GridBagConstraints();
  165. gbc.gridx = 7;
  166. gbc.gridy = 1;
  167. gbc.weightx = 1.0;
  168. gbc.fill = GridBagConstraints.HORIZONTAL;
  169. mainPanel.add(spacer1, gbc);
  170. serPortLbl = new JLabel();
  171. Font serPortLblFont = this.$$$getFont$$$("Bahnschrift", Font.PLAIN, 14, serPortLbl.getFont());
  172. if (serPortLblFont != null) serPortLbl.setFont(serPortLblFont);
  173. serPortLbl.setText("Serieller Port:");
  174. gbc = new GridBagConstraints();
  175. gbc.gridx = 0;
  176. gbc.gridy = 0;
  177. gbc.gridwidth = 2;
  178. gbc.anchor = GridBagConstraints.NORTHWEST;
  179. gbc.insets = new Insets(18, 10, 10, 10);
  180. mainPanel.add(serPortLbl, gbc);
  181. final JPanel spacer2 = new JPanel();
  182. gbc = new GridBagConstraints();
  183. gbc.gridx = 1;
  184. gbc.gridy = 6;
  185. gbc.weighty = 1.0;
  186. gbc.fill = GridBagConstraints.VERTICAL;
  187. mainPanel.add(spacer2, gbc);
  188. Font serPortCboBoxFont = this.$$$getFont$$$("Bahnschrift", Font.PLAIN, 14, serPortCboBox.getFont());
  189. if (serPortCboBoxFont != null) serPortCboBox.setFont(serPortCboBoxFont);
  190. serPortCboBox.setMinimumSize(new Dimension(120, 32));
  191. final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
  192. serPortCboBox.setModel(defaultComboBoxModel1);
  193. serPortCboBox.setPreferredSize(new Dimension(120, 32));
  194. gbc = new GridBagConstraints();
  195. gbc.gridx = 2;
  196. gbc.gridy = 0;
  197. gbc.anchor = GridBagConstraints.NORTHWEST;
  198. gbc.fill = GridBagConstraints.HORIZONTAL;
  199. gbc.insets = new Insets(10, 0, 10, 10);
  200. mainPanel.add(serPortCboBox, gbc);
  201. serPortOpenBtn = new JButton();
  202. serPortOpenBtn.setContentAreaFilled(true);
  203. serPortOpenBtn.setEnabled(false);
  204. Font serPortOpenBtnFont = this.$$$getFont$$$("Bahnschrift", Font.PLAIN, 14, serPortOpenBtn.getFont());
  205. if (serPortOpenBtnFont != null) serPortOpenBtn.setFont(serPortOpenBtnFont);
  206. serPortOpenBtn.setHideActionText(false);
  207. serPortOpenBtn.setHorizontalTextPosition(0);
  208. serPortOpenBtn.setLabel("Öffnen");
  209. serPortOpenBtn.setMinimumSize(new Dimension(130, 32));
  210. serPortOpenBtn.setPreferredSize(new Dimension(130, 32));
  211. serPortOpenBtn.setSelected(false);
  212. serPortOpenBtn.setText("Öffnen");
  213. serPortOpenBtn.setVerticalAlignment(3);
  214. gbc = new GridBagConstraints();
  215. gbc.gridx = 3;
  216. gbc.gridy = 0;
  217. gbc.anchor = GridBagConstraints.NORTH;
  218. gbc.fill = GridBagConstraints.HORIZONTAL;
  219. gbc.insets = new Insets(10, 10, 10, 10);
  220. mainPanel.add(serPortOpenBtn, gbc);
  221. serPortCloseBtn = new JButton();
  222. serPortCloseBtn.setEnabled(false);
  223. Font serPortCloseBtnFont = this.$$$getFont$$$("Bahnschrift", Font.PLAIN, 14, serPortCloseBtn.getFont());
  224. if (serPortCloseBtnFont != null) serPortCloseBtn.setFont(serPortCloseBtnFont);
  225. serPortCloseBtn.setLabel("Schliessen");
  226. serPortCloseBtn.setMinimumSize(new Dimension(130, 32));
  227. serPortCloseBtn.setPreferredSize(new Dimension(130, 32));
  228. serPortCloseBtn.setText("Schliessen");
  229. serPortCloseBtn.setVerticalAlignment(3);
  230. gbc = new GridBagConstraints();
  231. gbc.gridx = 4;
  232. gbc.gridy = 0;
  233. gbc.anchor = GridBagConstraints.NORTH;
  234. gbc.fill = GridBagConstraints.HORIZONTAL;
  235. gbc.insets = new Insets(10, 10, 10, 10);
  236. mainPanel.add(serPortCloseBtn, gbc);
  237. final JLabel label1 = new JLabel();
  238. Font label1Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label1.getFont());
  239. if (label1Font != null) label1.setFont(label1Font);
  240. label1.setForeground(new Color(-15834670));
  241. label1.setHorizontalAlignment(0);
  242. label1.setText("Relais Power Schalter");
  243. gbc = new GridBagConstraints();
  244. gbc.gridx = 0;
  245. gbc.gridy = 1;
  246. gbc.gridwidth = 3;
  247. gbc.weightx = 1.0;
  248. gbc.fill = GridBagConstraints.HORIZONTAL;
  249. gbc.insets = new Insets(10, 10, 10, 10);
  250. mainPanel.add(label1, gbc);
  251. final JLabel label2 = new JLabel();
  252. Font label2Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label2.getFont());
  253. if (label2Font != null) label2.setFont(label2Font);
  254. label2.setForeground(new Color(-15834670));
  255. label2.setHorizontalAlignment(0);
  256. label2.setText("Drehwinkel WebCam");
  257. gbc = new GridBagConstraints();
  258. gbc.gridx = 3;
  259. gbc.gridy = 1;
  260. gbc.gridwidth = 2;
  261. gbc.weightx = 1.0;
  262. gbc.fill = GridBagConstraints.HORIZONTAL;
  263. gbc.insets = new Insets(10, 10, 10, 10);
  264. mainPanel.add(label2, gbc);
  265. final JLabel label3 = new JLabel();
  266. Font label3Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label3.getFont());
  267. if (label3Font != null) label3.setFont(label3Font);
  268. label3.setForeground(new Color(-15834670));
  269. label3.setHorizontalAlignment(0);
  270. label3.setText("WebCam 0° Azimut");
  271. gbc = new GridBagConstraints();
  272. gbc.gridx = 5;
  273. gbc.gridy = 1;
  274. gbc.gridwidth = 2;
  275. gbc.weightx = 1.0;
  276. gbc.anchor = GridBagConstraints.WEST;
  277. gbc.insets = new Insets(10, 0, 10, 10);
  278. mainPanel.add(label3, gbc);
  279. final JPanel panel1 = new JPanel();
  280. panel1.setLayout(new GridBagLayout());
  281. gbc = new GridBagConstraints();
  282. gbc.gridx = 0;
  283. gbc.gridy = 2;
  284. gbc.gridwidth = 3;
  285. gbc.fill = GridBagConstraints.BOTH;
  286. mainPanel.add(panel1, gbc);
  287. final JLabel label4 = new JLabel();
  288. Font label4Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 20, label4.getFont());
  289. if (label4Font != null) label4.setFont(label4Font);
  290. label4.setForeground(new Color(-65536));
  291. label4.setText("AUS");
  292. gbc = new GridBagConstraints();
  293. gbc.gridx = 0;
  294. gbc.gridy = 0;
  295. gbc.anchor = GridBagConstraints.WEST;
  296. gbc.insets = new Insets(0, 0, 0, 10);
  297. panel1.add(label4, gbc);
  298. final JLabel label5 = new JLabel();
  299. Font label5Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 20, label5.getFont());
  300. if (label5Font != null) label5.setFont(label5Font);
  301. label5.setForeground(new Color(-16738404));
  302. label5.setText("EIN");
  303. gbc = new GridBagConstraints();
  304. gbc.gridx = 2;
  305. gbc.gridy = 0;
  306. gbc.anchor = GridBagConstraints.WEST;
  307. gbc.insets = new Insets(0, 10, 0, 0);
  308. panel1.add(label5, gbc);
  309. relaisPwrBtn = new SwitchButton();
  310. relaisPwrBtn.setBackground(new Color(-16738404));
  311. relaisPwrBtn.setPreferredSize(new Dimension(80, 40));
  312. gbc = new GridBagConstraints();
  313. gbc.gridx = 1;
  314. gbc.gridy = 0;
  315. panel1.add(relaisPwrBtn, gbc);
  316. final JLabel label6 = new JLabel();
  317. Font label6Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label6.getFont());
  318. if (label6Font != null) label6.setFont(label6Font);
  319. label6.setForeground(new Color(-15834670));
  320. label6.setHorizontalAlignment(0);
  321. label6.setText("Relais Power Status");
  322. gbc = new GridBagConstraints();
  323. gbc.gridx = 0;
  324. gbc.gridy = 4;
  325. gbc.gridwidth = 3;
  326. gbc.weightx = 1.0;
  327. gbc.fill = GridBagConstraints.HORIZONTAL;
  328. gbc.insets = new Insets(10, 10, 10, 10);
  329. mainPanel.add(label6, gbc);
  330. final JPanel spacer3 = new JPanel();
  331. gbc = new GridBagConstraints();
  332. gbc.gridx = 0;
  333. gbc.gridy = 3;
  334. gbc.gridwidth = 2;
  335. gbc.fill = GridBagConstraints.VERTICAL;
  336. gbc.ipady = 80;
  337. mainPanel.add(spacer3, gbc);
  338. relaisPwrLed = new JLabel();
  339. relaisPwrLed.setHorizontalAlignment(0);
  340. relaisPwrLed.setIcon(new ImageIcon(getClass().getResource("/blue_led_off.png")));
  341. relaisPwrLed.setText("");
  342. gbc = new GridBagConstraints();
  343. gbc.gridx = 0;
  344. gbc.gridy = 5;
  345. gbc.gridwidth = 3;
  346. gbc.fill = GridBagConstraints.HORIZONTAL;
  347. mainPanel.add(relaisPwrLed, gbc);
  348. setZeroAzBtn = new JButton();
  349. Font setZeroAzBtnFont = this.$$$getFont$$$("Bahnschrift", Font.PLAIN, 14, setZeroAzBtn.getFont());
  350. if (setZeroAzBtnFont != null) setZeroAzBtn.setFont(setZeroAzBtnFont);
  351. setZeroAzBtn.setMaximumSize(new Dimension(130, 32));
  352. setZeroAzBtn.setMinimumSize(new Dimension(130, 32));
  353. setZeroAzBtn.setPreferredSize(new Dimension(130, 32));
  354. setZeroAzBtn.setText("0° setzen");
  355. setZeroAzBtn.setVerticalAlignment(3);
  356. gbc = new GridBagConstraints();
  357. gbc.gridx = 5;
  358. gbc.gridy = 2;
  359. gbc.gridwidth = 2;
  360. gbc.anchor = GridBagConstraints.NORTHWEST;
  361. mainPanel.add(setZeroAzBtn, gbc);
  362. final JPanel panel2 = new JPanel();
  363. panel2.setLayout(new GridBagLayout());
  364. gbc = new GridBagConstraints();
  365. gbc.gridx = 5;
  366. gbc.gridy = 3;
  367. gbc.gridwidth = 2;
  368. gbc.anchor = GridBagConstraints.WEST;
  369. gbc.fill = GridBagConstraints.VERTICAL;
  370. mainPanel.add(panel2, gbc);
  371. final JLabel label7 = new JLabel();
  372. Font label7Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label7.getFont());
  373. if (label7Font != null) label7.setFont(label7Font);
  374. label7.setForeground(new Color(-65536));
  375. label7.setText("SLOW");
  376. gbc = new GridBagConstraints();
  377. gbc.gridx = 0;
  378. gbc.gridy = 1;
  379. gbc.anchor = GridBagConstraints.WEST;
  380. gbc.insets = new Insets(0, 0, 0, 10);
  381. panel2.add(label7, gbc);
  382. final JLabel label8 = new JLabel();
  383. Font label8Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label8.getFont());
  384. if (label8Font != null) label8.setFont(label8Font);
  385. label8.setForeground(new Color(-15834670));
  386. label8.setHorizontalAlignment(0);
  387. label8.setText("WebCam Geschwindigkeit");
  388. gbc = new GridBagConstraints();
  389. gbc.gridx = 0;
  390. gbc.gridy = 0;
  391. gbc.gridwidth = 4;
  392. gbc.weightx = 1.0;
  393. gbc.anchor = GridBagConstraints.WEST;
  394. gbc.insets = new Insets(10, 0, 10, 10);
  395. panel2.add(label8, gbc);
  396. camVelocityModeBtn = new SwitchButton();
  397. camVelocityModeBtn.setBackground(new Color(-16738404));
  398. gbc = new GridBagConstraints();
  399. gbc.gridx = 1;
  400. gbc.gridy = 1;
  401. panel2.add(camVelocityModeBtn, gbc);
  402. final JLabel label9 = new JLabel();
  403. Font label9Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label9.getFont());
  404. if (label9Font != null) label9.setFont(label9Font);
  405. label9.setForeground(new Color(-16738404));
  406. label9.setText("FAST");
  407. gbc = new GridBagConstraints();
  408. gbc.gridx = 2;
  409. gbc.gridy = 1;
  410. gbc.anchor = GridBagConstraints.WEST;
  411. gbc.insets = new Insets(0, 10, 0, 0);
  412. panel2.add(label9, gbc);
  413. final JPanel spacer4 = new JPanel();
  414. gbc = new GridBagConstraints();
  415. gbc.gridx = 0;
  416. gbc.gridy = 2;
  417. gbc.gridwidth = 4;
  418. gbc.weighty = 1.0;
  419. gbc.fill = GridBagConstraints.BOTH;
  420. panel2.add(spacer4, gbc);
  421. final JPanel panel3 = new JPanel();
  422. panel3.setLayout(new GridBagLayout());
  423. gbc = new GridBagConstraints();
  424. gbc.gridx = 5;
  425. gbc.gridy = 4;
  426. gbc.gridwidth = 2;
  427. gbc.gridheight = 2;
  428. gbc.anchor = GridBagConstraints.WEST;
  429. gbc.fill = GridBagConstraints.VERTICAL;
  430. mainPanel.add(panel3, gbc);
  431. final JLabel label10 = new JLabel();
  432. Font label10Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label10.getFont());
  433. if (label10Font != null) label10.setFont(label10Font);
  434. label10.setForeground(new Color(-65536));
  435. label10.setText("AUS");
  436. gbc = new GridBagConstraints();
  437. gbc.gridx = 0;
  438. gbc.gridy = 1;
  439. gbc.anchor = GridBagConstraints.SOUTHWEST;
  440. gbc.insets = new Insets(0, 0, 12, 10);
  441. panel3.add(label10, gbc);
  442. final JLabel label11 = new JLabel();
  443. Font label11Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label11.getFont());
  444. if (label11Font != null) label11.setFont(label11Font);
  445. label11.setForeground(new Color(-16738404));
  446. label11.setText("Ein");
  447. gbc = new GridBagConstraints();
  448. gbc.gridx = 2;
  449. gbc.gridy = 1;
  450. gbc.anchor = GridBagConstraints.SOUTH;
  451. gbc.fill = GridBagConstraints.HORIZONTAL;
  452. gbc.insets = new Insets(0, 10, 12, 0);
  453. panel3.add(label11, gbc);
  454. final JLabel label12 = new JLabel();
  455. Font label12Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 16, label12.getFont());
  456. if (label12Font != null) label12.setFont(label12Font);
  457. label12.setForeground(new Color(-15834670));
  458. label12.setHorizontalAlignment(0);
  459. label12.setText("WebCam Stepper Power");
  460. gbc = new GridBagConstraints();
  461. gbc.gridx = 0;
  462. gbc.gridy = 0;
  463. gbc.gridwidth = 4;
  464. gbc.anchor = GridBagConstraints.WEST;
  465. gbc.insets = new Insets(10, 0, 10, 10);
  466. panel3.add(label12, gbc);
  467. final JPanel panel4 = new JPanel();
  468. panel4.setLayout(new GridBagLayout());
  469. gbc = new GridBagConstraints();
  470. gbc.gridx = 3;
  471. gbc.gridy = 1;
  472. gbc.anchor = GridBagConstraints.EAST;
  473. gbc.fill = GridBagConstraints.VERTICAL;
  474. panel3.add(panel4, gbc);
  475. final JLabel label13 = new JLabel();
  476. Font label13Font = this.$$$getFont$$$("Bahnschrift", Font.BOLD, 14, label13.getFont());
  477. if (label13Font != null) label13.setFont(label13Font);
  478. label13.setForeground(new Color(-15834670));
  479. label13.setHorizontalAlignment(0);
  480. label13.setText("Status");
  481. gbc = new GridBagConstraints();
  482. gbc.gridx = 0;
  483. gbc.gridy = 0;
  484. gbc.fill = GridBagConstraints.HORIZONTAL;
  485. gbc.insets = new Insets(0, 10, 5, 10);
  486. panel4.add(label13, gbc);
  487. camStepperPwrLed = new JLabel();
  488. camStepperPwrLed.setHorizontalAlignment(0);
  489. camStepperPwrLed.setIcon(new ImageIcon(getClass().getResource("/blue_led_off.png")));
  490. camStepperPwrLed.setText("");
  491. gbc = new GridBagConstraints();
  492. gbc.gridx = 0;
  493. gbc.gridy = 1;
  494. gbc.fill = GridBagConstraints.HORIZONTAL;
  495. panel4.add(camStepperPwrLed, gbc);
  496. camStepperPwrBtn = new SwitchButton();
  497. camStepperPwrBtn.setBackground(new Color(-16738404));
  498. gbc = new GridBagConstraints();
  499. gbc.gridx = 1;
  500. gbc.gridy = 1;
  501. gbc.anchor = GridBagConstraints.SOUTH;
  502. gbc.insets = new Insets(0, 0, 10, 0);
  503. panel3.add(camStepperPwrBtn, gbc);
  504. final JLabel label14 = new JLabel();
  505. label14.setIcon(new ImageIcon(getClass().getResource("/Arduino_Logo_small.png")));
  506. label14.setText("");
  507. gbc = new GridBagConstraints();
  508. gbc.gridx = 5;
  509. gbc.gridy = 0;
  510. gbc.anchor = GridBagConstraints.EAST;
  511. gbc.insets = new Insets(10, 80, 20, 10);
  512. mainPanel.add(label14, gbc);
  513. logWindowBtn = new JButton();
  514. logWindowBtn.setIcon(new ImageIcon(getClass().getResource("/log24.png")));
  515. logWindowBtn.setMaximumSize(new Dimension(32, 32));
  516. logWindowBtn.setMinimumSize(new Dimension(32, 32));
  517. logWindowBtn.setPreferredSize(new Dimension(32, 32));
  518. logWindowBtn.setText("");
  519. gbc = new GridBagConstraints();
  520. gbc.gridx = 5;
  521. gbc.gridy = 0;
  522. gbc.anchor = GridBagConstraints.NORTHWEST;
  523. gbc.insets = new Insets(10, 10, 10, 10);
  524. mainPanel.add(logWindowBtn, gbc);
  525. }
  526. /**
  527. * @noinspection ALL
  528. */
  529. private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) {
  530. if (currentFont == null) return null;
  531. String resultName;
  532. if (fontName == null) {
  533. resultName = currentFont.getName();
  534. } else {
  535. Font testFont = new Font(fontName, Font.PLAIN, 10);
  536. if (testFont.canDisplay('a') && testFont.canDisplay('1')) {
  537. resultName = fontName;
  538. } else {
  539. resultName = currentFont.getName();
  540. }
  541. }
  542. Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
  543. boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
  544. Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
  545. return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
  546. }
  547. /**
  548. * @noinspection ALL
  549. */
  550. public JComponent $$$getRootComponent$$$() {
  551. return mainPanel;
  552. }
  553. }