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

📄 gui.java

📁 JAVA 实现虹膜识别(完整)
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
													}												});																			pnl_South.add(btn_Clear);				/* Add the panels to the content pane */		pnl_ContentPane.add(pnl_Main, BorderLayout.CENTER);		//pnl_ContentPane.add(pnl_East, BorderLayout.EAST);			pnl_ContentPane.add(pnl_South, BorderLayout.SOUTH);	}	/** 	 * Creates all of the required dialogs used by the GUI	 */	protected void createDialogs()	{		createAboutDialog();		createMemoryDialog();	}	/**	 * Creates the about dialog that shows the team members and relevant	 * information about the application	 */	protected void createAboutDialog()	{		/* About window */		dlg_About = new JDialog(this, "About Me", true);		dlg_About.getContentPane().setLayout(new BorderLayout());		dlg_About.setSize(new Dimension(500,215));		dlg_About.setLocationRelativeTo(this);		dlg_About.setVisible(false);			/* North panel */			pnl_AboutNorth = new GUIPanel();			pnl_AboutNorth.setLayout(new BoxLayout(pnl_AboutNorth, BoxLayout.X_AXIS));			pnl_AboutNorth.setPreferredSize(new Dimension(300,50));				/* Inner North panel */				pnl_AboutNorthInner = new GUIPanel();				pnl_AboutNorthInner.setLayout(new BoxLayout(pnl_AboutNorthInner, BoxLayout.Y_AXIS));					/* Team label */					lbl_AboutTeam = new GUILabel("Developers", SwingConstants.LEFT);					lbl_AboutTeam.setFont(new Font("Garamond", Font.BOLD, 20));					/* Team Member labels */					lbl_AboutTeamMembers = new GUILabel("Catherine Schell - Andy Bare - Imran Chaugule - Matt Pearson - Michael Huffman", SwingConstants.LEFT);	 						pnl_AboutNorthInner.add(lbl_AboutTeam);				pnl_AboutNorthInner.add(lbl_AboutTeamMembers);				pnl_AboutNorthInner.add(Box.createVerticalStrut(30));			pnl_AboutNorth.add(Box.createHorizontalStrut(10));			pnl_AboutNorth.add(pnl_AboutNorthInner);			/* Center panel */			pnl_AboutCenter = new GUIPanel();			pnl_AboutCenter.setLayout(new BoxLayout(pnl_AboutCenter, BoxLayout.X_AXIS));			pnl_AboutCenter.setPreferredSize(new Dimension(300,125));				/* Eye Picture panel */				pnl_AboutEye = new GUIPanel();				pnl_AboutEye.setLayout(new BoxLayout(pnl_AboutEye, BoxLayout.Y_AXIS));					/* About Eye Picture label */					lbl_AboutEye = new GUILabel(new ImageIcon("../AboutEye.jpg"));					pnl_AboutEye.add(Box.createVerticalStrut(10));				pnl_AboutEye.add(lbl_AboutEye);				pnl_AboutEye.add(Box.createVerticalStrut(10));				/* About Info panel */				pnl_AboutInfo = new GUIPanel();				pnl_AboutInfo.setLayout(new BoxLayout(pnl_AboutInfo, BoxLayout.Y_AXIS));					/* Info text area */					jta_AboutInfo = new JTextArea("My name is Mr. RecIris. My goal is to " +											      "learn what your eye, more specifically " +											      "your iris, looks like. Once I memorize " +											      "what your eye looks like I can then know " +											      "who you are just by looking at you.");	 	        		jta_AboutInfo.setLineWrap(true);	        		jta_AboutInfo.setWrapStyleWord(true);	          		jta_AboutInfo.setFont(new Font("Garamond", Font.BOLD, 14));	          		jta_AboutInfo.setBackground(Constants.CLR_DEFAULT_BACKGROUND);	          		jta_AboutInfo.setEditable(false);									pnl_AboutInfo.add(Box.createVerticalStrut(10));				pnl_AboutInfo.add(jta_AboutInfo);				pnl_AboutInfo.add(Box.createVerticalStrut(5));				          	pnl_AboutCenter.add(Box.createHorizontalStrut(10));			pnl_AboutCenter.add(pnl_AboutEye);			pnl_AboutCenter.add(Box.createHorizontalStrut(10));			pnl_AboutCenter.add(pnl_AboutInfo);			pnl_AboutCenter.add(Box.createHorizontalStrut(10));			/* South panel */			pnl_AboutSouth = new GUIPanel();			pnl_AboutSouth.setLayout(new FlowLayout(FlowLayout.CENTER));			pnl_AboutSouth.setPreferredSize(new Dimension(300,40));				/* Okay button */				btn_AboutOkay = new JButton("Okay");				btn_AboutOkay.addActionListener(new ActionListener()												{													public void actionPerformed(ActionEvent e)													{														dlg_About.setVisible(false);													}												});			pnl_AboutSouth.add(btn_AboutOkay);		dlg_About.getContentPane().add(pnl_AboutNorth, BorderLayout.NORTH);		dlg_About.getContentPane().add(pnl_AboutCenter, BorderLayout.CENTER);		dlg_About.getContentPane().add(pnl_AboutSouth, BorderLayout.SOUTH);	}		/**	 * Create the dialog to display the current contents of the agent's memory.	 */	protected void createMemoryDialog()	{		/* About window */		dlg_Memory = new JDialog(this, "My Memory", true);		dlg_Memory.getContentPane().setLayout(new BorderLayout());		dlg_Memory.setSize(new Dimension(300,400));		dlg_Memory.setLocationRelativeTo(this);		dlg_Memory.setVisible(false);			/* North panel */			pnl_MemoryNorth = new GUIPanel();			pnl_MemoryNorth.setLayout(new BoxLayout(pnl_MemoryNorth, BoxLayout.Y_AXIS));					/* Memory Statistics Panel */				pnl_MemoryStat = new GUIPanel();				pnl_MemoryStat.setLayout(new BoxLayout(pnl_MemoryStat, BoxLayout.X_AXIS));									/* Memory Statistic Label */					lbl_MemoryStat = new GUILabel("", SwingConstants.LEFT);	          		lbl_MemoryStat.setFont(new Font("Garamond", Font.BOLD, 18));	          						pnl_MemoryStat.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP));				pnl_MemoryStat.add(lbl_MemoryStat);				pnl_MemoryStat.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP));								pnl_MemoryNorth.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));			pnl_MemoryNorth.add(pnl_MemoryStat, BorderLayout.CENTER);			pnl_MemoryNorth.add(Box.createVerticalStrut(Constants.INT_SMALL_GAP));						/* Center panel */			pnl_MemoryCenter = new GUIPanel();			pnl_MemoryCenter.setLayout(new BorderLayout());							/* Memory Panel */				pnl_Memory = new GUIPanel();				pnl_Memory.setLayout(new BoxLayout(pnl_Memory, BoxLayout.X_AXIS));										/* Memory List */					jta_Memory = new JTextArea();					jta_Memory.setLineWrap(true);	          		jta_Memory.setMargin(new Insets(3, 3, 3, 3));	          		jta_Memory.setFont(new Font("Courier", Font.BOLD, 16));	          		jta_Memory.setBackground(Constants.CLR_DEFAULT_BACKGROUND);					jta_Memory.setEditable(false);	          	pnl_Memory.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP));				pnl_Memory.add(jta_Memory);				pnl_Memory.add(Box.createHorizontalStrut(Constants.INT_SMALL_GAP));		          					pnl_MemoryCenter.add(pnl_Memory, BorderLayout.CENTER);			/* South panel */			pnl_MemorySouth = new GUIPanel();				/* Okay button */				btn_MemoryOkay = new JButton("Okay");				btn_MemoryOkay.addActionListener(new ActionListener()												{													public void actionPerformed(ActionEvent e)													{														dlg_Memory.setVisible(false);													}												});	        pnl_MemorySouth.add(btn_MemoryOkay);		dlg_Memory.getContentPane().add(pnl_MemoryNorth, BorderLayout.NORTH);		dlg_Memory.getContentPane().add(pnl_MemoryCenter, BorderLayout.CENTER);		dlg_Memory.getContentPane().add(pnl_MemorySouth, BorderLayout.SOUTH);	}		/**	 * Display the memory dialog and add all of the current identities in the 	 * agent's memory into the dialog.	 */	protected void viewMemory()	{		Vector mem = this.model.getAgent().getMemory();				lbl_MemoryStat.setText("Known Identities: " + mem.size());		jta_Memory.setText("");				for(int a = 0; a < mem.size(); a++)		{			jta_Memory.append("- " + ((Identity)mem.get(a)).getIdentityName() + "\n");		}				dlg_Memory.setVisible(true);	}			/**	 * Initiates the scanning of an eye action by allowing the user to choose	 * an image from the local disk structure. The image is then sent to the agent	 * for processing.	 */	protected void scanEye()	{		String name = "";				//Show file chooser so the user can select a file		if( fch_fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)		{			clear();						//Ensure that the name is provided			while(name == null || name.length() == 0)			{				//Display input dialog to have user input the name of the subject being scanned				name = JOptionPane.showInputDialog(this, "Name of subject:\n", "Subject Name", JOptionPane.QUESTION_MESSAGE);							if(name != null && name.length() > 0)				{					//Have the model scan the eye					model.scanEye(name, fch_fileChooser.getSelectedFile().getPath());													//Redraw the images of the scanning process in the user interface					redrawSubject();				}				else				{					if(name != null)						JOptionPane.showMessageDialog(this, "Subject name missing");				}			}		}		else			clear();	}		/**	 * Rescans the eye using the current global variables. This is similar to the	 * scanEye method but the subject used is the current subject.	 */	public void rescanEye()	{		//If the current subject is not null		if(model.getAgent().getCurrentSubject() != null)		{			//Rescan the subject's eye			model.rescanEye(); 						//Redraw the images of the scanning process in the user interface			redrawSubject();		}	}		/**	 * Redraws the images from each of the processes in the scan in each of the	 * appropriate image panels.	 */	public void redrawSubject()	{					/* Original image panel */		pnl_OriginalImage.setImage(model.getOriginalImage());							/* Grayscale image panel */		pnl_GrayscaleImage.setImage(model.getGrayscaleImage());				/* Grayscale median filter image */		pnl_GrayscaleMedianFilterImage.setImage(model.getMedianFilterImage());							/* Grayscale median filter image with center panel */		pnl_GrayscaleMedianFilterImageWithCenter.setImage(model.getGrayscaleImage());		pnl_GrayscaleMedianFilterImageWithCenter.drawCenter(model.getSubjectPupilCenter());		pnl_GrayscaleMedianFilterImageWithCenter.drawPupilRadius(model.getSubjectPupilRadius());				/* Edge Detection panel */		pnl_EdgeImage.setImage(model.getEdgeImage());		pnl_EdgeImage.drawCenter(model.getSubjectPupilCenter());		pnl_EdgeImage.drawPupilRadius(model.getSubjectPupilRadius());				/* Edge Image With Radii */		pnl_EdgeImageWithRadii.setImage(model.getEdgeImage());		pnl_EdgeImageWithRadii.drawCenter(model.getSubjectPupilCenter());		pnl_EdgeImageWithRadii.drawPupilRadius(model.getSubjectPupilRadius());		pnl_EdgeImageWithRadii.drawIrisRadius(model.getSubjectIrisRadius());				/* Grayscale iris only */		pnl_GrayscaleIrisOnly.setImage(model.getOriginalImage());		pnl_GrayscaleIrisOnly.drawCenter(model.getSubjectPupilCenter());		pnl_GrayscaleIrisOnly.drawPupilRadius(model.getSubjectPupilRadius());		pnl_GrayscaleIrisOnly.drawIrisRadius(model.getSubjectIrisRadius());		pnl_GrayscaleIrisOnly.drawLocalization();				/* Unwrapped Iris Panel */		if(model.getUnwrappedImage() != null)		{			pnl_UnwrappedIris.setImage(model.getUnwrappedImage()); 		}				}		/**	 * Performs the matching operation by instructing the model to match the 	 * eye specified by the user from the file chooser dialog.	 */	protected void matchAgaintMemory()	{			if( fch_fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)		{			clear();						JOptionPane.showMessageDialog(this, "To the best of my knowledge, the identity of this subject is '" + this.model.matchEye(fch_fileChooser.getSelectedFile().getPath()) + "'");			}		else			clear();	}	/**	 * Loads memory from the specified file into the agent.	 */	protected void loadAgent()	{		       	if( fch_agentFileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)		{				Agent a = new Agent(this, Functions.deserializeAgent(fch_agentFileChooser.getSelectedFile()));									this.model.setAgent(a);		}	}  	/** 	 * Saves the memory of the agent to the specified file  	 */	protected void saveAgent()	{		if( fch_agentFileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION)		{				Functions.serializeAgent(fch_agentFileChooser.getSelectedFile(), this.model.getAgent());		}	}		/**	 * Clears the images in the image panels to nothing.	 */	protected void clear()	{		pnl_OriginalImage.setImage(null);		pnl_GrayscaleImage.setImage(null);		pnl_GrayscaleMedianFilterImage.setImage(null);		pnl_GrayscaleMedianFilterImageWithCenter.setImage(null);		pnl_EdgeImage.setImage(null);		pnl_EdgeImageWithRadii.setImage(null);		pnl_GrayscaleIrisOnly.setImage(null);		pnl_UnwrappedIris.setImage(null);	}		/**	 * Closes the user interface.	 */	protected void close()	{		System.exit(1);	}}

⌨️ 快捷键说明

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