Search in sources :

Example 6 with EnergyPanel

use of org.concord.energy3d.gui.EnergyPanel in project energy3d by concord-consortium.

the class HeliostatAnnualAnalysis method runAnalysis.

@Override
void runAnalysis(final JDialog parent) {
    graph.info = "Calculating...";
    graph.repaint();
    onStart();
    final EnergyPanel e = EnergyPanel.getInstance();
    for (final int m : MONTHS) {
        SceneManager.getTaskManager().update(new Callable<Object>() {

            @Override
            public Object call() {
                if (!analysisStopped) {
                    final Calendar c = Heliodon.getInstance().getCalendar();
                    c.set(Calendar.MONTH, m);
                    final Calendar today = (Calendar) c.clone();
                    Scene.getInstance().updateTrackables();
                    final Throwable t = compute();
                    if (t != null) {
                        stopAnalysis();
                        EventQueue.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                BugReporter.report(t);
                            }
                        });
                    }
                    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                    if (selectedPart instanceof Foundation) {
                        // synchronize with daily graph
                        final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
                        if (g.hasGraph()) {
                            g.setCalendar(today);
                            g.updateGraph();
                        }
                    }
                    final Calendar today2 = today;
                    EventQueue.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            e.getDateSpinner().setValue(c.getTime());
                            if (selectedPart instanceof Foundation) {
                                final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
                                e.getCspProjectTabbedPane().setSelectedComponent(g);
                                if (!g.hasGraph()) {
                                    g.setCalendar(today2);
                                    g.addGraph((Foundation) selectedPart);
                                }
                            }
                        }
                    });
                }
                return null;
            }
        });
    }
    SceneManager.getTaskManager().update(new Callable<Object>() {

        @Override
        public Object call() {
            EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    onCompletion();
                    if (Heliodon.getInstance().getCalendar().get(Calendar.MONTH) != Calendar.DECEMBER) {
                        // annual calculation aborted
                        return;
                    }
                    final String current = Graph.TWO_DECIMALS.format(getResult("Solar"));
                    final Map<String, Double> recordedResults = getRecordedResults("Solar");
                    final int n = recordedResults.size();
                    if (n > 0) {
                        String previousRuns = "";
                        final Object[] keys = recordedResults.keySet().toArray();
                        for (int i = n - 1; i >= 0; i--) {
                            previousRuns += keys[i] + " : " + Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + " kWh<br>";
                        }
                        final Object[] options = new Object[] { "OK", "Copy Data" };
                        final String msg = "<html>The calculated annual output is <b>" + current + " kWh</b>.<br><hr>Results from previously recorded tests:<br>" + previousRuns + "</html>";
                        final JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
                        final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Annual Output");
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            String output = "";
                            for (int i = 0; i < n; i++) {
                                output += Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + "\n";
                            }
                            output += current;
                            final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
                            clpbrd.setContents(new StringSelection(output), null);
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), "<html>" + (n + 1) + " data points copied to system clipboard.<br><hr>" + output, "Confirmation", JOptionPane.INFORMATION_MESSAGE);
                        }
                    } else {
                        JOptionPane.showMessageDialog(parent, "<html>The calculated annual output is <b>" + current + " kWh</b>.</html>", "Annual Output", JOptionPane.INFORMATION_MESSAGE);
                    }
                }
            });
            return null;
        }
    });
}
Also used : Calendar(java.util.Calendar) CspProjectDailyEnergyGraph(org.concord.energy3d.gui.CspProjectDailyEnergyGraph) JOptionPane(javax.swing.JOptionPane) StringSelection(java.awt.datatransfer.StringSelection) EnergyPanel(org.concord.energy3d.gui.EnergyPanel) Foundation(org.concord.energy3d.model.Foundation) Clipboard(java.awt.datatransfer.Clipboard) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Example 7 with EnergyPanel

use of org.concord.energy3d.gui.EnergyPanel in project energy3d by concord-consortium.

the class ParabolicDishAnnualAnalysis method runAnalysis.

@Override
void runAnalysis(final JDialog parent) {
    graph.info = "Calculating...";
    graph.repaint();
    onStart();
    final EnergyPanel e = EnergyPanel.getInstance();
    for (final int m : MONTHS) {
        SceneManager.getTaskManager().update(new Callable<Object>() {

            @Override
            public Object call() {
                if (!analysisStopped) {
                    final Calendar c = Heliodon.getInstance().getCalendar();
                    c.set(Calendar.MONTH, m);
                    final Calendar today = (Calendar) c.clone();
                    Scene.getInstance().updateTrackables();
                    final Throwable t = compute();
                    if (t != null) {
                        stopAnalysis();
                        EventQueue.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                BugReporter.report(t);
                            }
                        });
                    }
                    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                    if (selectedPart instanceof Foundation) {
                        // synchronize with daily graph
                        final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
                        if (g.hasGraph()) {
                            g.setCalendar(today);
                            g.updateGraph();
                        }
                    }
                    final Calendar today2 = today;
                    EventQueue.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            e.getDateSpinner().setValue(c.getTime());
                            if (selectedPart instanceof Foundation) {
                                final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
                                e.getCspProjectTabbedPane().setSelectedComponent(g);
                                if (!g.hasGraph()) {
                                    g.setCalendar(today2);
                                    g.addGraph((Foundation) selectedPart);
                                }
                            }
                        }
                    });
                }
                return null;
            }
        });
    }
    SceneManager.getTaskManager().update(new Callable<Object>() {

        @Override
        public Object call() {
            EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    onCompletion();
                    if (Heliodon.getInstance().getCalendar().get(Calendar.MONTH) != Calendar.DECEMBER) {
                        // annual calculation aborted
                        return;
                    }
                    final String current = Graph.TWO_DECIMALS.format(getResult("Solar"));
                    final Map<String, Double> recordedResults = getRecordedResults("Solar");
                    final int n = recordedResults.size();
                    if (n > 0) {
                        String previousRuns = "";
                        final Object[] keys = recordedResults.keySet().toArray();
                        for (int i = n - 1; i >= 0; i--) {
                            previousRuns += keys[i] + " : " + Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + " kWh<br>";
                        }
                        final Object[] options = new Object[] { "OK", "Copy Data" };
                        final String msg = "<html>The calculated annual output is <b>" + current + " kWh</b>.<br><hr>Results from previously recorded tests:<br>" + previousRuns + "</html>";
                        final JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
                        final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Annual Output");
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            String output = "";
                            for (int i = 0; i < n; i++) {
                                output += Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + "\n";
                            }
                            output += current;
                            final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
                            clpbrd.setContents(new StringSelection(output), null);
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), "<html>" + (n + 1) + " data points copied to system clipboard.<br><hr>" + output, "Confirmation", JOptionPane.INFORMATION_MESSAGE);
                        }
                    } else {
                        JOptionPane.showMessageDialog(parent, "<html>The calculated annual output is <b>" + current + " kWh</b>.</html>", "Annual Output", JOptionPane.INFORMATION_MESSAGE);
                    }
                }
            });
            return null;
        }
    });
}
Also used : Calendar(java.util.Calendar) CspProjectDailyEnergyGraph(org.concord.energy3d.gui.CspProjectDailyEnergyGraph) JOptionPane(javax.swing.JOptionPane) StringSelection(java.awt.datatransfer.StringSelection) EnergyPanel(org.concord.energy3d.gui.EnergyPanel) Foundation(org.concord.energy3d.model.Foundation) Clipboard(java.awt.datatransfer.Clipboard) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Aggregations

EnergyPanel (org.concord.energy3d.gui.EnergyPanel)7 HousePart (org.concord.energy3d.model.HousePart)7 Clipboard (java.awt.datatransfer.Clipboard)6 StringSelection (java.awt.datatransfer.StringSelection)6 Calendar (java.util.Calendar)6 JDialog (javax.swing.JDialog)6 JOptionPane (javax.swing.JOptionPane)6 Foundation (org.concord.energy3d.model.Foundation)6 CspProjectDailyEnergyGraph (org.concord.energy3d.gui.CspProjectDailyEnergyGraph)4 ColorRGBA (com.ardor3d.math.ColorRGBA)1 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)1 Date (java.util.Date)1 PvProjectDailyEnergyGraph (org.concord.energy3d.gui.PvProjectDailyEnergyGraph)1 Human (org.concord.energy3d.model.Human)1 Tree (org.concord.energy3d.model.Tree)1 Atmosphere (org.concord.energy3d.simulation.Atmosphere)1 CspCustomPrice (org.concord.energy3d.simulation.CspCustomPrice)1 CspDesignSpecs (org.concord.energy3d.simulation.CspDesignSpecs)1 DesignSpecs (org.concord.energy3d.simulation.DesignSpecs)1 Ground (org.concord.energy3d.simulation.Ground)1