Search in sources :

Example 66 with Foundation

use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.

the class PvAnnualAnalysis 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 PvProjectDailyEnergyGraph g = e.getPvProjectDailyEnergyGraph();
                        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 PvProjectDailyEnergyGraph g = e.getPvProjectDailyEnergyGraph();
                                e.getPvProjectTabbedPane().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 Photovoltaic 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 Photovoltaic Output", JOptionPane.INFORMATION_MESSAGE);
                    }
                }
            });
            return null;
        }
    });
}
Also used : Calendar(java.util.Calendar) JOptionPane(javax.swing.JOptionPane) StringSelection(java.awt.datatransfer.StringSelection) EnergyPanel(org.concord.energy3d.gui.EnergyPanel) PvProjectDailyEnergyGraph(org.concord.energy3d.gui.PvProjectDailyEnergyGraph) Foundation(org.concord.energy3d.model.Foundation) Clipboard(java.awt.datatransfer.Clipboard) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Example 67 with Foundation

use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.

the class MovePartCommand method move.

private void move(final Vector3 v) {
    SceneManager.getInstance().setSelectedPart(part);
    SceneManager.getTaskManager().update(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            if (part == null) {
                for (final HousePart p : Scene.getInstance().getParts()) {
                    if (p instanceof Foundation) {
                        ((Foundation) p).move(v, p.getGridSize());
                    }
                }
            } else if (part instanceof Foundation) {
                final Foundation f = (Foundation) part;
                if (f.isGroupMaster()) {
                    final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
                    for (final Foundation x : g) {
                        x.move(v, part.getGridSize());
                    }
                } else {
                    f.move(v, part.getGridSize());
                }
            } else if (part instanceof Window) {
                final Window w = (Window) part;
                w.move(v);
                w.draw();
            } else if (part instanceof SolarPanel) {
                final SolarPanel s = (SolarPanel) part;
                s.move(v, part.getGridSize());
                s.draw();
            } else if (part instanceof Rack) {
                final Rack r = (Rack) part;
                r.move(v, part.getGridSize());
                r.draw();
            } else if (part instanceof Mirror) {
                final Mirror m = (Mirror) part;
                m.move(v, part.getGridSize());
                m.draw();
            } else if (part instanceof ParabolicTrough) {
                final ParabolicTrough t = (ParabolicTrough) part;
                t.move(v, part.getGridSize());
                t.draw();
            } else if (part instanceof ParabolicDish) {
                final ParabolicDish d = (ParabolicDish) part;
                d.move(v, part.getGridSize());
                d.draw();
            } else if (part instanceof FresnelReflector) {
                final FresnelReflector f = (FresnelReflector) part;
                f.move(v, part.getGridSize());
                f.draw();
            }
            return null;
        }
    });
}
Also used : Window(org.concord.energy3d.model.Window) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) CannotUndoException(javax.swing.undo.CannotUndoException) CannotRedoException(javax.swing.undo.CannotRedoException) ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 68 with Foundation

use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.

the class RescaleBuildingCommand method redo.

@Override
public void redo() throws CannotRedoException {
    super.redo();
    if (foundation.isGroupMaster()) {
        final List<Foundation> g = Scene.getInstance().getFoundationGroup(foundation);
        for (final Foundation f : g) {
            f.rescale(newXLength / oldXLength, newYLength / oldYLength, newZLength / oldZLength);
            f.draw();
            f.drawChildren();
        }
    } else {
        foundation.rescale(newXLength / oldXLength, newYLength / oldYLength, newZLength / oldZLength);
        foundation.draw();
        foundation.drawChildren();
    }
    SceneManager.getInstance().refresh();
}
Also used : Foundation(org.concord.energy3d.model.Foundation)

Example 69 with Foundation

use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.

the class ChangeSolarReceiverEfficiencyForAllReflectorsCommand method redo.

@Override
public void redo() throws CannotRedoException {
    super.redo();
    final int n = reflectors.size();
    for (int i = 0; i < n; i++) {
        final SolarReflector r = reflectors.get(i);
        if (r instanceof HousePart) {
            final Foundation f = ((HousePart) r).getTopContainer();
            f.setSolarReceiverEfficiency(newValues[i]);
        }
    }
}
Also used : SolarReflector(org.concord.energy3d.model.SolarReflector) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 70 with Foundation

use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.

the class ChangeSolarReceiverEfficiencyForAllReflectorsCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = reflectors.size();
    newValues = new double[n];
    for (int i = 0; i < n; i++) {
        final SolarReflector r = reflectors.get(i);
        if (r instanceof HousePart) {
            final Foundation f = ((HousePart) r).getTopContainer();
            newValues[i] = f.getSolarReceiverEfficiency();
            f.setSolarReceiverEfficiency(oldValues[i]);
        }
    }
}
Also used : SolarReflector(org.concord.energy3d.model.SolarReflector) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

Foundation (org.concord.energy3d.model.Foundation)174 HousePart (org.concord.energy3d.model.HousePart)153 Rack (org.concord.energy3d.model.Rack)47 SolarPanel (org.concord.energy3d.model.SolarPanel)45 Window (org.concord.energy3d.model.Window)39 ActionEvent (java.awt.event.ActionEvent)38 ActionListener (java.awt.event.ActionListener)38 Roof (org.concord.energy3d.model.Roof)38 Wall (org.concord.energy3d.model.Wall)37 ArrayList (java.util.ArrayList)35 JDialog (javax.swing.JDialog)35 JMenuItem (javax.swing.JMenuItem)33 Mirror (org.concord.energy3d.model.Mirror)32 FresnelReflector (org.concord.energy3d.model.FresnelReflector)27 Door (org.concord.energy3d.model.Door)24 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)24 Tree (org.concord.energy3d.model.Tree)24 Vector3 (com.ardor3d.math.Vector3)22 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)22 ParabolicDish (org.concord.energy3d.model.ParabolicDish)22