Search in sources :

Example 16 with MenuEvent

use of javax.swing.event.MenuEvent 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 17 with MenuEvent

use of javax.swing.event.MenuEvent 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)

Example 18 with MenuEvent

use of javax.swing.event.MenuEvent in project triplea by triplea-game.

the class ViewMenu method addDrawTerritoryBordersAgain.

private void addDrawTerritoryBordersAgain() {
    final JMenu drawBordersMenu = new JMenu();
    drawBordersMenu.setMnemonic(KeyEvent.VK_O);
    drawBordersMenu.setText("Draw Borders On Top");
    final JRadioButton noneButton = new JRadioButton("Low");
    noneButton.setMnemonic(KeyEvent.VK_L);
    final JRadioButton mediumButton = new JRadioButton("Medium");
    mediumButton.setMnemonic(KeyEvent.VK_M);
    final JRadioButton highButton = new JRadioButton("High");
    highButton.setMnemonic(KeyEvent.VK_H);
    final ButtonGroup group = new ButtonGroup();
    group.add(noneButton);
    group.add(mediumButton);
    group.add(highButton);
    drawBordersMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            final IDrawable.OptionalExtraBorderLevel current = uiContext.getDrawTerritoryBordersAgain();
            if (current == IDrawable.OptionalExtraBorderLevel.LOW) {
                noneButton.setSelected(true);
            } else if (current == IDrawable.OptionalExtraBorderLevel.MEDIUM) {
                mediumButton.setSelected(true);
            } else if (current == IDrawable.OptionalExtraBorderLevel.HIGH) {
                highButton.setSelected(true);
            }
        }

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

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    noneButton.addActionListener(e -> {
        if (noneButton.isSelected() && uiContext.getDrawTerritoryBordersAgain() != IDrawable.OptionalExtraBorderLevel.LOW) {
            uiContext.setDrawTerritoryBordersAgain(IDrawable.OptionalExtraBorderLevel.LOW);
            frame.getMapPanel().resetMap();
        }
    });
    mediumButton.addActionListener(e -> {
        if (mediumButton.isSelected() && uiContext.getDrawTerritoryBordersAgain() != IDrawable.OptionalExtraBorderLevel.MEDIUM) {
            uiContext.setDrawTerritoryBordersAgain(IDrawable.OptionalExtraBorderLevel.MEDIUM);
            frame.getMapPanel().resetMap();
        }
    });
    highButton.addActionListener(e -> {
        if (highButton.isSelected() && uiContext.getDrawTerritoryBordersAgain() != IDrawable.OptionalExtraBorderLevel.HIGH) {
            uiContext.setDrawTerritoryBordersAgain(IDrawable.OptionalExtraBorderLevel.HIGH);
            frame.getMapPanel().resetMap();
        }
    });
    drawBordersMenu.add(noneButton);
    drawBordersMenu.add(mediumButton);
    drawBordersMenu.add(highButton);
    add(drawBordersMenu);
}
Also used : JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) MenuListener(javax.swing.event.MenuListener) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 19 with MenuEvent

use of javax.swing.event.MenuEvent in project airavata by apache.

the class RunMenuItem method createWorkflowMenu.

/**
 * Creates workflow menu.
 */
private void createWorkflowMenu() {
    // this.launchDynamicWorkflowItem = createLaunchDynamicWorkflowItem();
    createLaunchXBayaInterpreterItem();
    // this.configMonitorItem = createConfigMonitoring();
    // this.resumeMonitoringItem = createResumeMonitoring();
    // this.pauseMonitoringItem = createPauseMonitoring();
    // this.resetMonitoringItem = createResetMonitoring();
    // stopWorkflowItem = createStopWorkflow();
    runMenu = new JMenu("Run");
    runMenu.setMnemonic(KeyEvent.VK_R);
    runMenu.add(launchXBayaInterpreterItem);
    // runMenu.add(launchDynamicWorkflowItem);
    // runMenu.addSeparator();
    // runMenu.add(stopWorkflowItem);
    // runMenu.addSeparator();
    // runMenu.add(this.resumeMonitoringItem);
    // runMenu.add(this.pauseMonitoringItem);
    // runMenu.add(this.resetMonitoringItem);
    // runMenu.add(this.configMonitorItem);
    runMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuCanceled(MenuEvent e) {
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuSelected(MenuEvent e) {
        // stopWorkflowItem.setEnabled(isWorkflowRunning());
        }
    });
    setupMonitors();
    // startStopButtonStateUpdater();
    executionModeChanged(engine.getConfiguration());
}
Also used : MenuListener(javax.swing.event.MenuListener) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 20 with MenuEvent

use of javax.swing.event.MenuEvent in project org.alloytools.alloy by AlloyTools.

the class OurUtil method menu.

/**
 * Construct a new JMenu and add it to an existing JMenuBar.
 * <p>
 * Note: every time the user expands then collapses this JMenu, we automatically
 * enable all JMenu and JMenuItem objects in it.
 *
 * @param parent - the JMenuBar to add this Menu into (or null if we don't want
 *            to add it to a JMenuBar yet)
 * @param label - the label to show on screen (if it contains '&' followed by
 *            'a'..'z', we'll remove '&' and use it as mnemonic)
 * @param func - if nonnull we'll call its "run()" method right before expanding
 *            this menu
 */
public static JMenu menu(JMenuBar parent, String label, final Runnable func) {
    final JMenu x = new JMenu(label.replace("&", ""), false);
    if (!Util.onMac()) {
        int i = label.indexOf('&');
        if (i >= 0 && i + 1 < label.length())
            i = label.charAt(i + 1);
        if (i >= 'a' && i <= 'z')
            x.setMnemonic((i - 'a') + 'A');
        else if (i >= 'A' && i <= 'Z')
            x.setMnemonic(i);
    }
    x.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            if (func != null)
                func.run();
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            OurUtil.enableAll(x);
        }

        @Override
        public void menuCanceled(MenuEvent e) {
            OurUtil.enableAll(x);
        }
    });
    if (parent != null)
        parent.add(x);
    return x;
}
Also used : MenuListener(javax.swing.event.MenuListener) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Aggregations

MenuEvent (javax.swing.event.MenuEvent)42 MenuListener (javax.swing.event.MenuListener)39 JMenu (javax.swing.JMenu)38 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 JMenuBar (javax.swing.JMenuBar)10 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 JTextField (javax.swing.JTextField)6 BoxLayout (javax.swing.BoxLayout)5 JRadioButton (javax.swing.JRadioButton)5