package ch.psi.mxsc; import ch.psi.pshell.device.DiscretePositionerBase; import ch.psi.pshell.swing.DevicePanel; import java.awt.Color; /** * */ public class HexiposiPanel extends DevicePanel { final Color COLOR_ON = Color.GREEN; //new Color(51,102,255); final Color COLOR_OFF = Color.BLACK; public HexiposiPanel() { initComponents(); //setDeviceName("hexiposi"); } @Override public DiscretePositionerBase getDevice(){ return (DiscretePositionerBase) super.getDevice(); } @Override protected void onDeviceReadbackChanged(Object value) { ledA.setColor("A".equals(value) ? COLOR_ON: COLOR_OFF); ledB.setColor("B".equals(value) ? COLOR_ON: COLOR_OFF); ledC.setColor("C".equals(value) ? COLOR_ON: COLOR_OFF); ledD.setColor("D".equals(value) ? COLOR_ON: COLOR_OFF); ledE.setColor("E".equals(value) ? COLOR_ON: COLOR_OFF); ledF.setColor("F".equals(value) ? COLOR_ON: COLOR_OFF); if ((value==null) || (value.toString().trim().isEmpty()) || (value.toString().equalsIgnoreCase("Unknown"))){ textPosition.setText(""); } else { textPosition.setText((value.toString()).substring(0, 1)); } repaint(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { filler9 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); circlePanel2 = new ch.psi.mxsc.CirclePanel(); filler8 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); ledD = new ch.psi.pshell.swing.Led(); filler7 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0)); ledC = new ch.psi.pshell.swing.Led(); filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); ledE = new ch.psi.pshell.swing.Led(); filler10 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); textPosition = new javax.swing.JLabel(); filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); ledB = new ch.psi.pshell.swing.Led(); filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); ledF = new ch.psi.pshell.swing.Led(); filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); ledA = new ch.psi.pshell.swing.Led(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); circlePanel2.setLayout(new java.awt.GridLayout(5, 3)); circlePanel2.add(filler8); ledD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); circlePanel2.add(ledD); circlePanel2.add(filler7); ledC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); circlePanel2.add(ledC); circlePanel2.add(filler6); ledE.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); circlePanel2.add(ledE); circlePanel2.add(filler10); textPosition.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N textPosition.setForeground(new java.awt.Color(0, 128, 0)); textPosition.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); circlePanel2.add(textPosition); circlePanel2.add(filler4); ledB.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); circlePanel2.add(ledB); circlePanel2.add(filler3); ledF.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); circlePanel2.add(ledF); circlePanel2.add(filler2); ledA.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); circlePanel2.add(ledA); circlePanel2.add(filler1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 73, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(circlePanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 71, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(circlePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private ch.psi.mxsc.CirclePanel circlePanel2; private javax.swing.Box.Filler filler1; private javax.swing.Box.Filler filler10; private javax.swing.Box.Filler filler2; private javax.swing.Box.Filler filler3; private javax.swing.Box.Filler filler4; private javax.swing.Box.Filler filler6; private javax.swing.Box.Filler filler7; private javax.swing.Box.Filler filler8; private javax.swing.Box.Filler filler9; private ch.psi.pshell.swing.Led ledA; private ch.psi.pshell.swing.Led ledB; private ch.psi.pshell.swing.Led ledC; private ch.psi.pshell.swing.Led ledD; private ch.psi.pshell.swing.Led ledE; private ch.psi.pshell.swing.Led ledF; private javax.swing.JLabel textPosition; // End of variables declaration//GEN-END:variables }