⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.java

📁 JAVA 实现虹膜识别(完整)
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package IrisRecog;/** * GUI.java * * @author Team 6: A. Bare, I. Chaugule,M. Huffman, M. Pearson, C. Schell * @version 0.0.1 * * 	CSC 480 Section 2 * 	Fall 2005 * 	10/1/05 * */ import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.filechooser.*;import javax.swing.event.*;import javax.swing.border.*;import java.util.*;import java.lang.*;public class GUI extends JFrame{	/* Menu Bar */	protected JMenuBar mbr_Main;	/* Menus */	protected GUIMenu mnu_File, mnu_Actions, mnu_View, mnu_Help;	/* Menu Items */	protected GUIMenuItem itm_Exit, itm_About, itm_ScanIntoMemory, itm_ScanAgainstMemory, itm_ViewMemory,    					  itm_LoadAgent, itm_SaveMemory;	/* Image File Chooser */	protected ImageFileChooser fch_fileChooser;	/* File Chooser */	protected AgentFileChooser fch_agentFileChooser;		/* Dialogs */	protected JDialog dlg_About, dlg_Memory, dlg_Progress;	/* Custom Panels */	protected GUIPanel pnl_AboutNorth, pnl_AboutCenter, pnl_AboutSouth, pnl_AboutEye, 					   pnl_AboutInfo, pnl_AboutNorthInner, pnl_North, pnl_South, pnl_NorthInner,					   pnl_Step1, pnl_Step2, pnl_Step3, pnl_Step1Label, pnl_Step2Label, pnl_Step3Label, 					   pnl_Center, pnl_Step4, pnl_Step4Label, pnl_NorthRow1, pnl_NorthRow2, pnl_Step5Label, 					   pnl_Step5, pnl_Step6Label, pnl_Step6, pnl_Step7, pnl_Unwrapped, pnl_MemoryNorth, 					   pnl_MemoryCenter, pnl_MemorySouth, pnl_MemoryStat, pnl_Memory, pnl_Main, pnl_Options, 					   pnl_PupilCenterDetectionOptions, pnl_EdgeDetectionOptions, pnl_East, pnl_EdgeThreshhold, 					   pnl_PupilCenterDetectionLabels, pnl_PupilCenterDetectionSliders, pnl_PupilCenterDetectionValues,					   pnl_EdgeDetectionLabels, pnl_EdgeDetectionSliders, pnl_EdgeDetectionValues, pnl_ProgressNorth,					   pnl_ProgressCenter, pnl_RadiusDetectionOptions, pnl_RadiusDetectionLabels, pnl_RadiusDetectionValues,					   pnl_RadiusDetectionSliders, pnl_NorthRow3, pnl_Step7Label, pnl_Step8, pnl_Step8Label;					   		   	/* Image Panel */	protected ImagePanel pnl_OriginalImage, pnl_GrayscaleImage, pnl_GrayscaleMedianFilterImageWithCenter, pnl_EdgeImage,					     pnl_EdgeImageWithRadii, pnl_GrayscaleIrisOnly, pnl_GrayscaleMedianFilterImage, pnl_UnwrappedIris;		/* Panels */	protected JPanel pnl_ContentPane;		/* Buttons */	protected JButton btn_AboutOkay, btn_MemoryOkay, btn_Clear;	/* Text Area */	protected JTextArea jta_AboutInfo, jta_Memory;	/* Labels */	protected GUILabel lbl_AboutEye, lbl_AboutTeam, lbl_AboutTeamMembers, lbl_Step1, lbl_Step2, lbl_Step3,					   lbl_Step1Step2Arrow, lbl_Step4, lbl_Step5, lbl_Step6, lbl_Unwrapped, lbl_MemoryStat, 					   lbl_PupilCenterDetectionOptionsLabel, lbl_EdgeDetectionOptionsLabel, lbl_PupilPercentMatch,					   lbl_PupilVariance, lbl_EdgeThreshhold, lbl_EdgeGaussianWidth, lbl_RadiusCirclePercentMatch, 					   lbl_PupilRadiusMatchWeight, lbl_PupilCenterDistanceWeight, lbl_Step7, lbl_Step8;	/* Sliders */	protected JSlider sld_PupilBlockSizePortion, sld_PupilVariance, sld_EdgeThreshold, sld_EdgeGaussianWidth,				      sld_RadiusCirclePercentMatch, sld_PupilRadiusMatchWeight, sld_PupilCenterDistanceWeight;			protected JTextField jtf_PupilThreshhold, jtf_BlockSizePortion, jtf_EdgeThreshhold, jtf_EdgeGaussianWidth,						 jtf_RadiusCirclePercentMatch, jtf_PupilRadiusMatchWeight, jtf_PupilCenterDistanceWeight;					protected IrisRecog model;		/**	 * Constructor creates and initializes the components of the user interface.	 */	public GUI()	{		super("Mr. RecIris");		/* Setup the file choosers */		fch_fileChooser = new ImageFileChooser();		fch_agentFileChooser = new AgentFileChooser();				createMenu();		createLayout();			createDialogs();		/* Clear the image panels */		clear();						/* Setup window properties */		this.addWindowListener(new WindowAdapter()								{									public void windowClosing(WindowEvent e)									{										close();									}								});		this.setResizable(true);		this.setJMenuBar(mbr_Main);		this.setSize(new Dimension(Constants.INT_APPLICATION_WINDOW_WIDTH, Constants.INT_APPLICATION_WINDOW_HEIGHT));		this.setLocationRelativeTo(null);		this.setVisible(true);	}	/**	 * Associates the IrisRecog object as the model for this user interface.	 *	 * @param r The model to be associated with this user interface	 */	public void setModel(IrisRecog r)	{		this.model = r;	}		/**	 * Creates the main menu bar, the menus and the subsequent menu items.	 */	protected void createMenu()	{		/* Menu Bar */		mbr_Main = new JMenuBar();			/* File Menu */			mnu_File = new GUIMenu("File");				/* Load Agent */						itm_LoadAgent = new GUIMenuItem("Load Agent ...");				itm_LoadAgent.addActionListener(new ActionListener()											{												public void actionPerformed(ActionEvent e)												{													loadAgent();												}											});																	itm_LoadAgent.setEnabled(true);												/* Exit */				itm_Exit = new GUIMenuItem("Exit");				itm_Exit.addActionListener(new ActionListener()											{												public void actionPerformed(ActionEvent e)												{													close();												}											});			mnu_File.add(itm_LoadAgent);				mnu_File.add(itm_Exit);						/* Actions menu */			mnu_Actions = new GUIMenu("Actions");				/* Scan Eye To Database */				itm_ScanIntoMemory = new GUIMenuItem("Scan An Eye Into My Memory ...");				itm_ScanIntoMemory.addActionListener(new ActionListener()													{														public void actionPerformed(ActionEvent e)														{															scanEye();														}													});																		/* Scan Eye For Match */				itm_ScanAgainstMemory = new GUIMenuItem("Match Your Eye Against My Memory ...");				itm_ScanAgainstMemory.addActionListener(new ActionListener()														{																	public void actionPerformed(ActionEvent e)															{																							matchAgaintMemory(); 															}																});												/* Save Memory */				itm_SaveMemory = new GUIMenuItem("Save My Memory ...");				itm_SaveMemory.addActionListener(new ActionListener()														{																	public void actionPerformed(ActionEvent e)															{																													saveAgent(); 																	}																});										mnu_Actions.add(itm_ScanIntoMemory);			mnu_Actions.add(itm_ScanAgainstMemory);			mnu_Actions.add(itm_SaveMemory);						/* View menu */			mnu_View = new GUIMenu("View");				/* View Database Identities */				itm_ViewMemory = new GUIMenuItem("My Memory (Stored Identities) ...");				itm_ViewMemory.addActionListener(new ActionListener()												{													public void actionPerformed(ActionEvent e)													{														viewMemory();													}												});						mnu_View.add(itm_ViewMemory);			/* Help Menu */			mnu_Help = new GUIMenu("Help");				/* About */				itm_About = new GUIMenuItem("About Me ...");				itm_About.addActionListener(new ActionListener()											{												public void actionPerformed(ActionEvent e)												{													dlg_About.setVisible(true);												}											});			mnu_Help.add(itm_About);					mbr_Main.add(mnu_File);		mbr_Main.add(mnu_Actions);		mbr_Main.add(mnu_View);		mbr_Main.add(mnu_Help);		mbr_Main.setBackground(Constants.CLR_DEFAULT_BACKGROUND);	}	/** 	 * Creates the components, sets the layout, and adds them to the frame	 */	protected void createLayout()	{		/* Content Pane */			pnl_ContentPane = (JPanel)this.getContentPane();		pnl_ContentPane.setLayout(new BorderLayout());					/* Main Panel */			pnl_Main = new GUIPanel();			pnl_Main.setLayout(new BoxLayout(pnl_Main, BoxLayout.Y_AXIS));							/* North panel */				pnl_North = new GUIPanel();				pnl_North.setPreferredSize(new Dimension(Constants.INT_APPLICATION_WINDOW_WIDTH, (int)(Constants.INT_APPLICATION_WINDOW_HEIGHT * .60)));				pnl_North.setLayout(new BoxLayout(pnl_North, BoxLayout.Y_AXIS));									/* North first row panel */					pnl_NorthRow1 = new GUIPanel();					pnl_NorthRow1.setPreferredSize(new Dimension(Constants.INT_APPLICATION_WINDOW_WIDTH, 200));					pnl_NorthRow1.setLayout(new BoxLayout(pnl_NorthRow1, BoxLayout.X_AXIS));											/* Step 1 Panel */						pnl_Step1 = new GUIPanel();						pnl_Step1.setLayout(new BoxLayout(pnl_Step1, BoxLayout.Y_AXIS));													/* Step 1 Panel Labe */							pnl_Step1Label = new GUIPanel();							pnl_Step1Label.setLayout(new FlowLayout(FlowLayout.CENTER));															/* Step 1 Label */								lbl_Step1 = new GUILabel("Step 1: Scan Eye", SwingConstants.LEFT);														pnl_Step1Label.add(lbl_Step1);														/* Original Image Panel */							pnl_OriginalImage = new ImagePanel();							pnl_OriginalImage.setPreferredSize(new Dimension(200,180));									pnl_Step1.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step1.add(pnl_Step1Label);						pnl_Step1.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step1.add(pnl_OriginalImage);												/* Step 2 Panel */						pnl_Step2 = new GUIPanel();						pnl_Step2.setLayout(new BoxLayout(pnl_Step2, BoxLayout.Y_AXIS));																/* Step 2 Panel Labe */							pnl_Step2Label = new GUIPanel();							pnl_Step2Label.setLayout(new FlowLayout(FlowLayout.CENTER));															/* Step 2 Label */								lbl_Step2 = new GUILabel("Step 2: Grayscale Eye", SwingConstants.LEFT);																pnl_Step2Label.add(lbl_Step2);										    							/* Grayscale Image Panel */							pnl_GrayscaleImage = new ImagePanel();							pnl_GrayscaleImage.setPreferredSize(new Dimension(200,180));													pnl_Step2.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step2.add(pnl_Step2Label);						pnl_Step2.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step2.add(pnl_GrayscaleImage);											/* Step 3 Panel */						pnl_Step3 = new GUIPanel();						pnl_Step3.setLayout(new BoxLayout(pnl_Step3, BoxLayout.Y_AXIS));																/* Step 3 Panel Label */							pnl_Step3Label = new GUIPanel();							pnl_Step3Label.setLayout(new FlowLayout(FlowLayout.CENTER));															/* Step 3 Label */								lbl_Step3 = new GUILabel("Step 3: Median Filter", SwingConstants.LEFT);																pnl_Step3Label.add(lbl_Step3);										    							/* Grayscale Image Panel */							pnl_GrayscaleMedianFilterImage = new ImagePanel();							pnl_GrayscaleMedianFilterImage.setPreferredSize(new Dimension(200,180));													pnl_Step3.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step3.add(pnl_Step3Label);						pnl_Step3.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step3.add(pnl_GrayscaleMedianFilterImage);										pnl_NorthRow1.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP));					pnl_NorthRow1.add(pnl_Step1);					pnl_NorthRow1.add(Box.createHorizontalStrut(Constants.INT_LARGE_GAP));					pnl_NorthRow1.add(pnl_Step2);					pnl_NorthRow1.add(Box.createHorizontalStrut(Constants.INT_LARGE_GAP));					pnl_NorthRow1.add(pnl_Step3);					pnl_NorthRow1.add(Box.createHorizontalStrut(Constants.INT_MEDIUM_GAP));										/* North second row panel */					pnl_NorthRow2 = new GUIPanel();					pnl_NorthRow2.setPreferredSize(new Dimension(Constants.INT_APPLICATION_WINDOW_WIDTH, 200));					pnl_NorthRow2.setLayout(new BoxLayout(pnl_NorthRow2, BoxLayout.X_AXIS));												/* Step 4 Panel */						pnl_Step4 = new GUIPanel();						pnl_Step4.setLayout(new BoxLayout(pnl_Step4, BoxLayout.Y_AXIS));																/* Step 4 Panel Label */							pnl_Step4Label = new GUIPanel();							pnl_Step4Label.setLayout(new FlowLayout(FlowLayout.CENTER));															/* Step 4 Label */								lbl_Step4 = new GUILabel("Step 4: Pupil Center Detection", SwingConstants.LEFT);																pnl_Step4Label.add(lbl_Step4);										    							/* Grayscale Image Panel */							pnl_GrayscaleMedianFilterImageWithCenter = new ImagePanel();							pnl_GrayscaleMedianFilterImageWithCenter.setPreferredSize(new Dimension(200,180));												pnl_Step4.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step4.add(pnl_Step4Label);						pnl_Step4.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step4.add(pnl_GrayscaleMedianFilterImageWithCenter);											/* Step 5 Panel */						pnl_Step5 = new GUIPanel();						pnl_Step5.setLayout(new BoxLayout(pnl_Step5, BoxLayout.Y_AXIS));																/* Step 5 Panel Label */							pnl_Step5Label = new GUIPanel();							pnl_Step5Label.setLayout(new FlowLayout(FlowLayout.CENTER));															/* Step 5 Label */								lbl_Step5 = new GUILabel("Step 5: Canny Edge Detection", SwingConstants.LEFT);																pnl_Step5Label.add(lbl_Step5);										    							/* Grayscale Image Panel */							pnl_EdgeImage = new ImagePanel();							pnl_EdgeImage.setPreferredSize(new Dimension(200,180));																			    						pnl_Step5.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						pnl_Step5.add(pnl_Step5Label);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -