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

📄 optionsbox.java

📁 JaNet: Java Neural Network Toolkit resume: A well documented toolkit for designing and training, a
💻 JAVA
字号:
////////////////////////////////////////////////////////////////////////////////////  //  //  Copyright (C) 1996 L.  Patocchi & W.Gander////  This program is free  software;  you can  redistribute  it and/or  modify it//  under the terms of the GNU General  Public  License as published by the Free//  Software  Foundation;  either  version 2 of the License, or (at your option)//  any later version.////  This program is  distributed in the hope that it will be useful, but WITHOUT//  ANY  WARRANTY;  without  even the implied  warranty  of  MERCHANTABILITY  or//  FITNESS FOR A PARTICULAR  PURPOSE.  See the GNU General  Public  License for//  more details.////  You should have received a copy of the GNU General Public License along with//  this program; if not, write to the Free Software  Foundation, Inc., 675 Mass//  Ave, Cambridge, MA 02139, USA.////  Contacts://  //    Project Supervisor//      W.Hett       hew@info.isbiel.ch//  //    Authors//      W.Gander     gandw@info.isbiel.ch//      L.Patocchi   patol@info.isbiel.ch////  Documentation can be found at:////      http://www.isbiel.ch/Projects/janet/index.html////////////////////////////////////////////////////////////////////////////////////////// File : OptionsBox.java///*	jaNet - A Neural Network Toolkit for Java	-----------------------------------------	Author :		W.Gander	Modifications :	10.09.1996	Filename :		OptionsBox.java	Description :	Shows the Options Dialog Box	(c) 1996 Biel School of Engineering */package jaNet;import java.awt.*;import java.util.*;class OptionsBox extends Dialog {	public	List			ModuleList;	public	Button			AddButton;	public	Button			RemoveButton;	public	Button			CloseButton;	private editModuleType	editModuleTypeDialog;		private Vector			currentModuleTable;	private int				currentSelection = -1;    private jaNet			dearParent;	private	int				weight, height;	public OptionsBox(Frame parent){	    super(parent, "Options", false);		Label		label_1;		Separator	separator;		addNotify();		dearParent = (jaNet) parent;        this.setBackground(Color.lightGray);		// main panel		GridBagLayout grid = new GridBagLayout();		int rowHeights[] = {0,5,20,5,100,10,30,5};		int columnWidths[] = {0,5,75,100,75,100,75,5};		double rowWeights[] = {0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0};		double columnWeights[] = {0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0};		grid.rowHeights = rowHeights;		grid.columnWidths = columnWidths;		grid.rowWeights = rowWeights;		grid.columnWeights = columnWeights;		for(int i=0;i<rowHeights.length;i++) height += rowHeights[i];		for(int i=0;i<columnWidths.length;i++) weight += columnWidths[i];		resize(insets().left + insets().right+weight, insets().top + insets().bottom + height);		label_1 = new Label();		label_1.setText("Available networks :");		this.add(label_1);		separator = new Separator(Separator.HORIZONTAL);    	separator.perSide = 0;    	separator.rise = Separator.IN;		this.add(separator);		ModuleList = new List(4,false);		ModuleList.setFont(new Font("Courier",Font.PLAIN , 12));		this.add(ModuleList);		AddButton = new Button();		AddButton.setLabel("Add...");		this.add(AddButton);		RemoveButton = new Button();		RemoveButton.setLabel("Remove");		this.add(RemoveButton);		CloseButton = new Button();		CloseButton.setLabel("Close");		this.add(CloseButton);		// Geometry management		GridBagConstraints con = new GridBagConstraints();		reset(con);		con.gridx = 2;		con.gridy = 2;		con.gridwidth = 3;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.HORIZONTAL;		grid.setConstraints(label_1, con);		reset(con);		con.gridx = 2;		con.gridy = 4;		con.gridwidth = 5;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.BOTH;		grid.setConstraints(ModuleList, con);		reset(con);		con.gridx = 1;		con.gridy = 5;		con.gridwidth = 7;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.BOTH;		grid.setConstraints(separator, con);		reset(con);		con.gridx = 2;		con.gridy = 6;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.HORIZONTAL;		grid.setConstraints(AddButton, con);		reset(con);		con.gridx = 4;		con.gridy = 6;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.HORIZONTAL;		grid.setConstraints(RemoveButton, con);		reset(con);		con.gridx = 6;		con.gridy = 6;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.HORIZONTAL;		grid.setConstraints(CloseButton, con);		// Resize behavior management and parent heirarchy		setLayout(grid);		pack();		//resize(310, 200);	}	public synchronized	void show(Vector moduleTable) {		ModuleTypes tempMT;		Rectangle bounds = getParent().bounds();		Rectangle abounds =	bounds();				currentModuleTable = moduleTable;		move(bounds.x +	(bounds.width -	abounds.width)/	2,			bounds.y + abounds.height);		ModuleList.clear();		for(int i=0; i< moduleTable.size(); i++){			tempMT =(ModuleTypes) moduleTable.elementAt(i);    		ModuleList.addItem(formatItem(tempMT.ModuleTypeName, tempMT.ModuleClassName));		}    			super.show();	}	public void setModuleType(String moduleName, String className){		if(currentSelection != -1){			// modify an element in the list			ModuleList.delItem(currentSelection);			currentModuleTable.setElementAt(new ModuleTypes(moduleName, className), currentSelection);			ModuleList.addItem(formatItem(moduleName, className), currentSelection);			ModuleList.select(currentSelection);						((MenuItem)dearParent.newModuleMenu.getItem(currentSelection)).setLabel(moduleName);		}else{			// add a new element in the list			currentModuleTable.addElement(new ModuleTypes(moduleName, className));			ModuleList.addItem(formatItem(moduleName, className));						// entry in current menu list			dearParent.newModuleMenu.add(moduleName);				}	}	private	void reset(GridBagConstraints con) {		con.gridx =	GridBagConstraints.RELATIVE;		con.gridy =	GridBagConstraints.RELATIVE;		con.gridwidth =	1;		con.gridheight = 1;		con.weightx	= 0;		con.weighty	= 0;		con.anchor = GridBagConstraints.CENTER;		con.fill = GridBagConstraints.NONE;		con.insets = new Insets(0, 0, 0, 0);		con.ipadx =	0;		con.ipady =	0;	}	public boolean handleEvent(Event event) {        if (event.id == Event.LIST_SELECT && event.target == ModuleList) {                currentSelection = ((Integer)event.arg).intValue();                return true;        }else         if (event.id == Event.LIST_DESELECT && event.target == ModuleList) {				ModuleList.select(((Integer)event.arg).intValue());        }else         if (event.id == Event.ACTION_EVENT && event.target == ModuleList) {                doubleClickModuleList();                return true;        }else		if (event.id ==	Event.ACTION_EVENT && event.target == CloseButton) {			selectedCloseButton ();			return true;		}		if (event.id ==	Event.ACTION_EVENT && event.target == AddButton) {			selectedAddModuleType ();			return true;		}		if (event.id ==	Event.ACTION_EVENT && event.target == RemoveButton) {			selectedRemoveModuleType ();			return true;		}		if (event.id ==	Event.WINDOW_DESTROY) {			this.hide ();			return true;		}		return super.handleEvent(event);	}    public void doubleClickModuleList() {		if(editModuleTypeDialog == null) 			editModuleTypeDialog = new editModuleType(dearParent, this);		editModuleTypeDialog.show(((ModuleTypes) currentModuleTable.elementAt(currentSelection)).ModuleTypeName ,								  ((ModuleTypes) currentModuleTable.elementAt(currentSelection)).ModuleClassName);    }    public void selectedAddModuleType(){		if(currentSelection != -1){			ModuleList.deselect(currentSelection);			currentSelection = -1;		}		if(editModuleTypeDialog == null) 			editModuleTypeDialog = new editModuleType(dearParent, this);		editModuleTypeDialog.show("","");		//update jaNet module menu	}	public void selectedRemoveModuleType(){		if(currentSelection != -1){						dearParent.newModuleMenu.remove(currentSelection);					ModuleList.delItem(currentSelection);			currentModuleTable.removeElementAt(currentSelection);			if(currentSelection == ModuleList.countItems()) currentSelection--;			if(currentSelection != -1)ModuleList.select(currentSelection);		}	}	public void selectedCloseButton() {		this.hide ();	}		public String formatItem(String str1, String str2){		String str0 = str1;		while(str0.length() < 20) str0 = str0+" ";		return str0 + str2;	}}

⌨️ 快捷键说明

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