📄 janet.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 : jaNet.java///* jaNet - A Neural Network Toolkit for Java ----------------------------------------- Author : W.Gander Modifications : 10.09.1996 Filename : jaNet.java Description : jaNet Main class (c) 1996 Biel School of Engineering */package jaNet;import java.awt.*;import java.io.*;import java.util.*;public class jaNet extends Frame implements Confirmable,Runnable{ public static final String version = "1.0beta1"; public static final String homePage = "http://www.isbiel.ch/~patol/janet"; public static final String NOTHING = "NOTHING"; public static final int QUIT_CONFIRM = 0; public static final int QUIT_SAVEALL_CONFIRM = 1; public static final int QUIT_ASK_CONFIRM = 2; public static final int PRJ_SAVE = 3; // Declarations private String jaNetCFGFile = "jaNet.cfg"; private String jaNetCFGPath = "."; private String jaNetHomePath = "."; private boolean isAProjectOpen = false; private jaNetProject currentProject = null; private FileDialog openProjectFD = null; private FileDialog createProjectFD = null; private MenuItem menuNew; private MenuItem menuOpen; private MenuItem menuEdit; private MenuItem menuClose; private OptionsBox jaNetOptionsBox; private confirmDialog jaNetConfirmDialog; private ModuleList jaNetModuleList; private AboutBox jaNetAboutBox; private Vector moduleTypeTable; private ModuleTypes modt = null; // thread guard private Thread threadGuard = null; public String todo = NOTHING; public Menu moduleMenu; public Menu newModuleMenu;////////////////////////////////////////////////////////////////////// MAIN method//////////////////////////////////////////////////////////////////// public static void main(String args[]) { jaNet myJaNet = new jaNet(args); }////////////////////////////////////////////////////////////////////// jaNet creator and commandline attributes parser//////////////////////////////////////////////////////////////////// public jaNet(String args[]) { super("jaNet"); addNotify(); Menu fileMenu; Menu projectMenu; Menu helpMenu; int i=0; // parse imput commands while(i<args.length){ if(args[i].compareTo("-cfgpath")==0 && i< args.length-1){ i++; jaNetCFGPath = args[i]; }else if(args[i].compareTo("-cfgfile")==0 && i< args.length-1){ i++; jaNetCFGFile = args[i]; }else if(args[i].compareTo("-homepath")==0 && i< args.length-1){ i++; jaNetHomePath = args[i]; } i++; } moduleTypeTable = new Vector(); readConfigFile(jaNetCFGPath, jaNetCFGFile); MenuBar mb = new MenuBar(); fileMenu = new Menu("File"); fileMenu.add(new MenuItem("Options")); fileMenu.addSeparator(); fileMenu.add(new MenuItem("Exit and Save All")); fileMenu.add(new MenuItem("Exit and Discard")); fileMenu.add(new MenuItem("Exit")); mb.add(fileMenu); projectMenu = new Menu("Project"); projectMenu.add((menuNew = new MenuItem("New..."))); projectMenu.add((menuOpen= new MenuItem("Open..."))); projectMenu.add((menuEdit= new MenuItem("Edit..."))); menuEdit.disable(); projectMenu.add((menuClose= new MenuItem("Close"))); menuClose.disable(); mb.add(projectMenu); moduleMenu = new Menu("Module"); newModuleMenu = new Menu("New"); // creates the new module menu on the fly for(int j=0; j< moduleTypeTable.size(); j++){ newModuleMenu.add(new MenuItem(((ModuleTypes)moduleTypeTable.elementAt(j)).ModuleTypeName)); } moduleMenu.add(newModuleMenu); moduleMenu.add(new MenuItem("Module list")); mb.add(moduleMenu); helpMenu = new Menu("Help"); helpMenu.add(new MenuItem("Contents")); helpMenu.add(new MenuItem("Java API")); helpMenu.addSeparator(); helpMenu.add(new MenuItem("About...")); mb.add(helpMenu); setMenuBar(mb); //Display the help menu in a special reserved place. mb.setHelpMenu(helpMenu); setLayout(null); if(System.getProperty("file.separator").compareTo("/") == 0){ resize(1280, insets().top + insets().bottom); }else{ resize(1024, insets().top + insets().bottom+50); } pack(); this.show(); setProjectInactive(); // start Thread guard start(); } public synchronized void show() { move(0, 0); super.show(); } public void paint(Graphics g) { move(0, 0); } public void exit(){ hide(); // hide the Frame writeConfigFile(jaNetCFGPath, jaNetCFGFile); // write config dispose(); // tell windowing system to free resources System.exit(0); // exit }////////////////////////////////////////////////////////////////////// events handlers//////////////////////////////////////////////////////////////////// public boolean handleEvent(Event event) { if(event.id == Event.WINDOW_MOVED){ //move(0, 0); }else if(event.id == Event.WINDOW_DESTROY) { jaNetConfirmDialog = new confirmDialog(this, "Are You sure to quit jaNet ?", QUIT_CONFIRM); jaNetConfirmDialog.show(); return true; } return super.handleEvent(event); } public boolean action(Event event, Object arg) { if (event.target instanceof MenuItem) { String label = (String) arg; if (label.equalsIgnoreCase("Options")) { selectedOptions(); return true; } else if (label.equalsIgnoreCase("Exit and Save All")) { selectedExitSaveAll(); return true; } else if (label.equalsIgnoreCase("Exit and Discard")) { selectedExitDiscard(); return true; } else if (label.equalsIgnoreCase("Exit")) { selectedExit(); return true; } else if (label.equalsIgnoreCase("New...")) { selectedNewProject(); return true; } else if (label.equalsIgnoreCase("Open...")) { selectedOpenProject(); return true; } else if (label.equalsIgnoreCase("Edit...")) { selectedEditProject(); return true; } else if (label.equalsIgnoreCase("Close")) { selectedCloseProject(); return true; } else if (label.equalsIgnoreCase("Module list")) { selectedModuleList(); return true; } else if (label.equalsIgnoreCase("Contents")) { selectedContents(); return true; } else if (label.equalsIgnoreCase("Java API")) { selectedJavaAPI(); return true; } else if (label.equalsIgnoreCase("About...")) { selectedAbout(); return true; } else { selectedNewModule(label); } } return super.action(event, arg); }////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// public void setProjectActive(){ menuOpen.disable(); menuNew.disable(); menuEdit.enable(); menuClose.enable(); moduleMenu.enable(); } public void setProjectInactive(){ menuOpen.enable(); menuNew.enable(); menuEdit.disable(); menuClose.disable(); moduleMenu.disable(); if(jaNetModuleList != null)jaNetModuleList.hide(); }////////////////////////////////////////////////////////////////////// Confirmable interface implementors//////////////////////////////////////////////////////////////////// public void confirmIsYes(int id){ switch(id){ case QUIT_CONFIRM: exit();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -