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

📄 displayrules.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 : displayRules.java//package jaNet.backprop.gui;

import java.awt.*;

public class displayRules extends Dialog {		


	public TextField 	entryShowDataFrequence;
	public TextField 	entryShowGraphFrequence;
	public Button 		buttonOk;
	public Button 		buttonCancel;

    private BPNgui		dearParent;
    
    private int			tempDataFrequence,  origDataFrequence;
    private int			tempGraphFrequence, origGraphFrequence;

	public displayRules(Frame parent) {
	    super(parent, "BPNgui Display Rules", false);
		Label 		label_1;
		Label 		label_2;
		Label 		label_3;
		Separator	separator;

		// this is my parent
		dearParent = (BPNgui) parent;
        this.setBackground(Color.lightGray);

		// main panel
		GridBagLayout grid = new GridBagLayout();
		int rowHeights[] = {0,5,25,25,5,25,10,30,5};
		int columnWidths[] = {0,5,20,100,7,100,20,5};
		double rowWeights[] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
		double columnWeights[] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
		grid.rowHeights = rowHeights;
		grid.columnWidths = columnWidths;
		grid.rowWeights = rowWeights;
		grid.columnWeights = columnWeights;

		label_1 = new Label();
    	label_1.setFont(new Font("Helvetica",Font.BOLD , 12));
		label_1.setText("Display frequency :");
		this.add(label_1);

		label_2 = new Label();
		label_2.setFont(new Font("Helvetica",Font.PLAIN , 12));
		label_2.setText("Data");
		this.add(label_2);

		entryShowDataFrequence = new TextField(8);
		this.add(entryShowDataFrequence);

		label_3 = new Label();
		label_3.setFont(new Font("Helvetica",Font.PLAIN , 12));
		label_3.setText("Graph");
		this.add(label_3);

		entryShowGraphFrequence = new TextField(8);
		this.add(entryShowGraphFrequence);

		separator = new Separator(Separator.HORIZONTAL);
    	separator.perSide = 0;
    	separator.rise = Separator.IN;
		this.add(separator);

		buttonOk = new Button();
		buttonOk.setLabel("OK");
		this.add(buttonOk);

		buttonCancel = new Button();
		buttonCancel.setLabel("Cancel");
		this.add(buttonCancel);

		// Geometry management
		GridBagConstraints con = new GridBagConstraints();
		reset(con);
		con.gridx = 2;
		con.gridy = 2;
		con.gridwidth = 5;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.HORIZONTAL;
		grid.setConstraints(label_1, con);

		reset(con);
		con.gridx = 2;
		con.gridy = 3;
		con.gridwidth = 2;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.HORIZONTAL;
		grid.setConstraints(label_2, con);

		reset(con);
		con.gridx = 4;
		con.gridy = 3;
		con.gridwidth = 3;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.HORIZONTAL;
		grid.setConstraints(entryShowDataFrequence, con);

		reset(con);
		con.gridx = 2;
		con.gridy = 5;
		con.gridwidth = 2;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.HORIZONTAL;
		grid.setConstraints(label_3, con);

		reset(con);
		con.gridx = 4;
		con.gridy = 5;
		con.gridwidth = 3;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.BOTH;
		grid.setConstraints(entryShowGraphFrequence, con);

		reset(con);
		con.gridx = 2;
		con.gridy = 6;
		con.gridwidth = 5;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.BOTH;
		grid.setConstraints(separator, con);

		reset(con);
		con.gridx = 3;
		con.gridy = 7;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.HORIZONTAL;
		grid.setConstraints(buttonOk, con);

		reset(con);
		con.gridx = 5;
		con.gridy = 7;
		con.anchor = GridBagConstraints.CENTER;
		con.fill = GridBagConstraints.HORIZONTAL;
		grid.setConstraints(buttonCancel, con);


		// Resize behavior management and parent heirarchy
		setLayout(grid);


        addNotify();
        pack();
	}
	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 synchronized void show(int dataFreq, int graphFreq){
    
		tempDataFrequence	= dataFreq;
		tempGraphFrequence	= graphFreq;
		
		origDataFrequence = dataFreq;
		origGraphFrequence	= graphFreq;
		
		entryShowDataFrequence.setText(""+dataFreq);
		entryShowGraphFrequence.setText(""+graphFreq);
		
		super.show();
	}

    public synchronized boolean handleEvent(Event event) {
    	if (event.id == Event.KEY_RELEASE && event.target == entryShowDataFrequence) {
			String entry = entryShowDataFrequence.getText();
			int value = 0;
			try{
				value = Integer.parseInt(entry);
			}catch(NumberFormatException nfe){
				if(entry.compareTo("") != 0){
					//dearParent.todo = ""+nfe;
					return true;
				}else{
					value = 0;
				}
			}
			tempDataFrequence = value;
			return super.handleEvent(event);
    	}else
    	if (event.id == Event.KEY_RELEASE && event.target == entryShowGraphFrequence) {
			String entry = entryShowGraphFrequence.getText();
			int value = 0;
			try{
				value = Integer.parseInt(entry);
			}catch(NumberFormatException nfe){
				if(entry.compareTo("") != 0){
					//dearParent.todo = ""+nfe;
					return true;
				}else{
					value = 0;
				}
			}
			tempGraphFrequence = value;
			return super.handleEvent(event);
    	}else
    	if (event.id == Event.ACTION_EVENT && event.target == buttonOk) {
    	    	clickedButtonOk();
    	    	return true;
    	}else
    	if (event.id == Event.ACTION_EVENT && event.target == buttonCancel) {
    	    	clickedButtonCancel();
    	    	return true;
    	}else
    	if (event.id == Event.WINDOW_DESTROY) {
    	    hide();
    	    return true;
    	}
    	return super.handleEvent(event);
    }
    
    public void clickedButtonOk() {
		if(tempDataFrequence!=origDataFrequence || tempGraphFrequence!=origGraphFrequence){
			dearParent.setDisplayFrequences(tempDataFrequence,tempGraphFrequence);
			if(tempDataFrequence!=origDataFrequence)
				dearParent.putOnMonitor("Show data frequence changed to "+tempDataFrequence+"\n");
			if(tempGraphFrequence!=origGraphFrequence)
				dearParent.putOnMonitor("Show graph frequence changed to "+tempGraphFrequence+"\n");
		}
        this.hide();
    }
    public void clickedButtonCancel() {
        this.hide();
    }

}

⌨️ 快捷键说明

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