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

📄 guiantminerjframe.java

📁 Short description: GUI Ant-Miner is a tool for extracting classification rules from data. It is an u
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
						jPanel9.setLayout(jPanel9Layout);						jPanel9.setBounds(7, 8, 260, 50);						{							jLabel4 = new JLabel();							jPanel9.add(jLabel4, new GridBagConstraints(								1,								0,								1,								1,								0.0,								0.0,								GridBagConstraints.WEST,								GridBagConstraints.NONE,								new Insets(0, 0, 0, 0),								0,								0));							jLabel4.setText("Folds: ");							jLabel4.setFont(new java.awt.Font("Dialog", 0, 12));						}						{							jTextField2 = new JTextField();							jPanel9.add(jTextField2, new GridBagConstraints(								2,								0,								1,								1,								0.0,								0.0,								GridBagConstraints.WEST,								GridBagConstraints.NONE,								new Insets(0, 0, 0, 0),								0,								0));							jTextField2.setText("10");							jTextField2								.setPreferredSize(new java.awt.Dimension(40, 20));						}					}					{						jScrollPane2 = new JScrollPane();						jPanel3.add(jScrollPane2, new GridBagConstraints(							1,							0,							1,							1,							1.0,							1.0,							GridBagConstraints.CENTER,							GridBagConstraints.BOTH,							new Insets(5, 2, 0, 3),							0,							0));						jScrollPane2.setBounds(271, 8, 509, 501);						jScrollPane2.setBorder(BorderFactory.createTitledBorder("Output"));						{							jTextArea1 = new JTextArea();							jScrollPane2.setViewportView(jTextArea1);							jTextArea1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));							jTextArea1.setEditable(false);						}					}					{						jCheckBox1 = new JCheckBox();						jPanel3.add(jCheckBox1, new GridBagConstraints(							0,							0,							1,							1,							0.0,							0.0,							GridBagConstraints.NORTHWEST,							GridBagConstraints.NONE,							new Insets(212, 10, 0, 0),							0,							0));						jCheckBox1.setText("Clear output screen");						jCheckBox1.setBounds(17, 201, 133, 30);						jCheckBox1.setFont(new java.awt.Font("Dialog",0,12));						jCheckBox1.setSelected(true);						jCheckBox1.setToolTipText("Clear the output screen the next time a classification task is run.");					}					{						jCheckBox2 = new JCheckBox();						jPanel3.add(jCheckBox2, new GridBagConstraints(							0,							0,							1,							1,							0.0,							0.0,							GridBagConstraints.NORTHWEST,							GridBagConstraints.NONE,							new Insets(235, 10, 0, 0),							0,							0));						jCheckBox2.setText("Print test set");						jCheckBox2.setFont(new java.awt.Font("Dialog",0,12));					}					{						jCheckBox3 = new JCheckBox();						jPanel3.add(jCheckBox3, new GridBagConstraints(							0,							0,							1,							1,							0.0,							0.0,							GridBagConstraints.NORTHWEST,							GridBagConstraints.NONE,							new Insets(258, 10, 0, 0),							0,							0));						jCheckBox3.setText("Print training set");						jCheckBox3.setFont(new java.awt.Font("Dialog",0,12));					}					{						jButton2 = new JButton();						jPanel3.add(jButton2, new GridBagConstraints(							0,							0,							1,							1,							0.0,							0.0,							GridBagConstraints.NORTHWEST,							GridBagConstraints.NONE,							new Insets(292, 95, 0, 0),							0,							0));						jButton2.setText("Cancel");						jButton2.setToolTipText("Cancel task.");						jButton2.setPreferredSize(new java.awt.Dimension(75, 23));						jButton2.setMaximumSize(new java.awt.Dimension(75, 23));						jButton2.setMinimumSize(new java.awt.Dimension(75, 23));						jButton2.setEnabled(false);						jButton2.addActionListener(new ActionListener() {							public void actionPerformed(ActionEvent evt) {								cv.stop();							}						});						jButton2.addMouseListener(new MouseAdapter() {							public void mouseExited(MouseEvent evt) {								if (isClassifying)									jTabbedPane1										.setCursor(Cursor											.getPredefinedCursor(Cursor.WAIT_CURSOR));							}							public void mouseEntered(MouseEvent evt) {								jTabbedPane1									.setCursor(Cursor										.getPredefinedCursor(Cursor.DEFAULT_CURSOR));							}						});					}				}			}		} catch (Exception e) {			e.printStackTrace();		}		pack();		this.setSize(800, 600);		setGraph();					jTabbedPane1.setEnabledAt(1,false);		jTabbedPane1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));		{			jPanel8 = new JPanel();			GridBagLayout jPanel8Layout = new GridBagLayout();			jPanel8Layout.columnWeights = new double[] {0.1,0.1};			jPanel8Layout.columnWidths = new int[] {7,7};			jPanel8Layout.rowWeights = new double[] {0.1};			jPanel8Layout.rowHeights = new int[] {7};			jPanel8.setLayout(jPanel8Layout);			this.getContentPane().add(jPanel8, BorderLayout.SOUTH);			jPanel8.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));			{				jProgressBar1 = new JProgressBar();				jPanel8.add(jProgressBar1, new GridBagConstraints(					1,					0,					1,					1,					0.0,					0.0,					GridBagConstraints.EAST,					GridBagConstraints.NONE,					new Insets(0, 0, 0, 0),					0,					0));				jProgressBar1.setPreferredSize(new java.awt.Dimension(140, 18));			}			{				jLabel17 = new JLabel();				jPanel8.add(jLabel17, new GridBagConstraints(					0,					0,					1,					1,					0.0,					0.0,					GridBagConstraints.WEST,					GridBagConstraints.NONE,					new Insets(0, 0, 0, 0),					0,					0));				jLabel17.setText("Idle");			}		}			}	public void setLabel2(String label){		jLabel2.setText(label);	}	public JLabel getJLabel2(){		return jLabel2;	}	public boolean getJCheckBox1IsSelected(){		return jCheckBox1.isSelected();	}	public boolean getJCheckBox2IsSelected(){		return jCheckBox2.isSelected();	}	public boolean getJCheckBox3IsSelected(){		return jCheckBox3.isSelected();	}	public String getjTextField2Value(){		return jTextField2.getText();	}	public JTextField getJTextField1(){		return jTextField1;	}	public JTextField getJTextField3(){		return jTextField3;	}	public JTextField getJTextField4(){		return jTextField4;	}	public JTextField getJTextField5(){		return jTextField5;	}	public JTextField getJTextField6(){		return jTextField6;	}	public JTextArea getJTextArea1(){		return jTextArea1;	}	public JProgressBar getJProgressBar1(){		return jProgressBar1;	}	public void setTableAtt1(Attribute [] attributesArray){		String numberAndName[][] = new String[attributesArray.length][2];		for(int n=0; n < attributesArray.length; n++){			numberAndName[n][0] = new Integer(n + 1).toString();			numberAndName[n][1] = attributesArray[n].getAttributeName();		}				jTable1Model = new MyTableModel(			numberAndName,			new String[] { "#", "Name" });		jTable1 = new JTable();		jScrollPane1.setViewportView(jTable1);		jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);		jTable1.setModel(jTable1Model);				ListSelectionModel rowSM = jTable1.getSelectionModel();		rowSM.addListSelectionListener(new ListSelectionListener() {		    public void valueChanged(ListSelectionEvent e) {		        //Ignore extra messages.		    	if (e.getValueIsAdjusting()) return;		        ListSelectionModel lsm = (ListSelectionModel)e.getSource();		        if (lsm.isSelectionEmpty()) {		            //no rows are selected		        } else {		            int selectedRow = lsm.getMinSelectionIndex();		            setTableAtt2(selectedRow, generateStats(selectedRow));		            jLabel8.setText(ar()[selectedRow].getAttributeName());		            		            DecimalFormat myFormatter = new DecimalFormat("###.#");		            jLabel10.setText(String.valueOf(calculateMissing(selectedRow))+ " ("+myFormatter.format(((float) calculateMissing(selectedRow)/myFileReader.getDataInstancesArray().length)*100)+"%)");		            		            jLabelDistinct.setText(String.valueOf(jTable2.getModel().getRowCount()));		        }		    }		});		rowSM.setSelectionInterval(0, 0);	}		private Attribute[] ar(){		return this.attributesArray;	}		public void setTableAtt2(int attributeIndex, int [] typesOccurences){		String labelAndCount[][] = new String[typesOccurences.length][2];		for(int n=0; n < typesOccurences.length; n++){			labelAndCount[n][0] = attributesArray[attributeIndex].getTypes()[n];			labelAndCount[n][1] = new Integer(typesOccurences[n]).toString();		}				jTable2Model = new MyTableModel(			labelAndCount,			new String[] { "Attribute Value", "Quantity of Instances" });		jTable2 = new JTable();		jScrollPane3.setViewportView(jTable2);		jTable2.setModel(jTable2Model);	}		public void setGraph(){		canvas1 = new AttGraph();		jPanel4.add(canvas1, BorderLayout.CENTER);				//canvas1.setSize(347, 220);		canvas1.setBounds(2, 2, 377, 221);	}		public void setInitialState(){		jTabbedPane1.setEnabledAt(1,false);		jTabbedPane1.setSelectedIndex(0);		if(jTable1 != null){			jTable1.removeAll();			jTable1.setVisible(false);			jTable1Model = null;		}		if(jTable2 != null){			jTable2.removeAll();			jTable2.setVisible(false);			jTable2Model = null;		}		jLabel2.setText("");		jLabelNumberOfInstances.setText("");		jLabelNumberOfAttributes.setText("");		jLabel8.setText("");		jLabel10.setText("");		jLabelDistinct.setText("");	}		public void setIsClassifying(boolean b){		if(b){			jLabel17.setText("Classifying " + jLabel2.getText() + "...");			isClassifying = true;			jMenuItem1.setEnabled(false);			jButton1.setEnabled(false);			jButton2.setEnabled(true);			jTabbedPane1.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));		}else{			jLabel17.setText("Idle");			isClassifying = false;			jMenuItem1.setEnabled(true);			jButton1.setEnabled(true);			jButton2.setEnabled(false);			jTabbedPane1.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));					}	}		public MyFileReader getMyFileReader(){		return myFileReader;	}		/**	* Auto-generated method for setting the popup menu for a component	*/	@SuppressWarnings("unused")	private void setComponentPopupMenu(final java.awt.Component parent, final javax.swing.JPopupMenu menu) {		parent.addMouseListener(new java.awt.event.MouseAdapter() {			public void mousePressed(java.awt.event.MouseEvent e) {				if(e.isPopupTrigger())					menu.show(parent, e.getX(), e.getY());			}			public void mouseReleased(java.awt.event.MouseEvent e) {				if(e.isPopupTrigger())					menu.show(parent, e.getX(), e.getY());			}		});	}		public JLabel getJLabel17() {		return jLabel17;	}	class MyTableModel extends DefaultTableModel{	    /**		 * 		 */		private static final long serialVersionUID = 1L;		public MyTableModel(Object[][] data, Object[] columnNames) {	        setDataVector(data, columnNames);	    }		public boolean isCellEditable(int row, int column)	    {	        return false;	    }	}		/**	 * @param attributePos	 * @return	 */	private int calculateMissing(int attributePos){		int count=0;		for(int x=0; x < dataInstancesArray.length; x++){			if(dataInstancesArray[x].getValues()[attributePos] == -1)				count++;		}		return count;	}	/**	 * Determines the number of occurences of the attribute values in the dataset	 * @param attributePos	 * @return	 */	private int [] generateStats(int attributePos){		int count;		int [] typesArray = (attributesArray[attributePos]).getIntTypesArray();		int [] returnArray = new int[typesArray.length];		for(int type=0; type < typesArray.length; type++){			count = 0;			for(int x2=0; x2 < dataInstancesArray.length; x2++){				if(dataInstancesArray[x2].getValues()[attributePos] == type)					count++;			}			returnArray[type] = count;		}		return returnArray;	}}

⌨️ 快捷键说明

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