Search in sources :

Example 6 with MenuListener

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

the class AnnualAnalysis method createOptionsMenu.

JMenu createOptionsMenu(final JDialog dialog, final List<HousePart> selectedParts, final boolean selectAll, final boolean exportStoredResults) {
    final JMenuItem miClear = new JMenuItem("Clear Previous Results");
    final JMenuItem miView = new JMenuItem("View Raw Data...");
    final JMenuItem miExportStoredResults = new JMenuItem("Export Stored Hourly Results");
    final JMenu menu = new JMenu("Options");
    menu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            miClear.setEnabled(graph.hasRecords());
            miView.setEnabled(graph.hasData());
            miExportStoredResults.setEnabled(Scene.getInstance().getSolarResults() != null);
        }

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

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    final JMenu chartMenu = new JMenu("Chart");
    final ButtonGroup chartGroup = new ButtonGroup();
    menu.add(chartMenu);
    final JRadioButtonMenuItem miLine = new JRadioButtonMenuItem("Line");
    miLine.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graph.setGraphType(Graph.LINE_CHART);
                graph.repaint();
            }
        }
    });
    chartMenu.add(miLine);
    chartGroup.add(miLine);
    miLine.setSelected(graph.getGraphType() == Graph.LINE_CHART);
    final JRadioButtonMenuItem miArea = new JRadioButtonMenuItem("Area");
    miArea.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graph.setGraphType(Graph.AREA_CHART);
                graph.repaint();
            }
        }
    });
    chartMenu.add(miArea);
    chartGroup.add(miArea);
    miArea.setSelected(graph.getGraphType() == Graph.AREA_CHART);
    miClear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            final int i = JOptionPane.showConfirmDialog(dialog, "Are you sure that you want to clear all the previous results\nrelated to the selected object?", "Confirmation", JOptionPane.YES_NO_OPTION);
            if (i != JOptionPane.YES_OPTION) {
                return;
            }
            graph.clearRecords();
            graph.repaint();
            TimeSeriesLogger.getInstance().logClearGraphData(graph.getClass().getSimpleName());
        }
    });
    menu.add(miClear);
    miView.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (selectedParts == null) {
                DataViewer.viewRawData(dialog, graph, selectAll);
            } else {
                DataViewer.viewRawData(dialog, graph, selectedParts);
            }
        }
    });
    menu.add(miView);
    final JMenuItem miCopyImage = new JMenuItem("Copy Image");
    miCopyImage.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(graph);
        }
    });
    menu.add(miCopyImage);
    if (exportStoredResults) {
        miExportStoredResults.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final double[][] solarResults = Scene.getInstance().getSolarResults();
                if (solarResults != null) {
                    double sum = 0;
                    // Hack to fix the results in case we make a mistake that can be quickly remedied
                    final double scale = 1;
                    for (int i = 0; i < solarResults.length; i++) {
                        for (int j = 0; j < solarResults[i].length; j++) {
                            solarResults[i][j] *= scale;
                            sum += solarResults[i][j];
                        }
                    }
                    sum *= 365.0 / 12.0;
                    String s = "";
                    for (int i = 0; i < solarResults.length; i++) {
                        s += "\"" + AnnualGraph.THREE_LETTER_MONTH[i] + "\": \"";
                        for (int j = 0; j < solarResults[i].length; j++) {
                            s += EnergyPanel.FIVE_DECIMALS.format(solarResults[i][j]).replaceAll(",", "") + " ";
                        }
                        s = s.trim() + "\",\n\t";
                    }
                    s = s.substring(0, s.length() - 1);
                    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(s), null);
                    JOptionPane.showMessageDialog(dialog, "A total of " + EnergyPanel.TWO_DECIMALS.format(sum) + " KWh was copied to the clipboard.", "Export", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        });
        menu.add(miExportStoredResults);
    }
    return menu;
}
Also used : ItemEvent(java.awt.event.ItemEvent) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) ClipImage(org.concord.energy3d.util.ClipImage) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) StringSelection(java.awt.datatransfer.StringSelection) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ItemListener(java.awt.event.ItemListener) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 7 with MenuListener

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

the class EnergyAngularAnalysis method show.

public void show(final String title) {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    String s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
    if (selectedPart instanceof Foundation) {
        s = s.replaceAll("Foundation", "Building");
        if (selectedPart.getChildren().isEmpty()) {
            JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no building on this foundation.", "No Building", JOptionPane.WARNING_MESSAGE);
            return;
        }
        if (!isBuildingComplete((Foundation) selectedPart)) {
            if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "The selected building has not been completed.\nAre you sure to continue?", "Incomplete Building", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }
    } else if (selectedPart instanceof Tree) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "Energy analysis is not applicable to a tree.", "Not Applicable", JOptionPane.WARNING_MESSAGE);
        return;
    }
    final JDialog dialog = new JDialog(MainFrame.getInstance(), title + ": " + s, true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    graph.parent = dialog;
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    final JMenuItem miClear = new JMenuItem("Clear Previous Results");
    final JMenuItem miView = new JMenuItem("View Raw Data...");
    final JMenuItem miCopyImage = new JMenuItem("Copy Image");
    final JMenu menu = new JMenu("Options");
    menu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            miClear.setEnabled(graph.hasRecords());
            miView.setEnabled(graph.hasData());
        }

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

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    menuBar.add(menu);
    miClear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            final int i = JOptionPane.showConfirmDialog(dialog, "Are you sure that you want to clear all the previous results\nrelated to the selected object?", "Confirmation", JOptionPane.YES_NO_OPTION);
            if (i != JOptionPane.YES_OPTION) {
                return;
            }
            graph.clearRecords();
            graph.repaint();
            TimeSeriesLogger.getInstance().logClearGraphData(graph.getClass().getSimpleName());
        }
    });
    menu.add(miClear);
    miView.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            DataViewer.viewRawData(dialog, graph, false);
        }
    });
    menu.add(miView);
    miCopyImage.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(graph);
        }
    });
    menu.add(miCopyImage);
    final JMenu showTypeMenu = new JMenu("Types");
    showTypeMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            showTypeMenu.removeAll();
            final Set<String> dataNames = graph.getDataNames();
            if (!dataNames.isEmpty()) {
                JMenuItem mi = new JMenuItem("Show All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final String name : dataNames) {
                            graph.hideData(name, false);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowCurve(graph.getClass().getSimpleName(), "All", true);
                    }
                });
                showTypeMenu.add(mi);
                mi = new JMenuItem("Hide All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final String name : dataNames) {
                            graph.hideData(name, true);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowCurve(graph.getClass().getSimpleName(), "All", false);
                    }
                });
                showTypeMenu.add(mi);
                showTypeMenu.addSeparator();
                for (final String name : dataNames) {
                    final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(name, !graph.isDataHidden(name));
                    cbmi.addItemListener(new ItemListener() {

                        @Override
                        public void itemStateChanged(final ItemEvent e) {
                            graph.hideData(name, !cbmi.isSelected());
                            graph.repaint();
                            TimeSeriesLogger.getInstance().logShowCurve(graph.getClass().getSimpleName(), name, cbmi.isSelected());
                        }
                    });
                    showTypeMenu.add(cbmi);
                }
            }
        }

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

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    menuBar.add(showTypeMenu);
    final JMenu showRunsMenu = new JMenu("Runs");
    showRunsMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            showRunsMenu.removeAll();
            if (!AngularGraph.records.isEmpty()) {
                JMenuItem mi = new JMenuItem("Show All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final Results r : AngularGraph.records) {
                            graph.hideRun(r.getID(), false);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowRun(graph.getClass().getSimpleName(), "All", true);
                    }
                });
                showRunsMenu.add(mi);
                mi = new JMenuItem("Hide All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final Results r : AngularGraph.records) {
                            graph.hideRun(r.getID(), true);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowRun(graph.getClass().getSimpleName(), "All", false);
                    }
                });
                showRunsMenu.add(mi);
                showRunsMenu.addSeparator();
                for (final Results r : AngularGraph.records) {
                    final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(Integer.toString(r.getID()), !graph.isRunHidden(r.getID()));
                    cbmi.addItemListener(new ItemListener() {

                        @Override
                        public void itemStateChanged(final ItemEvent e) {
                            graph.hideRun(r.getID(), !cbmi.isSelected());
                            graph.repaint();
                            TimeSeriesLogger.getInstance().logShowRun(graph.getClass().getSimpleName(), "" + r.getID(), cbmi.isSelected());
                        }
                    });
                    showRunsMenu.add(cbmi);
                }
            }
        }

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

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    menuBar.add(showRunsMenu);
    final JPanel contentPane = new JPanel(new BorderLayout());
    dialog.setContentPane(contentPane);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    contentPane.add(panel, BorderLayout.CENTER);
    panel.add(graph, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    runButton = new JButton("Run");
    runButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            runButton.setEnabled(false);
            runAnalysis(dialog);
        }
    });
    buttonPanel.add(runButton);
    final JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            stopAnalysis();
            if (graph.hasData()) {
                final Object[] options = { "Yes", "No", "Cancel" };
                final int i = JOptionPane.showOptionDialog(dialog, "Do you want to keep the results of this run?", "Confirmation", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]);
                if (i == JOptionPane.CANCEL_OPTION) {
                    return;
                }
                if (i == JOptionPane.YES_OPTION) {
                    graph.keepResults();
                }
            }
            windowLocation.setLocation(dialog.getLocationOnScreen());
            dialog.dispose();
        }
    });
    buttonPanel.add(button);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            stopAnalysis();
            windowLocation.setLocation(dialog.getLocationOnScreen());
            dialog.dispose();
        }
    });
    dialog.pack();
    if (windowLocation.x > 0 && windowLocation.y > 0) {
        dialog.setLocation(windowLocation);
    } else {
        dialog.setLocationRelativeTo(MainFrame.getInstance());
    }
    dialog.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) Set(java.util.Set) FlowLayout(java.awt.FlowLayout) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) BorderLayout(java.awt.BorderLayout) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) JMenuItem(javax.swing.JMenuItem) HousePart(org.concord.energy3d.model.HousePart) MenuEvent(javax.swing.event.MenuEvent) ClipImage(org.concord.energy3d.util.ClipImage) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) ItemListener(java.awt.event.ItemListener) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 8 with MenuListener

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

the class DailyAnalysis method createOptionsMenu.

JMenu createOptionsMenu(final JDialog dialog, final List<HousePart> selectedParts, final boolean selectAll) {
    final JMenuItem miClear = new JMenuItem("Clear Previous Results");
    final JMenuItem miView = new JMenuItem("View Raw Data...");
    final JMenu menu = new JMenu("Options");
    menu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            miClear.setEnabled(graph.hasRecords());
            miView.setEnabled(graph.hasData());
        }

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

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    final JMenu chartMenu = new JMenu("Chart");
    final ButtonGroup chartGroup = new ButtonGroup();
    menu.add(chartMenu);
    final JRadioButtonMenuItem miLine = new JRadioButtonMenuItem("Line");
    miLine.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graph.setGraphType(Graph.LINE_CHART);
                graph.repaint();
            }
        }
    });
    chartMenu.add(miLine);
    chartGroup.add(miLine);
    miLine.setSelected(graph.getGraphType() == Graph.LINE_CHART);
    final JRadioButtonMenuItem miArea = new JRadioButtonMenuItem("Area");
    miArea.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graph.setGraphType(Graph.AREA_CHART);
                graph.repaint();
            }
        }
    });
    chartMenu.add(miArea);
    chartGroup.add(miArea);
    miArea.setSelected(graph.getGraphType() == Graph.AREA_CHART);
    final JCheckBoxMenuItem miMilitaryTime = new JCheckBoxMenuItem("Military Time");
    miMilitaryTime.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (graph instanceof DailyGraph) {
                ((DailyGraph) graph).setMilitaryTime(miMilitaryTime.isSelected());
                graph.repaint();
            }
        }
    });
    menu.add(miMilitaryTime);
    miClear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            final int i = JOptionPane.showConfirmDialog(dialog, "Are you sure that you want to clear all the previous results\nrelated to the selected object?", "Confirmation", JOptionPane.YES_NO_OPTION);
            if (i != JOptionPane.YES_OPTION) {
                return;
            }
            graph.clearRecords();
            graph.repaint();
            TimeSeriesLogger.getInstance().logClearGraphData(graph.getClass().getSimpleName());
        }
    });
    menu.add(miClear);
    miView.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (selectedParts == null) {
                DataViewer.viewRawData(dialog, graph, selectAll);
            } else {
                DataViewer.viewRawData(dialog, graph, selectedParts);
            }
        }
    });
    menu.add(miView);
    final JMenuItem miCopyImage = new JMenuItem("Copy Image");
    miCopyImage.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(graph);
        }
    });
    menu.add(miCopyImage);
    return menu;
}
Also used : ItemEvent(java.awt.event.ItemEvent) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) ClipImage(org.concord.energy3d.util.ClipImage) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ItemListener(java.awt.event.ItemListener) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent)

Example 9 with MenuListener

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

the class MainFrame method getHelpMenu.

private JMenu getHelpMenu() {
    if (helpMenu == null) {
        helpMenu = new JMenu("Help");
        helpMenu.addMenuListener(new MenuListener() {

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

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

            @Override
            public void menuSelected(final MenuEvent e) {
            }
        });
        // User data and models
        final JMenu userHistoryMenu = new JMenu("View My History");
        helpMenu.add(userHistoryMenu);
        helpMenu.addSeparator();
        final JMenu userEventsMenu = new JMenu("Events");
        userHistoryMenu.add(userEventsMenu);
        JMenuItem mi = new JMenuItem("Event String");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new EventString().showGui();
            }
        });
        userEventsMenu.add(mi);
        mi = new JMenuItem("Event Time Series");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new EventTimeSeries().showGui();
            }
        });
        userEventsMenu.add(mi);
        mi = new JMenuItem("Event Frequency");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new EventFrequency().showGui();
            }
        });
        userEventsMenu.add(mi);
        final JMenu userResultsMenu = new JMenu("Results");
        userHistoryMenu.add(userResultsMenu);
        mi = new JMenuItem("Analysis Results");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new ResultList().showGui();
            }
        });
        userResultsMenu.add(mi);
        if (!Config.isMac()) {
            helpMenu.add(getPreferencesMenuItem());
        }
        helpMenu.add(getRecoveryMenuItem());
        // the automatic updater can fail sometimes. This provides an independent check.
        final JMenuItem miUpdate = new JMenuItem("Check Update...");
        helpMenu.add(miUpdate);
        miUpdate.setEnabled(!Config.isWebStart() && !Config.isEclipse());
        miUpdate.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                File jarFile = null;
                try {
                    jarFile = new File(MainApplication.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
                } catch (final URISyntaxException e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(instance, e1.getMessage(), "URL Error (local energy3d.jar)", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (!jarFile.toString().endsWith("energy3d.jar")) {
                    return;
                }
                final long localLastModified = jarFile.lastModified();
                new SwingWorker<Void, Void>() {

                    URLConnection connection = null;

                    String msg = null;

                    long remoteLastModified;

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            connection = new URL("http://energy.concord.org/energy3d/update/energy3d.jar").openConnection();
                            remoteLastModified = connection.getLastModified();
                        } catch (final Exception e1) {
                            e1.printStackTrace();
                            msg = e1.getMessage();
                        }
                        return null;
                    }

                    @Override
                    protected void done() {
                        if (connection == null) {
                            JOptionPane.showMessageDialog(instance, msg, "URL Error (remote energy3d.jar)", JOptionPane.ERROR_MESSAGE);
                        } else {
                            if (remoteLastModified <= localLastModified) {
                                JOptionPane.showMessageDialog(instance, "Your software is up to date.", "Update Status", JOptionPane.INFORMATION_MESSAGE);
                            } else {
                                JOptionPane.showMessageDialog(instance, "<html>Your software is out of date. But for some reason, it cannot update itself.<br>Please go to http://energy3d.concord.org to download and reinstall the latest version.</html>", "Update Status", JOptionPane.INFORMATION_MESSAGE);
                                Util.openBrowser("http://energy3d.concord.org");
                            }
                        }
                    }
                }.execute();
            }
        });
        helpMenu.addSeparator();
        // Energy3D web pages
        mi = new JMenuItem("Visit Virtual Solar Grid...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/vsg/syw.html");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("View Building Examples...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/styles.html");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("View User Work...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/models.html");
            }
        });
        helpMenu.add(mi);
        helpMenu.addSeparator();
        mi = new JMenuItem("Visit User Forum...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("https://energy.concord.org/energy3d/forum/");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("Visit Home Page...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy3d.concord.org");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("Contact Us...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/contact.html");
            }
        });
        helpMenu.add(mi);
        if (!Config.isMac()) {
            helpMenu.add(getAboutMenuItem());
        }
    }
    return helpMenu;
}
Also used : ResultList(org.concord.energy3d.agents.ResultList) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) EventString(org.concord.energy3d.agents.EventString) URISyntaxException(java.net.URISyntaxException) EventString(org.concord.energy3d.agents.EventString) URLConnection(java.net.URLConnection) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) EventTimeSeries(org.concord.energy3d.agents.EventTimeSeries) ActionListener(java.awt.event.ActionListener) EventFrequency(org.concord.energy3d.agents.EventFrequency) SwingWorker(javax.swing.SwingWorker) JMenuItem(javax.swing.JMenuItem) File(java.io.File) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent) MainApplication(org.concord.energy3d.MainApplication)

Example 10 with MenuListener

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

the class MainFrame method getThemeMenu.

private JMenu getThemeMenu() {
    if (themeMenu == null) {
        themeMenu = new JMenu("Theme");
        themeMenu.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) {
                Util.selectSilently(blueSkyMenuItem, Scene.getInstance().getTheme() == Scene.BLUE_SKY_THEME);
                Util.selectSilently(desertMenuItem, Scene.getInstance().getTheme() == Scene.DESERT_THEME);
                Util.selectSilently(grasslandMenuItem, Scene.getInstance().getTheme() == Scene.GRASSLAND_THEME);
                Util.selectSilently(forestMenuItem, Scene.getInstance().getTheme() == Scene.FOREST_THEME);
            }
        });
        themeMenu.add(getBlueSkyMenuItem());
        themeMenu.add(getDesertMenuItem());
        themeMenu.add(getGrasslandMenuItem());
        themeMenu.add(getForestMenuItem());
    }
    return themeMenu;
}
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