📄 gui.java
字号:
pnl_Step5.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Step5.add(pnl_EdgeImage); /* Step 6 Panel */ pnl_Step6 = new GUIPanel(); pnl_Step6.setLayout(new BoxLayout(pnl_Step6, BoxLayout.Y_AXIS)); /* Step 6 Panel Label */ pnl_Step6Label = new GUIPanel(); pnl_Step6Label.setLayout(new FlowLayout(FlowLayout.CENTER)); /* Step 6 Label */ lbl_Step6 = new GUILabel("Step 6: Pupil/Iris Radius Detection", SwingConstants.LEFT); pnl_Step6Label.add(lbl_Step6); /* Grayscale Image With Edges Panel */ pnl_EdgeImageWithRadii = new ImagePanel(); pnl_EdgeImageWithRadii.setPreferredSize(new Dimension(200,180)); pnl_Step6.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Step6.add(pnl_Step6Label); pnl_Step6.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Step6.add(pnl_EdgeImageWithRadii); pnl_NorthRow2.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP)); pnl_NorthRow2.add(pnl_Step4); pnl_NorthRow2.add(Box.createHorizontalStrut(Constants.INT_LARGE_GAP)); pnl_NorthRow2.add(pnl_Step5); pnl_NorthRow2.add(Box.createHorizontalStrut(Constants.INT_LARGE_GAP)); pnl_NorthRow2.add(pnl_Step6); pnl_NorthRow2.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP)); /* North Row 3 Panel */ pnl_NorthRow3 = new GUIPanel(); pnl_NorthRow3.setPreferredSize(new Dimension(Constants.INT_APPLICATION_WINDOW_WIDTH, 200)); pnl_NorthRow3.setLayout(new BoxLayout(pnl_NorthRow3, BoxLayout.X_AXIS)); /* Step 7 Panel */ pnl_Step7 = new GUIPanel(); pnl_Step7.setLayout(new BoxLayout(pnl_Step7, BoxLayout.Y_AXIS)); /* Step 7 Panel Label */ pnl_Step7Label = new GUIPanel(); pnl_Step7Label.setLayout(new FlowLayout(FlowLayout.CENTER)); /* Step 7 Label */ lbl_Step7 = new GUILabel("Step 7: Iris Localization", SwingConstants.LEFT); pnl_Step7Label.add(lbl_Step7); /* Grayscale Iris Only panel */ pnl_GrayscaleIrisOnly = new ImagePanel(); pnl_GrayscaleIrisOnly.setPreferredSize(new Dimension(200,180)); pnl_Step7.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Step7.add(pnl_Step7Label); pnl_Step7.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Step7.add(pnl_GrayscaleIrisOnly); /* Step 8 Panel */ pnl_Step8 = new GUIPanel(); pnl_Step8.setPreferredSize(new Dimension(435, 180)); /* Step 8 Label Panel */ pnl_Step8Label = new GUIPanel(); pnl_Step8Label.setLayout(new FlowLayout(FlowLayout.CENTER)); /* Step 8 Label */ lbl_Step8 = new GUILabel("Step 8: Iris Unrolling (Unwrapping)", SwingConstants.LEFT); pnl_Step8Label.add(lbl_Step8); /* Unwrapped Image Panel */ pnl_Unwrapped = new GUIPanel(); pnl_Unwrapped.setLayout(new BoxLayout(pnl_Unwrapped, BoxLayout.X_AXIS)); /* Unwrapped Image Panel */ pnl_UnwrappedIris = new ImagePanel(); pnl_UnwrappedIris.setPreferredSize(new Dimension(435, 55)); pnl_Unwrapped.add(Box.createVerticalStrut(Constants.INT_MEDIUM_GAP)); pnl_Unwrapped.add(pnl_UnwrappedIris); pnl_Unwrapped.add(Box.createVerticalStrut(Constants.INT_MEDIUM_GAP)); pnl_Step8.add(Box.createVerticalStrut(Constants.INT_MEDIUM_GAP)); pnl_Step8.add(pnl_Step8Label); pnl_Step8.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Step8.add(pnl_Unwrapped); pnl_NorthRow3.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP)); pnl_NorthRow3.add(pnl_Step7); pnl_NorthRow3.add(Box.createHorizontalStrut(Constants.INT_LARGE_GAP)); pnl_NorthRow3.add(pnl_Step8); pnl_NorthRow3.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP)); pnl_North.add(pnl_NorthRow1); pnl_North.add(pnl_NorthRow2); pnl_North.add(pnl_NorthRow3); pnl_Main.add(pnl_North); pnl_Main.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); /* East panel */ pnl_East = new GUIPanel(); pnl_East.setLayout(new BoxLayout(pnl_East, BoxLayout.X_AXIS)); /* Options Panel */ pnl_Options = new GUIPanel(); pnl_Options.setLayout(new BoxLayout(pnl_Options, BoxLayout.Y_AXIS)); /* Pupil Center Detection Option Panel */ pnl_PupilCenterDetectionOptions = new GUIPanel(); pnl_PupilCenterDetectionOptions.setPreferredSize(new Dimension(300, 380)); pnl_PupilCenterDetectionOptions.setLayout(new BoxLayout(pnl_PupilCenterDetectionOptions, BoxLayout.X_AXIS)); pnl_PupilCenterDetectionOptions.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), " Pupil Center Detection Options ", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION)); /* Pupil Center Detection labels */ pnl_PupilCenterDetectionLabels = new GUIPanel(); pnl_PupilCenterDetectionLabels.setLayout(new BoxLayout(pnl_PupilCenterDetectionLabels, BoxLayout.Y_AXIS)); /* Pupil Variance Label */ lbl_PupilVariance = new GUILabel("Variance ", SwingConstants.LEFT); /* Pupil Area Percent Match Label */ lbl_PupilPercentMatch = new GUILabel("Block Size % ", SwingConstants.LEFT); pnl_PupilCenterDetectionLabels.add(lbl_PupilVariance); pnl_PupilCenterDetectionLabels.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_PupilCenterDetectionLabels.add(lbl_PupilPercentMatch); /* Pupil Center Detection Sliders */ pnl_PupilCenterDetectionSliders = new GUIPanel(); pnl_PupilCenterDetectionSliders.setLayout(new BoxLayout(pnl_PupilCenterDetectionSliders, BoxLayout.Y_AXIS)); /* Pupil Variance Slidder */ sld_PupilVariance = new JSlider(1, 50); sld_PupilVariance.setValue(Globals.PUPIL_VARIANCE); sld_PupilVariance.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { jtf_PupilThreshhold.setText((new Integer(sld_PupilVariance.getValue())).toString()); Globals.PUPIL_VARIANCE = sld_PupilVariance.getValue(); } }); sld_PupilVariance.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { rescanEye(); } }); /* Pupil Area Percent Slider */ sld_PupilBlockSizePortion = new JSlider(0, 100); sld_PupilBlockSizePortion.setValue((int)(Globals.PUPIL_BLOCK_SIZE_PORTION * 100)); sld_PupilBlockSizePortion.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { jtf_BlockSizePortion.setText((new Integer(sld_PupilBlockSizePortion.getValue())).toString() + "%"); Globals.PUPIL_BLOCK_SIZE_PORTION = (new Double(sld_PupilBlockSizePortion.getValue())).doubleValue() / 100; } }); sld_PupilBlockSizePortion.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { rescanEye(); } }); pnl_PupilCenterDetectionSliders.add(sld_PupilVariance); pnl_PupilCenterDetectionSliders.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_PupilCenterDetectionSliders.add(sld_PupilBlockSizePortion); /* Pupil Center Detection Values */ pnl_PupilCenterDetectionValues = new GUIPanel(); pnl_PupilCenterDetectionValues.setLayout(new BoxLayout(pnl_PupilCenterDetectionValues, BoxLayout.Y_AXIS)); /* Variance Text Field */ jtf_PupilThreshhold = new JTextField((new Integer(Globals.PUPIL_VARIANCE)).toString(), 8); jtf_PupilThreshhold.setEditable(false); jtf_PupilThreshhold.setHorizontalAlignment(JTextField.CENTER); /* Block Size Portion Text Field */ jtf_BlockSizePortion = new JTextField((new Integer((int)(Globals.PUPIL_BLOCK_SIZE_PORTION*100))).toString() + "%", 8); jtf_BlockSizePortion.setEditable(false); jtf_BlockSizePortion.setHorizontalAlignment(JTextField.CENTER); pnl_PupilCenterDetectionValues.add(jtf_PupilThreshhold); pnl_PupilCenterDetectionValues.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_PupilCenterDetectionValues.add(jtf_BlockSizePortion); pnl_PupilCenterDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_PupilCenterDetectionOptions.add(pnl_PupilCenterDetectionLabels); pnl_PupilCenterDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_PupilCenterDetectionOptions.add(pnl_PupilCenterDetectionSliders); pnl_PupilCenterDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_PupilCenterDetectionOptions.add(pnl_PupilCenterDetectionValues); pnl_PupilCenterDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); /* Edge Detection Option Panel */ pnl_EdgeDetectionOptions = new GUIPanel(); pnl_EdgeDetectionOptions.setPreferredSize(new Dimension(300, 380)); pnl_EdgeDetectionOptions.setLayout(new BoxLayout(pnl_EdgeDetectionOptions, BoxLayout.X_AXIS)); pnl_EdgeDetectionOptions.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), " Edge Detection Options ", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION)); /* Edge Detection labels */ pnl_EdgeDetectionLabels = new GUIPanel(); pnl_EdgeDetectionLabels.setLayout(new BoxLayout(pnl_EdgeDetectionLabels, BoxLayout.Y_AXIS)); /* Edge Threshhold */ lbl_EdgeThreshhold = new GUILabel("Threshhold ", SwingConstants.LEFT); /* Edge Gaussian Width */ lbl_EdgeGaussianWidth = new GUILabel("Gaussian Width ", SwingConstants.LEFT); pnl_EdgeDetectionLabels.add(lbl_EdgeThreshhold); pnl_EdgeDetectionLabels.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_EdgeDetectionLabels.add(lbl_EdgeGaussianWidth); /* Edge Detection sliders */ pnl_EdgeDetectionSliders = new GUIPanel(); pnl_EdgeDetectionSliders.setLayout(new BoxLayout(pnl_EdgeDetectionSliders, BoxLayout.Y_AXIS)); /* Threshhold Slider */ sld_EdgeThreshold = new JSlider(1, 255); sld_EdgeThreshold.setValue((int)(Globals.EDGE_THRESHHOLD)); sld_EdgeThreshold.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { jtf_EdgeThreshhold.setText((new Integer(sld_EdgeThreshold.getValue())).toString()); Globals.EDGE_THRESHHOLD = sld_EdgeThreshold.getValue(); } }); sld_EdgeThreshold.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { rescanEye(); } }); /* Edge Gaussian Width Slider */ sld_EdgeGaussianWidth = new JSlider(2, 35); sld_EdgeGaussianWidth.setValue((int)(Globals.GUASSIAN_WIDTH)); sld_EdgeGaussianWidth.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { jtf_EdgeGaussianWidth.setText((new Integer(sld_EdgeGaussianWidth.getValue())).toString()); Globals.GUASSIAN_WIDTH = sld_EdgeGaussianWidth.getValue(); } }); sld_EdgeGaussianWidth.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { rescanEye(); } }); pnl_EdgeDetectionSliders.add(sld_EdgeThreshold); pnl_EdgeDetectionSliders.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_EdgeDetectionSliders.add(sld_EdgeGaussianWidth); /* Edge Detection Values */ pnl_EdgeDetectionValues = new GUIPanel(); pnl_EdgeDetectionValues.setLayout(new BoxLayout(pnl_EdgeDetectionValues, BoxLayout.Y_AXIS)); /* Edge Threshhold Text Field */ jtf_EdgeThreshhold = new JTextField((new Integer((int)(Globals.EDGE_THRESHHOLD))).toString(), 10); jtf_EdgeThreshhold.setEditable(false); jtf_EdgeThreshhold.setHorizontalAlignment(JTextField.CENTER); /* Edge Gaussian Width Tect Field */ jtf_EdgeGaussianWidth = new JTextField((new Integer((int)(Globals.GUASSIAN_WIDTH))).toString(), 10); jtf_EdgeGaussianWidth.setEditable(false); jtf_EdgeGaussianWidth.setHorizontalAlignment(JTextField.CENTER); pnl_EdgeDetectionValues.add(jtf_EdgeThreshhold); pnl_EdgeDetectionValues.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_EdgeDetectionValues.add(jtf_EdgeGaussianWidth); pnl_EdgeDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_EdgeDetectionOptions.add(pnl_EdgeDetectionLabels); pnl_EdgeDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_EdgeDetectionOptions.add(pnl_EdgeDetectionSliders); pnl_EdgeDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_EdgeDetectionOptions.add(pnl_EdgeDetectionValues); pnl_EdgeDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); /* Radius Detection Option Panel */ pnl_RadiusDetectionOptions = new GUIPanel(); pnl_RadiusDetectionOptions.setPreferredSize(new Dimension(300, 380)); pnl_RadiusDetectionOptions.setLayout(new BoxLayout(pnl_RadiusDetectionOptions, BoxLayout.X_AXIS)); pnl_RadiusDetectionOptions.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), " Iris / Pupil Radius Detection Options ", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION)); /* Radius Detection labels */ pnl_RadiusDetectionLabels = new GUIPanel(); pnl_RadiusDetectionLabels.setLayout(new BoxLayout(pnl_RadiusDetectionLabels, BoxLayout.Y_AXIS)); /* Radius Circle Percentage */ lbl_RadiusCirclePercentMatch = new GUILabel("% Circle Match ", SwingConstants.LEFT); pnl_RadiusDetectionLabels.add(lbl_RadiusCirclePercentMatch); /* Radius Detection sliders */ pnl_RadiusDetectionSliders = new GUIPanel(); pnl_RadiusDetectionSliders.setLayout(new BoxLayout(pnl_RadiusDetectionSliders, BoxLayout.Y_AXIS)); /* Threshhold Slider */ sld_RadiusCirclePercentMatch = new JSlider(1, 100); sld_RadiusCirclePercentMatch.setValue((int)(Globals.CIRCLE_PERCENT_MATCH*100)); sld_RadiusCirclePercentMatch.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { jtf_RadiusCirclePercentMatch.setText((new Integer((int)(sld_RadiusCirclePercentMatch.getValue()))).toString() + "%"); Globals.CIRCLE_PERCENT_MATCH = ((double)sld_RadiusCirclePercentMatch.getValue()) / 100; } }); sld_RadiusCirclePercentMatch.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { rescanEye(); } }); pnl_RadiusDetectionSliders.add(sld_RadiusCirclePercentMatch); /* Radius Detection Values */ pnl_RadiusDetectionValues = new GUIPanel(); pnl_RadiusDetectionValues.setLayout(new BoxLayout(pnl_RadiusDetectionValues, BoxLayout.Y_AXIS)); /* Radius Circle Percent Match Text Field */ jtf_RadiusCirclePercentMatch = new JTextField((new Integer((int)(Globals.CIRCLE_PERCENT_MATCH*100))).toString() + "%", 10); jtf_RadiusCirclePercentMatch.setEditable(false); jtf_RadiusCirclePercentMatch.setHorizontalAlignment(JTextField.CENTER); pnl_RadiusDetectionValues.add(jtf_RadiusCirclePercentMatch); pnl_RadiusDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_RadiusDetectionOptions.add(pnl_RadiusDetectionLabels); pnl_RadiusDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_RadiusDetectionOptions.add(pnl_RadiusDetectionSliders); pnl_RadiusDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_RadiusDetectionOptions.add(pnl_RadiusDetectionValues); pnl_RadiusDetectionOptions.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP)); pnl_Options.add(Box.createVerticalStrut(Constants.INT_MEDIUM_GAP)); pnl_Options.add(pnl_PupilCenterDetectionOptions); pnl_Options.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Options.add(pnl_EdgeDetectionOptions); pnl_Options.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP)); pnl_Options.add(pnl_RadiusDetectionOptions); pnl_Options.add(Box.createVerticalStrut(400)); pnl_East.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP)); pnl_East.add(pnl_Options); pnl_East.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP)); /* South Panel */ pnl_South = new GUIPanel(); pnl_South.setLayout(new FlowLayout(FlowLayout.CENTER)); /* Clear button */ btn_Clear = new JButton("Clear"); btn_Clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clear();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -