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

📄 joonedit.java

📁 拥有图形界面的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    }        /**     * Create a Net menu.     * The View menu permits to control some features of the neural net,     * like showing the control panel, randomize the net, etc.     *     *  @return newly create net menu     */    protected JMenu createToolsMenu() {        tf = new TodoFrame(this);        JMenu menu = new JMenu("Tools");        menu.setMnemonic(KeyEvent.VK_O);                JMenuItem mi = new JMenuItem("Control Panel");        mi.setMnemonic(KeyEvent.VK_C);        mi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                NeuralNetDrawing nnd = (NeuralNetDrawing)drawing();                NeuralNet nn = nnd.getNeuralNet();                ps = getMonitorPropertySheet(nn);                ps.setParameters(parameters);                ps.update();                ps.setSize(330,350);                ps.setVisible(true);                ((JooneStandardDrawingView)view()).setModified(true);            }        });        menu.add(mi);        mi = new JMenuItem("To Do List");        mi.setMnemonic(KeyEvent.VK_T);        mi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                tf.show();            }        });        menu.add(mi);                menu.addSeparator();                mi = new JMenuItem("Add Noise");        mi.setMnemonic(KeyEvent.VK_A);        mi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                NeuralNetDrawing nnd = (NeuralNetDrawing)drawing();                NeuralNet nn = nnd.getNeuralNet();                nn.addNoise(0.2);                ((JooneStandardDrawingView)view()).setModified(true);            }        });        menu.add(mi);                mi = new JMenuItem("Randomize");        mi.setMnemonic(KeyEvent.VK_R);        mi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                NeuralNetDrawing nnd = (NeuralNetDrawing)drawing();                NeuralNet nn = nnd.getNeuralNet();                nn.randomize(0.3);                ((JooneStandardDrawingView)view()).setModified(true);            }        });        menu.add(mi);                menu.addSeparator();                mi = new JMenuItem("Reset Input Streams");        mi.setMnemonic(KeyEvent.VK_I);        mi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                NeuralNetDrawing nnd = (NeuralNetDrawing)drawing();                NeuralNet nn = nnd.getNeuralNet();                nn.resetInput();                ((JooneStandardDrawingView)view()).setModified(true);            }        });                menu.add(mi);        menu.addSeparator();                mi = new JMenuItem("Macro Editor");        mi.setMnemonic(KeyEvent.VK_M);        mi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                NeuralNetDrawing nnd = (NeuralNetDrawing)drawing();                NeuralNet nn = nnd.getNeuralNet();                if (macroEditor == null) {                    if (nn.getMacroPlugin() == null)                        nn.setMacroPlugin(new org.joone.util.MacroPlugin());                    macroEditor = new JMacroEditor(nn);                }                macroEditor.setVisible(true);                ((JooneStandardDrawingView)view()).setModified(true);            }        });                menu.add(mi);        return menu;    }        protected MonitorPropertySheet getMonitorPropertySheet(NeuralNet nn) {        if (ps == null) {            Wrapper wr = new Wrapper(null, nn.getMonitor(), "Control Panel");            ps = new MonitorPropertySheet(wr, nn);        }        return ps;    }        /**     * Creates the alignment menu. Clients override this     * method to add additional menu items.     */    protected JMenu createAlignmentMenu() {        JooneCommandMenu menu = new JooneCommandMenu("Align");        menu.setMnemonic(KeyEvent.VK_A);        menu.add(new ToggleGridCommand("Toggle Snap to Grid", view(), new Point(4,4)),  new MenuShortcut('t'));        //JCheckBoxMenuItem jcme = new JCheckBoxMenuItem("Toggle Snap to Grid");        menu.addSeparator();        menu.add(new AlignCommand("Left", view(), AlignCommand.LEFTS),  new MenuShortcut('l'));        menu.add(new AlignCommand("Center", view(), AlignCommand.CENTERS),  new MenuShortcut('c'));        menu.add(new AlignCommand("Right", view(), AlignCommand.RIGHTS),  new MenuShortcut('r'));        menu.addSeparator();        menu.add(new AlignCommand("Top", view(), AlignCommand.TOPS),  new MenuShortcut('o'));        menu.add(new AlignCommand("Middle", view(), AlignCommand.MIDDLES),  new MenuShortcut('m'));        menu.add(new AlignCommand("Bottom", view(), AlignCommand.BOTTOMS),  new MenuShortcut('b'));        return menu;    }        /**     * Creates the file menu. Clients override this     * method to add additional menu items.     */    protected JMenu createFileMenu() {        JMenu menu = new JMenu("File");        menu.setMnemonic(KeyEvent.VK_F);        JMenuItem mi = new JMenuItem("New", new MenuShortcut('n').getKey());        mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                int n = askForSave("Save changes to Neural Net?");                if ((n == JOptionPane.NO_OPTION) || !((JooneStandardDrawingView)view()).isModified()) {                    promptNew();                    return;                }            }                    });        menu.add(mi);                mi = new JMenuItem("Open...", new MenuShortcut('o').getKey());        mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));        mi.addActionListener(        new ActionListener() {            public void actionPerformed(final ActionEvent event) {                int n = askForSave("Save changes to Neural Net?");                if ((n == JOptionPane.NO_OPTION) || !((JooneStandardDrawingView)view()).isModified()) {                    promptOpen();                }            }        });        menu.add(mi);                mi = new JMenuItem("Save", new MenuShortcut('s').getKey());        mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                if (latestStorageFormat != null &&                getDrawingTitle() != null &&                !getDrawingTitle().equals("")) {                    saveDrawing(latestStorageFormat, getDrawingTitle());                } else {                    promptSaveAs();                }            }        }        );        menu.add(mi);                mi = new JMenuItem("Save As...", new MenuShortcut('a').getKey());        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                promptSaveAs();            }        }        );        menu.add(mi);                mi = new JMenuItem("Export NeuralNet...", new MenuShortcut('e').getKey());        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                promptSaveNeuralNet();            }        }        );        menu.add(mi);                mi = new JMenuItem("Export as XML...", new MenuShortcut('e').getKey());        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                promptSaveAsXML();            }        }        );        menu.add(mi);                menu.addSeparator();        mi = new JMenuItem("Print...", new MenuShortcut('p').getKey());        mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                print();            }        }        );        menu.add(mi);                mi = new JMenuItem("Page Setup...", new MenuShortcut('u').getKey());        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                pageSetup();            }        }        );        menu.add(mi);                menu.addSeparator();                mi = new JMenuItem("Exit", new MenuShortcut('x').getKey());        mi.addActionListener(        new ActionListener() {            public void actionPerformed(ActionEvent event) {                exit();            }        }        );        menu.add(mi);        return menu;    }        /** Creating a Help Menu */    protected JMenu createHelpMenu() {        CommandMenu menu = new CommandMenu("Help");        menu.setMnemonic(KeyEvent.VK_H);        af = new AboutFrame(this);                try {                        // Create menu items.            JMenuItem helpContents = new JMenuItem("Help Contents");            helpContents.setAccelerator(KeyStroke.getKeyStroke("F1"));            helpContents.setMnemonic(KeyEvent.VK_H);                        // Create broker for Joone help set.            HelpSet hs = new HelpSet(null, HelpSet.findHelpSet(null, "org/joone/edit/help_contents/joone.hs"));            HelpBroker hb = hs.createHelpBroker();            hb.setSize(new Dimension(800, 600));            hb.setFont(new Font("Helvetica", Font.PLAIN, 10));                        // Add listeners to menu item.            helpContents.addActionListener(new CSH.DisplayHelpFromSource(hb));                        // Enable F1 key.            hb.enableHelpKey(getRootPane(), "top", null);                        // Add items to the menu.            menu.add(helpContents);        } catch (Exception e) {            log.warn( "Exception thrown while creating the MenuHelp. Message is : " + e.getMessage(),            e);        }                JMenu samples = createSamplesMenu();        menu.add(samples);        menu.addSeparator();        JMenuItem mi = new JMenuItem("About Joone");        mi.setMnemonic(KeyEvent.VK_A);        mi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                                // Center the About window on the center of this screen.                Rectangle r = getBounds();                af.place(r.x + r.width/2, r.y + r.height/2);                af.setVisible(true);            }        });        menu.add(mi);                return menu;    }        private JMenu createSamplesMenu() {        JMenu smp = new JMenu("Examples");        JMenuItem smpi = new JMenuItem("SOM Image Tester");        smpi.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent event) {                new SOMImageTester().setVisible(true);            }        });        smp.add(smpi);        return smp;    }        /**     * Shows a file dialog and exports the NeuralNet.     */    public void promptSaveNeuralNet() {        toolDone();

⌨️ 快捷键说明

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