Search in sources :

Example 11 with MenuListener

use of javax.swing.event.MenuListener in project energy3d by concord-consortium.

the class MainFrame method getFileMenu.

private JMenu getFileMenu() {
    if (fileMenu == null) {
        fileMenu = new JMenu();
        fileMenu.addMenuListener(new MenuListener() {

            private void enableMenuItems(final boolean b) {
                replayFolderMenuItem.setEnabled(b);
                replayLastFolderMenuItem.setEnabled(b);
                replayControlsMenu.setEnabled(b);
                analyzeFolderMenuItem.setEnabled(b);
                saveMenuItem.setEnabled(b);
            }

            @Override
            public void menuCanceled(final MenuEvent e) {
                // if any of these actions is registered with a keystroke, we must re-enable it
                enableMenuItems(true);
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                SceneManager.getInstance().refresh();
                enableMenuItems(true);
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                MainPanel.getInstance().defaultTool();
                enableMenuItems(true);
                // cannot overwrite a template
                saveMenuItem.setEnabled(!Scene.isInternalFile());
                // prevent multiple replay or postprocessing commands
                final boolean inactive = !PlayControl.active;
                replayFolderMenuItem.setEnabled(inactive);
                final File lastFolder = DesignReplay.getInstance().getLastFolder();
                replayLastFolderMenuItem.setEnabled(lastFolder != null && inactive);
                replayLastFolderMenuItem.setText(lastFolder != null ? "Replay Last Folder: " + lastFolder : "Replay Last Folder");
                replayControlsMenu.setEnabled(!inactive);
                analyzeFolderMenuItem.setEnabled(inactive);
                // recent files
                if (!recentFileMenuItems.isEmpty()) {
                    for (final JComponent x : recentFileMenuItems) {
                        fileMenu.remove(x);
                    }
                }
                final String[] recentFiles = FileChooser.getInstance().getRecentFiles();
                if (recentFiles != null) {
                    final int n = recentFiles.length;
                    if (n > 0) {
                        for (int i = 0; i < n; i++) {
                            final JMenuItem x = new JMenuItem((i + 1) + "  " + Util.getFileName(recentFiles[i]));
                            x.setToolTipText(recentFiles[i]);
                            final File rf = new File(recentFiles[i]);
                            x.addActionListener(new ActionListener() {

                                @Override
                                public void actionPerformed(final ActionEvent e) {
                                    boolean ok = false;
                                    if (Scene.getInstance().isEdited()) {
                                        final int save = JOptionPane.showConfirmDialog(MainFrame.this, "Do you want to save changes?", "Save", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                                        if (save == JOptionPane.YES_OPTION) {
                                            save();
                                            if (!Scene.getInstance().isEdited()) {
                                                ok = true;
                                            }
                                        } else if (save != JOptionPane.CANCEL_OPTION) {
                                            ok = true;
                                        }
                                    } else {
                                        ok = true;
                                    }
                                    if (ok) {
                                        SceneManager.getTaskManager().update(new Callable<Object>() {

                                            @Override
                                            public Object call() {
                                                try {
                                                    Scene.open(rf.toURI().toURL());
                                                    updateTitleBar();
                                                    FileChooser.getInstance().rememberFile(rf.getPath());
                                                } catch (final Throwable err) {
                                                    BugReporter.report(err, rf.getAbsolutePath());
                                                }
                                                return null;
                                            }
                                        });
                                    }
                                }
                            });
                            fileMenu.insert(x, fileMenuItemCount + i);
                            recentFileMenuItems.add(x);
                        }
                        final JSeparator s = new JSeparator();
                        fileMenu.add(s, fileMenuItemCount + n);
                        recentFileMenuItems.add(s);
                    }
                }
            }
        });
        fileMenu.setText("File");
        addItemToFileMenu(getNewMenuItem());
        addItemToFileMenu(getOpenMenuItem());
        addItemToFileMenu(getSaveMenuItem());
        addItemToFileMenu(getSaveasMenuItem());
        addItemToFileMenu(getSubmitToVsgMenuItem());
        addItemToFileMenu(new JSeparator());
        addItemToFileMenu(getImportMenuItem());
        addItemToFileMenu(getImportColladaMenuItem());
        addItemToFileMenu(getCopyImageMenuItem());
        addItemToFileMenu(getExportModelMenuItem());
        addItemToFileMenu(getExportImageMenuItem());
        addItemToFileMenu(getExportLogMenuItem());
        addItemToFileMenu(new JSeparator());
        addItemToFileMenu(getReplayFolderMenuItem());
        addItemToFileMenu(getReplayLastFolderMenuItem());
        replayControlsMenu = new JMenu("Replay Controls");
        replayControlsMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuCanceled(final MenuEvent e) {
                // if any of these actions is registered with a keystroke, we must re-enable it
                endReplayMenuItem.setEnabled(true);
                pauseReplayMenuItem.setEnabled(true);
                forwardReplayMenuItem.setEnabled(true);
                backwardReplayMenuItem.setEnabled(true);
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                endReplayMenuItem.setEnabled(true);
                pauseReplayMenuItem.setEnabled(true);
                forwardReplayMenuItem.setEnabled(true);
                backwardReplayMenuItem.setEnabled(true);
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                endReplayMenuItem.setEnabled(PlayControl.active);
                pauseReplayMenuItem.setEnabled(PlayControl.active);
                pauseReplayMenuItem.setText((PlayControl.replaying ? "Pause Replay" : "Resume Replay") + " (Space Bar)");
                forwardReplayMenuItem.setEnabled(!PlayControl.replaying);
                backwardReplayMenuItem.setEnabled(!PlayControl.replaying);
            }
        });
        addItemToFileMenu(replayControlsMenu);
        replayControlsMenu.add(getPauseReplayMenuItem());
        replayControlsMenu.add(getBackwardReplayMenuItem());
        replayControlsMenu.add(getForwardReplayMenuItem());
        replayControlsMenu.add(getEndReplayMenuItem());
        addItemToFileMenu(getAnalyzeFolderMenuItem());
        addItemToFileMenu(new JSeparator());
        addItemToFileMenu(getScaleToFitRadioButtonMenuItem());
        addItemToFileMenu(getExactSizeRadioButtonMenuItem());
        addItemToFileMenu(getPageSetupMenuItem());
        addItemToFileMenu(getPreviewMenuItem());
        addItemToFileMenu(getPrintMenuItem());
        addItemToFileMenu(new JSeparator());
        fileMenu.add(getExitMenuItem());
    }
    return fileMenu;
}
Also used : MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) JComponent(javax.swing.JComponent) Point(java.awt.Point) JSeparator(javax.swing.JSeparator) ActionListener(java.awt.event.ActionListener) JMenuItem(javax.swing.JMenuItem) File(java.io.File) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 12 with MenuListener

use of javax.swing.event.MenuListener in project energy3d by concord-consortium.

the class MainFrame method getTextureMenu.

private JMenu getTextureMenu() {
    if (textureMenu == null) {
        textureMenu = new JMenu("Texture");
        final JMenuItem removeBuildingTextureMenuItem = new JMenuItem("Remove Building Texture");
        removeBuildingTextureMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final ChangeBuildingTextureCommand c = new ChangeBuildingTextureCommand();
                Scene.getInstance().setTextureMode(TextureMode.None);
                Scene.getInstance().setEdited(true);
                if (MainPanel.getInstance().getEnergyButton().isSelected()) {
                    MainPanel.getInstance().getEnergyButton().setSelected(false);
                }
                SceneManager.getInstance().getUndoManager().addEdit(c);
            }
        });
        textureMenu.add(removeBuildingTextureMenuItem);
        final JMenuItem outlineBuildingTextureMenuItem = new JMenuItem("Use Outline Building Texture");
        outlineBuildingTextureMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final ChangeBuildingTextureCommand c = new ChangeBuildingTextureCommand();
                Scene.getInstance().setTextureMode(TextureMode.Simple);
                Scene.getInstance().setEdited(true);
                if (MainPanel.getInstance().getEnergyButton().isSelected()) {
                    MainPanel.getInstance().getEnergyButton().setSelected(false);
                }
                SceneManager.getInstance().getUndoManager().addEdit(c);
            }
        });
        textureMenu.add(outlineBuildingTextureMenuItem);
        textureMenu.addSeparator();
        final JMenu wallTextureMenu = new JMenu("Walls");
        textureMenu.add(wallTextureMenu);
        final JRadioButtonMenuItem wallTexture01MenuItem = createWallTextureMenuItem(Wall.TEXTURE_01, "icons/wall_01.png");
        final JRadioButtonMenuItem wallTexture02MenuItem = createWallTextureMenuItem(Wall.TEXTURE_02, "icons/wall_02.png");
        final JRadioButtonMenuItem wallTexture03MenuItem = createWallTextureMenuItem(Wall.TEXTURE_03, "icons/wall_03.png");
        final JRadioButtonMenuItem wallTexture04MenuItem = createWallTextureMenuItem(Wall.TEXTURE_04, "icons/wall_04.png");
        final JRadioButtonMenuItem wallTexture05MenuItem = createWallTextureMenuItem(Wall.TEXTURE_05, "icons/wall_05.png");
        final JRadioButtonMenuItem wallTexture06MenuItem = createWallTextureMenuItem(Wall.TEXTURE_06, "icons/wall_06.png");
        final ButtonGroup wallTextureButtonGroup = new ButtonGroup();
        wallTextureButtonGroup.add(wallTexture01MenuItem);
        wallTextureButtonGroup.add(wallTexture02MenuItem);
        wallTextureButtonGroup.add(wallTexture03MenuItem);
        wallTextureButtonGroup.add(wallTexture04MenuItem);
        wallTextureButtonGroup.add(wallTexture05MenuItem);
        wallTextureButtonGroup.add(wallTexture06MenuItem);
        wallTextureMenu.add(wallTexture01MenuItem);
        wallTextureMenu.add(wallTexture02MenuItem);
        wallTextureMenu.add(wallTexture03MenuItem);
        wallTextureMenu.add(wallTexture04MenuItem);
        wallTextureMenu.add(wallTexture05MenuItem);
        wallTextureMenu.add(wallTexture06MenuItem);
        wallTextureMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuCanceled(final MenuEvent e) {
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                SceneManager.getInstance().refresh();
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                if (Scene.getInstance().getTextureMode() == TextureMode.Full) {
                    switch(Scene.getInstance().getWallTextureType()) {
                        case Wall.TEXTURE_01:
                            Util.selectSilently(wallTexture01MenuItem, true);
                            break;
                        case Wall.TEXTURE_02:
                            Util.selectSilently(wallTexture02MenuItem, true);
                            break;
                        case Wall.TEXTURE_03:
                            Util.selectSilently(wallTexture03MenuItem, true);
                            break;
                        case Wall.TEXTURE_04:
                            Util.selectSilently(wallTexture04MenuItem, true);
                            break;
                        case Wall.TEXTURE_05:
                            Util.selectSilently(wallTexture05MenuItem, true);
                            break;
                        case Wall.TEXTURE_06:
                            Util.selectSilently(wallTexture06MenuItem, true);
                            break;
                    }
                }
            }
        });
        final JMenu roofTextureMenu = new JMenu("Roofs");
        textureMenu.add(roofTextureMenu);
        final JRadioButtonMenuItem roofTexture01MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_01, "icons/roof_01.png");
        final JRadioButtonMenuItem roofTexture02MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_02, "icons/roof_02.png");
        final JRadioButtonMenuItem roofTexture03MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_03, "icons/roof_03.png");
        final JRadioButtonMenuItem roofTexture04MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_04, "icons/roof_04.png");
        final JRadioButtonMenuItem roofTexture05MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_05, "icons/roof_05.png");
        final JRadioButtonMenuItem roofTexture06MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_06, "icons/roof_06.png");
        final ButtonGroup roofTextureButtonGroup = new ButtonGroup();
        roofTextureButtonGroup.add(roofTexture01MenuItem);
        roofTextureButtonGroup.add(roofTexture02MenuItem);
        roofTextureButtonGroup.add(roofTexture03MenuItem);
        roofTextureButtonGroup.add(roofTexture04MenuItem);
        roofTextureButtonGroup.add(roofTexture05MenuItem);
        roofTextureButtonGroup.add(roofTexture06MenuItem);
        roofTextureMenu.add(roofTexture01MenuItem);
        roofTextureMenu.add(roofTexture02MenuItem);
        roofTextureMenu.add(roofTexture03MenuItem);
        roofTextureMenu.add(roofTexture04MenuItem);
        roofTextureMenu.add(roofTexture05MenuItem);
        roofTextureMenu.add(roofTexture06MenuItem);
        roofTextureMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuCanceled(final MenuEvent e) {
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                SceneManager.getInstance().refresh();
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                if (Scene.getInstance().getTextureMode() == TextureMode.Full) {
                    switch(Scene.getInstance().getRoofTextureType()) {
                        case Roof.TEXTURE_01:
                            Util.selectSilently(roofTexture01MenuItem, true);
                            break;
                        case Roof.TEXTURE_02:
                            Util.selectSilently(roofTexture02MenuItem, true);
                            break;
                        case Roof.TEXTURE_03:
                            Util.selectSilently(roofTexture03MenuItem, true);
                            break;
                        case Roof.TEXTURE_04:
                            Util.selectSilently(roofTexture04MenuItem, true);
                            break;
                        case Roof.TEXTURE_05:
                            Util.selectSilently(roofTexture05MenuItem, true);
                            break;
                        case Roof.TEXTURE_06:
                            Util.selectSilently(roofTexture06MenuItem, true);
                            break;
                    }
                }
            }
        });
        textureMenu.addSeparator();
        final JMenu heliostatTextureMenu = new JMenu("Heliostats");
        textureMenu.add(heliostatTextureMenu);
        final ButtonGroup heliostatTextureButtonGroup = new ButtonGroup();
        final JRadioButtonMenuItem heliostat1MirrorTextureMenuItem = new JRadioButtonMenuItem("Whole Mirror");
        heliostat1MirrorTextureMenuItem.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
                    Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_ONE_MIRROR);
                    Scene.getInstance().setEdited(true);
                    if (MainPanel.getInstance().getEnergyButton().isSelected()) {
                        MainPanel.getInstance().getEnergyButton().setSelected(false);
                    }
                    Scene.getInstance().redrawAll();
                    SceneManager.getInstance().getUndoManager().addEdit(c);
                }
            }
        });
        heliostatTextureButtonGroup.add(heliostat1MirrorTextureMenuItem);
        final JRadioButtonMenuItem heliostat2X1MirrorsTextureMenuItem = new JRadioButtonMenuItem("2 \u00D7 1 Mirrors");
        heliostat2X1MirrorsTextureMenuItem.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
                    Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_2X1_MIRRORS);
                    Scene.getInstance().setEdited(true);
                    if (MainPanel.getInstance().getEnergyButton().isSelected()) {
                        MainPanel.getInstance().getEnergyButton().setSelected(false);
                    }
                    Scene.getInstance().redrawAll();
                    SceneManager.getInstance().getUndoManager().addEdit(c);
                }
            }
        });
        heliostatTextureButtonGroup.add(heliostat2X1MirrorsTextureMenuItem);
        final JRadioButtonMenuItem heliostat1X2MirrorsTextureMenuItem = new JRadioButtonMenuItem("1 \u00D7 2 Mirrors");
        heliostat1X2MirrorsTextureMenuItem.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
                    Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_1X2_MIRRORS);
                    Scene.getInstance().setEdited(true);
                    if (MainPanel.getInstance().getEnergyButton().isSelected()) {
                        MainPanel.getInstance().getEnergyButton().setSelected(false);
                    }
                    Scene.getInstance().redrawAll();
                    SceneManager.getInstance().getUndoManager().addEdit(c);
                }
            }
        });
        heliostatTextureButtonGroup.add(heliostat1X2MirrorsTextureMenuItem);
        final JRadioButtonMenuItem heliostat7X5MirrorsTextureMenuItem = new JRadioButtonMenuItem("7 \u00D7 5 Mirrors");
        heliostat7X5MirrorsTextureMenuItem.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
                    Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_7X5_MIRRORS);
                    Scene.getInstance().setEdited(true);
                    if (MainPanel.getInstance().getEnergyButton().isSelected()) {
                        MainPanel.getInstance().getEnergyButton().setSelected(false);
                    }
                    Scene.getInstance().redrawAll();
                    SceneManager.getInstance().getUndoManager().addEdit(c);
                }
            }
        });
        heliostatTextureButtonGroup.add(heliostat7X5MirrorsTextureMenuItem);
        heliostatTextureMenu.add(heliostat1MirrorTextureMenuItem);
        heliostatTextureMenu.add(heliostat2X1MirrorsTextureMenuItem);
        heliostatTextureMenu.add(heliostat1X2MirrorsTextureMenuItem);
        heliostatTextureMenu.add(heliostat7X5MirrorsTextureMenuItem);
        heliostatTextureMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuCanceled(final MenuEvent e) {
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                SceneManager.getInstance().refresh();
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                switch(Scene.getInstance().getHeliostatTextureType()) {
                    default:
                        Util.selectSilently(heliostat1MirrorTextureMenuItem, true);
                        break;
                    case Mirror.TEXTURE_2X1_MIRRORS:
                        Util.selectSilently(heliostat2X1MirrorsTextureMenuItem, true);
                        break;
                    case Mirror.TEXTURE_1X2_MIRRORS:
                        Util.selectSilently(heliostat1X2MirrorsTextureMenuItem, true);
                        break;
                    case Mirror.TEXTURE_7X5_MIRRORS:
                        Util.selectSilently(heliostat7X5MirrorsTextureMenuItem, true);
                        break;
                }
            }
        });
    }
    return textureMenu;
}
Also used : ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) MenuListener(javax.swing.event.MenuListener) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) ChangeHeliostatTextureCommand(org.concord.energy3d.undo.ChangeHeliostatTextureCommand) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ChangeBuildingTextureCommand(org.concord.energy3d.undo.ChangeBuildingTextureCommand) ItemListener(java.awt.event.ItemListener) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 13 with MenuListener

use of javax.swing.event.MenuListener in project energy3d by concord-consortium.

the class MainFrame method getTemplatesMenu.

private JMenu getTemplatesMenu() {
    if (examplesMenu == null) {
        examplesMenu = new JMenu("Examples");
        examplesMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuCanceled(final MenuEvent e) {
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                SceneManager.getInstance().refresh();
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                MainPanel.getInstance().defaultTool();
            }
        });
        final JMenu benchmarksMenu = new JMenu("Benchmarks");
        examplesMenu.add(benchmarksMenu);
        final JMenu bestestMenu = new JMenu("Building Energy Simulation Tests");
        benchmarksMenu.add(bestestMenu);
        addModel(bestestMenu, "BESTEST Case 600", "benchmarks/bestest600.ng3");
        addModel(bestestMenu, "BESTEST Case 610", "benchmarks/bestest610.ng3");
        addModel(bestestMenu, "BESTEST Case 620", "benchmarks/bestest620.ng3");
        addModel(bestestMenu, "BESTEST Case 630", "benchmarks/bestest630.ng3");
        final JMenu simpleMenu = new JMenu("Simple Buildings");
        examplesMenu.add(simpleMenu);
        addModel(simpleMenu, "Apartment 1", "templates/apartment-template-1.ng3");
        addModel(simpleMenu, "Apartment 2", "templates/apartment-template-2.ng3");
        addModel(simpleMenu, "Box Gabled Roof", "templates/box-gabled-template.ng3");
        addModel(simpleMenu, "Bungalow", "templates/bungalow-template.ng3");
        addModel(simpleMenu, "Butterfly Roof", "templates/butterfly-template.ng3");
        addModel(simpleMenu, "Cape Cod", "templates/cape-cod-template.ng3");
        addModel(simpleMenu, "Colonial", "templates/colonial-template.ng3");
        addModel(simpleMenu, "Combination Roof", "templates/combination-roof-template.ng3");
        addModel(simpleMenu, "Cross Gabled Roof", "templates/cross-gabled-template.ng3");
        addModel(simpleMenu, "Cross Hipped Roof", "templates/cross-hipped-template.ng3");
        addModel(simpleMenu, "Dutch Colonial", "templates/gambrel-template.ng3");
        addModel(simpleMenu, "Flat Roof", "templates/flat-roof-template.ng3");
        addModel(simpleMenu, "Gable & Valley Roof", "templates/gable-valley-template.ng3");
        addModel(simpleMenu, "Gablet Roof", "templates/gablet-template.ng3");
        addModel(simpleMenu, "Hip Roof", "templates/hip-roof-template.ng3");
        addModel(simpleMenu, "Hip & Valley Roof", "templates/hip-valley-template.ng3");
        addModel(simpleMenu, "M-Shaped Roof", "templates/m-shaped-template.ng3");
        addModel(simpleMenu, "Mansard", "templates/mansard-template.ng3");
        addModel(simpleMenu, "Saltbox 1", "templates/saltbox-template-1.ng3");
        addModel(simpleMenu, "Saltbox 2", "templates/saltbox-template-2.ng3");
        addModel(simpleMenu, "Shed Roof", "templates/shed-roof-template.ng3");
        final JMenu complexMenu = new JMenu("Complex Buildings");
        examplesMenu.add(complexMenu);
        addModel(complexMenu, "Cape Cod with Front Porch", "templates/example-cape-cod-front-porch.ng3");
        addModel(complexMenu, "Cape Cod with Garage", "templates/example-cape-cod-attached-garage.ng3");
        addModel(complexMenu, "Cape Cod with Shed and Gable Dormers", "templates/example-cape-cod-shed-gable-dormers.ng3");
        addModel(complexMenu, "Colonial with Fence", "templates/example-colonial-fence.ng3");
        addModel(complexMenu, "Colonial with Front Porch", "templates/example-colonial-front-porch.ng3");
        addModel(complexMenu, "L-Shaped Colonial", "templates/example-colonial-l-shaped.ng3");
        addModel(complexMenu, "Dutch Colonial with Front Porch", "templates/example-dutch-colonial.ng3");
        addModel(complexMenu, "Federal", "templates/example-federal.ng3");
        addModel(complexMenu, "Victorian", "templates/example-victorian.ng3");
        addModel(complexMenu, "Shingle", "templates/example-shingle.ng3");
        addModel(complexMenu, "Sunroom", "templates/example-sunroom.ng3");
        addModel(complexMenu, "Barn House", "templates/example-barn-house.ng3");
        addModel(complexMenu, "Santa Fe Style House", "templates/example-santa-fe.ng3");
        final JMenu pvSolarMenu = new JMenu("Photovoltaic Systems");
        addModel(pvSolarMenu, "Solar Canopy: Wavy Top", "templates/example-solar-canopy-wavy-top.ng3");
        addModel(pvSolarMenu, "Solar Canopy: Curvy Top", "templates/example-solar-canopy-curvy-top.ng3");
        addModel(pvSolarMenu, "Solar Canopy: Bus Stop", "templates/example-solar-canopy-bus-stop.ng3");
        addModel(pvSolarMenu, "Solar Canopy: Parking Garage 1", "templates/example-solar-canopy-parking-garage-1.ng3");
        addModel(pvSolarMenu, "Solar Canopy: Parking Garage 2", "templates/example-solar-canopy-parking-garage-2.ng3");
        addModel(pvSolarMenu, "Solar Canopy: Overhang", "templates/example-solar-canopy-overhang.ng3");
        addModel(pvSolarMenu, "Solar Facades: Example 1", "templates/example-solar-facade1.ng3");
        addModel(pvSolarMenu, "Solar Facades: Example 2", "templates/example-solar-facade2.ng3");
        examplesMenu.add(pvSolarMenu);
        final JMenu cspSolarMenu = new JMenu("Concentrated Solar Power Systems");
        cspSolarMenu.setEnabled(false);
        examplesMenu.add(cspSolarMenu);
        final JMenu miscMenu = new JMenu("Miscellaneous");
        examplesMenu.add(miscMenu);
        addModel(miscMenu, "Temple", "templates/temple-template.ng3");
        addModel(miscMenu, "Tibetan Temple", "templates/tibetan-temple-template.ng3");
        addModel(miscMenu, "Church 1", "templates/church-template-1.ng3");
        addModel(miscMenu, "Church 2", "templates/church-template-2.ng3");
        addModel(miscMenu, "Church 3", "templates/cathedral-template.ng3");
        addModel(miscMenu, "Mexican Church", "templates/mexican-church-template.ng3");
        addModel(miscMenu, "Chinese Tower", "templates/chinese-tower-template.ng3");
        addModel(miscMenu, "Dome", "templates/dome-template.ng3");
        addModel(miscMenu, "Egyptian Pyramid", "templates/egyptian-pyramid-template.ng3");
        addModel(miscMenu, "Mayan Pyramid", "templates/mayan-pyramid-template.ng3");
        addModel(miscMenu, "Stadium", "templates/stadium-template.ng3");
    }
    return examplesMenu;
}
Also used : MenuListener(javax.swing.event.MenuListener) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 14 with MenuListener

use of javax.swing.event.MenuListener in project energy3d by concord-consortium.

the class MainFrame method getAnalysisMenu.

private JMenu getAnalysisMenu() {
    if (analysisMenu == null) {
        analysisMenu = new JMenu("Analysis");
        analysisMenu.addMenuListener(new MenuListener() {

            private void enableEnergyAnalysis(final boolean b) {
                annualEnergyAnalysisMenuItem.setEnabled(b);
                annualEnergyAnalysisForSelectionMenuItem.setEnabled(b);
                dailyEnergyAnalysisMenuItem.setEnabled(b);
                dailyEnergyAnalysisForSelectionMenuItem.setEnabled(b);
            // orientationalEnergyAnalysisMenuItem.setEnabled(b);
            }

            @Override
            public void menuCanceled(final MenuEvent e) {
                simulationSettingsMenuItem.setEnabled(true);
                visualizationSettingsMenuItem.setEnabled(true);
                enableEnergyAnalysis(true);
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                SceneManager.getInstance().refresh();
                simulationSettingsMenuItem.setEnabled(true);
                visualizationSettingsMenuItem.setEnabled(true);
                enableEnergyAnalysis(true);
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                MainPanel.getInstance().defaultTool();
                final boolean b = !Scene.getInstance().isStudentMode();
                simulationSettingsMenuItem.setEnabled(b);
                visualizationSettingsMenuItem.setEnabled(b);
                enableEnergyAnalysis(!Scene.getInstance().getOnlySolarAnalysis());
            }
        });
        analysisMenu.add(getSimulationSettingsMenuItem());
        analysisMenu.addSeparator();
        final JMenu buildingsMenu = new JMenu("Buildings");
        analysisMenu.add(buildingsMenu);
        buildingsMenu.add(getDailyEnergyAnalysisMenuItem());
        buildingsMenu.add(getAnnualEnergyAnalysisMenuItem());
        buildingsMenu.addSeparator();
        buildingsMenu.add(getDailyEnergyAnalysisForSelectionMenuItem());
        buildingsMenu.add(getAnnualEnergyAnalysisForSelectionMenuItem());
        final JMenu solarPanelsMenu = new JMenu("Solar Panels");
        analysisMenu.add(solarPanelsMenu);
        solarPanelsMenu.add(getDailyPvAnalysisMenuItem());
        solarPanelsMenu.add(getAnnualPvAnalysisMenuItem());
        final JMenu heliostatsMenu = new JMenu("Heliostats");
        analysisMenu.add(heliostatsMenu);
        heliostatsMenu.add(getDailyHeliostatAnalysisMenuItem());
        heliostatsMenu.add(getAnnualHeliostatAnalysisMenuItem());
        final JMenu parabolicTroughsMenu = new JMenu("Parabolic Troughs");
        analysisMenu.add(parabolicTroughsMenu);
        parabolicTroughsMenu.add(getDailyParabolicTroughAnalysisMenuItem());
        parabolicTroughsMenu.add(getAnnualParabolicTroughAnalysisMenuItem());
        final JMenu parabolicDishesMenu = new JMenu("Parabolic Dishes");
        analysisMenu.add(parabolicDishesMenu);
        parabolicDishesMenu.add(getDailyParabolicDishAnalysisMenuItem());
        parabolicDishesMenu.add(getAnnualParabolicDishAnalysisMenuItem());
        final JMenu fresnelReflectorsMenu = new JMenu("Linear Fresnel Reflectors");
        analysisMenu.add(fresnelReflectorsMenu);
        fresnelReflectorsMenu.add(getDailyFresnelReflectorAnalysisMenuItem());
        fresnelReflectorsMenu.add(getAnnualFresnelReflectorAnalysisMenuItem());
        analysisMenu.addSeparator();
        final JMenu sensorsMenu = new JMenu("Sensors");
        analysisMenu.add(sensorsMenu);
        sensorsMenu.add(getDailySensorMenuItem());
        sensorsMenu.add(getAnnualSensorMenuItem());
        final JMenu groupMenu = new JMenu("Group");
        analysisMenu.add(groupMenu);
        groupMenu.add(getGroupDailyAnalysisMenuItem());
        groupMenu.add(getGroupAnnualAnalysisMenuItem());
        analysisMenu.addSeparator();
        analysisMenu.add(getCostAnalysisMenuItem());
    // analysisMenu.add(getOrientationalEnergyAnalysisMenuItem());
    }
    return analysisMenu;
}
Also used : MenuListener(javax.swing.event.MenuListener) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 15 with MenuListener

use of javax.swing.event.MenuListener in project energy3d by concord-consortium.

the class MainFrame method getTutorialsMenu.

private JMenu getTutorialsMenu() {
    if (tutorialsMenu == null) {
        tutorialsMenu = new JMenu("Tutorials");
        tutorialsMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuCanceled(final MenuEvent e) {
            }

            @Override
            public void menuDeselected(final MenuEvent e) {
                SceneManager.getInstance().refresh();
            }

            @Override
            public void menuSelected(final MenuEvent e) {
                MainPanel.getInstance().defaultTool();
            }
        });
        final JMenu uiBasicsMenu = new JMenu("User Interface Basics");
        uiBasicsMenu.setEnabled(false);
        tutorialsMenu.add(uiBasicsMenu);
        final JMenu buildingBasicsMenu = new JMenu("Building Science Basics");
        tutorialsMenu.add(buildingBasicsMenu);
        addModel(buildingBasicsMenu, "The Effect of the U-Value (AI \u2713)", "tutorials/ia-learn-u-value.ng3");
        buildingBasicsMenu.addSeparator();
        addModel(buildingBasicsMenu, "Two Houses of Different Sizes", "tutorials/building-size.ng3");
        addModel(buildingBasicsMenu, "Two Houses of Different Shapes", "tutorials/building-shape.ng3");
        addModel(buildingBasicsMenu, "Two Houses with Different Roof Insulations", "tutorials/building-roof-insulation.ng3");
        addModel(buildingBasicsMenu, "Two Houses with Different Roof Colors", "tutorials/building-cool-roof.ng3");
        addModel(buildingBasicsMenu, "Two Houses with Different Window SHGCs", "tutorials/building-window-shgc.ng3");
        addModel(buildingBasicsMenu, "Two Houses with Different Orientations", "tutorials/building-orientation.ng3");
        addModel(buildingBasicsMenu, "Two Houses with Different Thermostat Settings", "tutorials/building-thermostat.ng3");
        buildingBasicsMenu.addSeparator();
        addModel(buildingBasicsMenu, "Energy Use at Different Locations", "tutorials/building-location.ng3");
        addModel(buildingBasicsMenu, "Effect of Environment Albedo", "tutorials/building-albedo.ng3");
        addModel(buildingBasicsMenu, "Passive Heating with Windows", "tutorials/building-passive-heating.ng3");
        addModel(buildingBasicsMenu, "Passive Cooling with Trees", "tutorials/building-tree-passive-cooling.ng3");
        final JMenu solarBasicsMenu = new JMenu("Solar Science Basics");
        tutorialsMenu.add(solarBasicsMenu);
        addModel(solarBasicsMenu, "Solar Angles", "tutorials/solar-angles.ng3");
        addModel(solarBasicsMenu, "Solar Box", "tutorials/solar-box.ng3");
        addModel(solarBasicsMenu, "Solar Irradiance Heat Map", "tutorials/solar-heat-map.ng3");
        addModel(solarBasicsMenu, "Solar Analysis of Cities", "tutorials/city-block.ng3");
        solarBasicsMenu.addSeparator();
        addModel(solarBasicsMenu, "Solar Panel Tilt Angles", "tutorials/solar-panel-tilt-angle.ng3");
        addModel(solarBasicsMenu, "Solar Panel Azimuthal Angles", "tutorials/solar-panel-azimuth-angle.ng3");
        addModel(solarBasicsMenu, "Solar Panel Orientation", "tutorials/solar-panel-orientation.ng3");
        addModel(solarBasicsMenu, "Solar Panel Cell Efficiency", "tutorials/solar-panel-cell-efficiency.ng3");
        addModel(solarBasicsMenu, "Nominal Operating Cell Temperature", "tutorials/solar-panel-noct.ng3");
        addModel(solarBasicsMenu, "Solar Trackers", "tutorials/solar-trackers.ng3");
        tutorialsMenu.addSeparator();
        final JMenu inquiryMethodMenu = new JMenu("Methods of Scientific Inquiry");
        tutorialsMenu.add(inquiryMethodMenu);
        addModel(inquiryMethodMenu, "Passive Solar Investigation", "tutorials/guided-inquiry-passive-solar.ng3");
        final JMenu designMethodMenu = new JMenu("Methods of Engineering Design");
        tutorialsMenu.add(designMethodMenu);
        addModel(designMethodMenu, "Single-Variable, Single-Objective Optimization", "tutorials/guided-design-single-variable-single-objective.ng3");
        tutorialsMenu.addSeparator();
        final JMenu pvMenu = new JMenu("Photovoltaic Solar Power");
        tutorialsMenu.add(pvMenu);
        addModel(pvMenu, "Brand Name Solar Panels", "tutorials/solar-panel-brand-names.ng3");
        addModel(pvMenu, "Single Solar Rack", "tutorials/solar-single-rack.ng3");
        addModel(pvMenu, "Multiple Solar Racks", "tutorials/solar-multiple-racks.ng3");
        addModel(pvMenu, "Solar Trackers for Racks", "tutorials/solar-tracker-racks.ng3");
        addModel(pvMenu, "Solar Canopy Form Factors", "tutorials/solar-canopy-form-factors.ng3");
        pvMenu.addSeparator();
        addModel(pvMenu, "Rooftop Solar Power System", "tutorials/pv-rooftop-system.ng3");
        addModel(pvMenu, "Parking Lot Solar Canopy", "tutorials/solar-canopy.ng3");
        addModel(pvMenu, "Photovoltaic Solar Farm: Arrays with Fixed Tilt Angles", "tutorials/pv-fixed-rack-arrays.ng3");
        addModel(pvMenu, "Photovoltaic Solar Farm: Arrays with Seasonally Adjusted Tilt Angles", "tutorials/solar-rack-array-seasonal-tilt.ng3");
        addModel(pvMenu, "Photovoltaic Solar Farm: Horizontal Single-Axis Tracker Arrays", "tutorials/pv-hsat-rack-arrays.ng3");
        addModel(pvMenu, "Photovoltaic Solar Farm: Cost-Effectiveness", "tutorials/solar-rack-why-array.ng3");
        addModel(pvMenu, "Photovoltaic Solar Farm: The Effect of Inter-Row Spacing", "tutorials/solar-rack-array-row-spacing.ng3");
        addModel(pvMenu, "Photovoltaic Solar Farm: Landscape vs. Portrait Arrays", "tutorials/solar-rack-array-row-spacing-portrait.ng3");
        addModel(pvMenu, "Photovoltaic Solar Farm: Layout for Dual-Axis Trackers", "tutorials/azdat-layout.ng3");
        final JMenu cspMenu = new JMenu("Concentrated Solar Power");
        tutorialsMenu.add(cspMenu);
        addModel(cspMenu, "Parabolic Trough Focal Line", "tutorials/parabolic-trough-focal-line.ng3");
        addModel(cspMenu, "Parabolic Trough Rim Angle", "tutorials/parabolic-trough-curvature.ng3");
        addModel(cspMenu, "Parabolic Trough Arrays", "tutorials/parabolic-trough-array.ng3");
        addModel(cspMenu, "Parabolic Trough Rhomboid Layout", "tutorials/parabolic-trough-rhomboid-layout.ng3");
        addModel(cspMenu, "Parabolic Troughs with Different Azimuth Angles", "tutorials/parabolic-trough-azimuth-angles.ng3");
        cspMenu.addSeparator();
        addModel(cspMenu, "Parabolic Dish Stirling Engine", "tutorials/parabolic-dish-single.ng3");
        addModel(cspMenu, "Parabolic Dish Focal Length", "tutorials/parabolic-dish-focal-length.ng3");
        addModel(cspMenu, "Parabolic Dish Array", "tutorials/parabolic-dish-array.ng3");
        cspMenu.addSeparator();
        addModel(cspMenu, "Linear Fresnel Reflectors", "tutorials/linear-fresnel-reflectors.ng3");
        addModel(cspMenu, "Linear Fresnel Reflectors: The Effect of Absorber Height", "tutorials/linear-fresnel-reflectors-absorber-height.ng3");
        addModel(cspMenu, "Linear Fresnel Reflectors: The Effect of Orientation", "tutorials/linear-fresnel-reflectors-orientation.ng3");
        addModel(cspMenu, "Linear Fresnel Reflectors: Multiple Absorbers", "tutorials/compact-linear-fresnel-reflectors.ng3");
        cspMenu.addSeparator();
        addModel(cspMenu, "Concentrated Solar Power Tower", "tutorials/concentrated-solar-power-tower.ng3");
        addModel(cspMenu, "Cosine Efficiency", "tutorials/csp-cosine-efficiency.ng3");
        addModel(cspMenu, "Shadowing and Blocking", "tutorials/csp-shadowing-blocking.ng3");
        addModel(cspMenu, "Shadowing and Blocking (Reduced Heliostat Height)", "tutorials/csp-shadowing-blocking-less.ng3");
        addModel(cspMenu, "Shadowing and Blocking (Increased Radial Spacing)", "tutorials/csp-shadowing-blocking-even-less.ng3");
        addModel(cspMenu, "The Effect of Solar Tower Height", "tutorials/csp-tower-height.ng3");
        addModel(cspMenu, "Fermat Spiral Layout of Heliostats (Sunflower Pattern)", "tutorials/csp-spiral-layout.ng3");
    }
    return tutorialsMenu;
}
Also used : MenuListener(javax.swing.event.MenuListener) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Aggregations

MenuListener (javax.swing.event.MenuListener)40 MenuEvent (javax.swing.event.MenuEvent)39 JMenu (javax.swing.JMenu)35 ActionEvent (java.awt.event.ActionEvent)23 JMenuItem (javax.swing.JMenuItem)23 ActionListener (java.awt.event.ActionListener)22 ItemEvent (java.awt.event.ItemEvent)18 ItemListener (java.awt.event.ItemListener)18 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)14 ButtonGroup (javax.swing.ButtonGroup)13 JPanel (javax.swing.JPanel)10 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)10 BorderLayout (java.awt.BorderLayout)9 HousePart (org.concord.energy3d.model.HousePart)9 Foundation (org.concord.energy3d.model.Foundation)8 JDialog (javax.swing.JDialog)7 JMenuBar (javax.swing.JMenuBar)7 JTextField (javax.swing.JTextField)6 BoxLayout (javax.swing.BoxLayout)5 JRadioButton (javax.swing.JRadioButton)5