Search in sources :

Example 1 with ParabolicDish

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

the class PopupMenuForParabolicDish method getPopupMenu.

static JPopupMenu getPopupMenu() {
    if (popupMenuForParabolicDish == null) {
        final JMenuItem miMesh = new JMenuItem("Mesh...");
        miMesh.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final Foundation foundation = d.getTopContainer();
                final String partInfo = d.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel inputPanel = new JPanel(new GridLayout(2, 2, 5, 5));
                gui.add(inputPanel, BorderLayout.CENTER);
                inputPanel.add(new JLabel("Radial Direction: "));
                final JTextField nRadialField = new JTextField("" + d.getNRadialSections());
                inputPanel.add(nRadialField);
                inputPanel.add(new JLabel("Axial Direction: "));
                final JTextField nAxialField = new JTextField("" + d.getNAxialSections());
                inputPanel.add(nAxialField);
                inputPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
                final JPanel scopePanel = new JPanel();
                scopePanel.setLayout(new BoxLayout(scopePanel, BoxLayout.Y_AXIS));
                scopePanel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                scopePanel.add(rb1);
                scopePanel.add(rb2);
                scopePanel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                gui.add(scopePanel, BorderLayout.NORTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { "Set mesh for " + partInfo, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Mesh");
                while (true) {
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        int nRadialSections = 0, nAxialSections = 0;
                        boolean ok = true;
                        try {
                            nRadialSections = Integer.parseInt(nRadialField.getText());
                            nAxialSections = Integer.parseInt(nAxialField.getText());
                        } catch (final NumberFormatException nfe) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), "Invalid input!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (nRadialSections < 4) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Number of radial sections must be at least 4.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else if (nAxialSections < 4) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Number of axial sections mesh must be at least 4.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else if (!Util.isPowerOfTwo(nRadialSections) || !Util.isPowerOfTwo(nAxialSections)) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Number of parabolic dish mesh sections in x or y direction must be power of two.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                if (rb1.isSelected()) {
                                    // final SetPartSizeCommand c = new SetPartSizeCommand(t);
                                    d.setNRadialSections(nRadialSections);
                                    d.setNAxialSections(nAxialSections);
                                    d.draw();
                                    SceneManager.getInstance().refresh();
                                    // SceneManager.getInstance().getUndoManager().addEdit(c);
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    // final SetShapeForParabolicTroughsOnFoundationCommand c = new SetShapeForParabolicTroughsOnFoundationCommand(foundation);
                                    foundation.setSectionsForParabolicDishes(nRadialSections, nAxialSections);
                                    // SceneManager.getInstance().getUndoManager().addEdit(c);
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    // final SetShapeForAllParabolicTroughsCommand c = new SetShapeForAllParabolicTroughsCommand();
                                    Scene.getInstance().setSectionsForAllParabolicDishes(nRadialSections, nAxialSections);
                                    // SceneManager.getInstance().getUndoManager().addEdit(c);
                                    selectedScopeIndex = 2;
                                }
                                updateAfterEdit();
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        final JMenuItem miRib = new JMenuItem("Ribs...");
        miRib.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final Foundation foundation = d.getTopContainer();
                final String partInfo = d.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel inputPanel = new JPanel(new GridLayout(2, 2, 5, 5));
                gui.add(inputPanel, BorderLayout.CENTER);
                inputPanel.add(new JLabel("Rib Lines: "));
                final JTextField nribField = new JTextField("" + d.getNumberOfRibs());
                inputPanel.add(nribField);
                inputPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
                final JPanel scopePanel = new JPanel();
                scopePanel.setLayout(new BoxLayout(scopePanel, BoxLayout.Y_AXIS));
                scopePanel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                scopePanel.add(rb1);
                scopePanel.add(rb2);
                scopePanel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                gui.add(scopePanel, BorderLayout.NORTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { "Set rib lines for " + partInfo, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Ribs");
                while (true) {
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        int nrib = 0;
                        boolean ok = true;
                        try {
                            nrib = Integer.parseInt(nribField.getText());
                        } catch (final NumberFormatException nfe) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), "Invalid input!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (nrib < 0) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Number of ribs cannot be negative.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                boolean changed = nrib != d.getNumberOfRibs();
                                if (rb1.isSelected()) {
                                    if (changed) {
                                        final SetParabolicDishRibsCommand c = new SetParabolicDishRibsCommand(d);
                                        d.setNumberOfRibs(nrib);
                                        d.draw();
                                        SceneManager.getInstance().refresh();
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                            if (x.getNumberOfRibs() != nrib) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final SetRibsForParabolicDishesOnFoundationCommand c = new SetRibsForParabolicDishesOnFoundationCommand(foundation);
                                        foundation.setNumberOfRibsForParabolicDishes(nrib);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                            if (x.getNumberOfRibs() != nrib) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final SetRibsForAllParabolicDishesCommand c = new SetRibsForAllParabolicDishesCommand();
                                        Scene.getInstance().setNumberOfRibsForAllParabolicDishes(nrib);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 2;
                                }
                                if (changed) {
                                    updateAfterEdit();
                                }
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        final JCheckBoxMenuItem cbmiDisableEditPoint = new JCheckBoxMenuItem("Disable Edit Point");
        cbmiDisableEditPoint.addItemListener(new ItemListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void itemStateChanged(final ItemEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final boolean disabled = cbmiDisableEditPoint.isSelected();
                final ParabolicDish dish = (ParabolicDish) selectedPart;
                final String partInfo = dish.toString().substring(0, dish.toString().indexOf(')') + 1);
                final JPanel gui = new JPanel(new BorderLayout(0, 20));
                final JPanel panel = new JPanel();
                gui.add(panel, BorderLayout.SOUTH);
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                panel.add(rb1);
                panel.add(rb2);
                panel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                final String title = "<html>" + (disabled ? "Disable" : "Enable") + " edit point for " + partInfo + "</html>";
                final String footnote = "<html><hr><font size=2>Disable the edit point of a parabolic dish prevents it<br>from being unintentionally moved.<hr></html>";
                final Object[] options = new Object[] { "OK", "Cancel" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { title, footnote, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[0]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), (disabled ? "Disable" : "Enable") + " Edit Point");
                dialog.setVisible(true);
                if (optionPane.getValue() == options[0]) {
                    if (rb1.isSelected()) {
                        final LockEditPointsCommand c = new LockEditPointsCommand(dish);
                        dish.setLockEdit(disabled);
                        SceneManager.getInstance().getUndoManager().addEdit(c);
                        selectedScopeIndex = 0;
                    } else if (rb2.isSelected()) {
                        final Foundation foundation = dish.getTopContainer();
                        final LockEditPointsOnFoundationCommand c = new LockEditPointsOnFoundationCommand(foundation, dish.getClass());
                        foundation.setLockEditForClass(disabled, dish.getClass());
                        SceneManager.getInstance().getUndoManager().addEdit(c);
                        selectedScopeIndex = 1;
                    } else if (rb3.isSelected()) {
                        final LockEditPointsForClassCommand c = new LockEditPointsForClassCommand(dish);
                        Scene.getInstance().setLockEditForClass(disabled, dish.getClass());
                        SceneManager.getInstance().getUndoManager().addEdit(c);
                        selectedScopeIndex = 2;
                    }
                    SceneManager.getInstance().refresh();
                    Scene.getInstance().setEdited(true);
                }
            }
        });
        final JCheckBoxMenuItem cbmiDrawSunBeams = new JCheckBoxMenuItem("Draw Sun Beams");
        cbmiDrawSunBeams.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final ShowSunBeamCommand c = new ShowSunBeamCommand(d);
                d.setSunBeamVisible(cbmiDrawSunBeams.isSelected());
                d.drawSunBeam();
                d.draw();
                SceneManager.getInstance().refresh();
                SceneManager.getInstance().getUndoManager().addEdit(c);
                Scene.getInstance().setEdited(true);
            }
        });
        final JMenuItem miRimRadius = new JMenuItem("Rim Radius...");
        miRimRadius.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final Foundation foundation = d.getTopContainer();
                final String partInfo = d.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel inputPanel = new JPanel(new GridLayout(1, 2, 5, 5));
                gui.add(inputPanel, BorderLayout.CENTER);
                inputPanel.add(new JLabel("Rim Radius (m): "));
                final JTextField apertureRadiusField = new JTextField(threeDecimalsFormat.format(d.getRimRadius()));
                inputPanel.add(apertureRadiusField);
                inputPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
                final JPanel scopePanel = new JPanel();
                scopePanel.setLayout(new BoxLayout(scopePanel, BoxLayout.Y_AXIS));
                scopePanel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                scopePanel.add(rb1);
                scopePanel.add(rb2);
                scopePanel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                gui.add(scopePanel, BorderLayout.NORTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { "Set rim radius for " + partInfo, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Rim Radius");
                while (true) {
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        double r = 0;
                        boolean ok = true;
                        try {
                            r = Double.parseDouble(apertureRadiusField.getText());
                        } catch (final NumberFormatException x) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), "Invalid input!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (r < 1 || r > 10) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Parabolic dish rim radius must be between 1 and 10 m.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                boolean changed = Math.abs(r - d.getRimRadius()) > 0.000001;
                                if (rb1.isSelected()) {
                                    if (changed) {
                                        final SetPartSizeCommand c = new SetPartSizeCommand(d);
                                        d.setRimRadius(r);
                                        d.draw();
                                        SceneManager.getInstance().refresh();
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                            if (Math.abs(r - x.getRimRadius()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final SetRimRadiusForParabolicDishesOnFoundationCommand c = new SetRimRadiusForParabolicDishesOnFoundationCommand(foundation);
                                        foundation.setRimRadiusForParabolicDishes(r);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                            if (Math.abs(r - x.getRimRadius()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final SetRimRadiusForAllParabolicDishesCommand c = new SetRimRadiusForAllParabolicDishesCommand();
                                        Scene.getInstance().setRimRadiusForAllParabolicDishes(r);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 2;
                                }
                                if (changed) {
                                    updateAfterEdit();
                                }
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        final JMenuItem miFocalLength = new JMenuItem("Focal Length...");
        miFocalLength.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final Foundation foundation = d.getTopContainer();
                final String partInfo = d.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel inputPanel = new JPanel(new GridLayout(1, 2, 5, 5));
                gui.add(inputPanel, BorderLayout.CENTER);
                inputPanel.add(new JLabel("Focal Length (m): "));
                final JTextField focalLengthField = new JTextField(threeDecimalsFormat.format(d.getFocalLength()));
                inputPanel.add(focalLengthField);
                inputPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
                final JPanel scopePanel = new JPanel();
                scopePanel.setLayout(new BoxLayout(scopePanel, BoxLayout.Y_AXIS));
                scopePanel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                scopePanel.add(rb1);
                scopePanel.add(rb2);
                scopePanel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                gui.add(scopePanel, BorderLayout.NORTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { "Set focal length for " + partInfo, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Focal Length");
                while (true) {
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        double fl = 0;
                        boolean ok = true;
                        try {
                            fl = Double.parseDouble(focalLengthField.getText());
                        } catch (final NumberFormatException nfe) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), "Invalid input!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (fl < 0.5 || fl > 10) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Focal length must be between 0.5 and 10 m.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                boolean changed = Math.abs(fl - d.getFocalLength()) > 0.000001;
                                if (rb1.isSelected()) {
                                    if (changed) {
                                        final SetParabolicDishFocalLengthCommand c = new SetParabolicDishFocalLengthCommand(d);
                                        d.setFocalLength(fl);
                                        d.draw();
                                        SceneManager.getInstance().refresh();
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                            if (Math.abs(fl - x.getFocalLength()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final SetFocalLengthForParabolicDishesOnFoundationCommand c = new SetFocalLengthForParabolicDishesOnFoundationCommand(foundation);
                                        foundation.setFocalLengthForParabolicDishes(fl);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                            if (Math.abs(fl - x.getFocalLength()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final SetFocalLengthForAllParabolicDishesCommand c = new SetFocalLengthForAllParabolicDishesCommand();
                                        Scene.getInstance().setFocalLengthForAllParabolicDishes(fl);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 2;
                                }
                                if (changed) {
                                    updateAfterEdit();
                                }
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        final JMenuItem miBaseHeight = new JMenuItem("Base Height...");
        miBaseHeight.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final String partInfo = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final Foundation foundation = d.getTopContainer();
                final String title = "<html>Base Height (m) of " + partInfo + "</html>";
                final String footnote = "<html><hr><font size=2></html>";
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel panel = new JPanel();
                gui.add(panel, BorderLayout.CENTER);
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                panel.add(rb1);
                panel.add(rb2);
                panel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                final JTextField inputField = new JTextField(EnergyPanel.TWO_DECIMALS.format(d.getBaseHeight() * Scene.getInstance().getAnnotationScale()));
                gui.add(inputField, BorderLayout.SOUTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { title, footnote, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Base Height");
                while (true) {
                    inputField.selectAll();
                    inputField.requestFocusInWindow();
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        double val = 0;
                        boolean ok = true;
                        try {
                            val = Double.parseDouble(inputField.getText()) / Scene.getInstance().getAnnotationScale();
                        } catch (final NumberFormatException exception) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), inputField.getText() + " is an invalid value!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            boolean changed = Math.abs(val - d.getBaseHeight()) > 0.000001;
                            if (rb1.isSelected()) {
                                if (changed) {
                                    final ChangeBaseHeightCommand c = new ChangeBaseHeightCommand(d);
                                    d.setBaseHeight(val);
                                    d.draw();
                                    SceneManager.getInstance().refresh();
                                    SceneManager.getInstance().getUndoManager().addEdit(c);
                                }
                                selectedScopeIndex = 0;
                            } else if (rb2.isSelected()) {
                                if (!changed) {
                                    for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                        if (Math.abs(val - x.getBaseHeight()) > 0.000001) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeFoundationSolarCollectorBaseHeightCommand c = new ChangeFoundationSolarCollectorBaseHeightCommand(foundation, d.getClass());
                                    foundation.setBaseHeightForParabolicDishes(val);
                                    SceneManager.getInstance().getUndoManager().addEdit(c);
                                }
                                selectedScopeIndex = 1;
                            } else if (rb3.isSelected()) {
                                if (!changed) {
                                    for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                        if (Math.abs(val - x.getBaseHeight()) > 0.000001) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeBaseHeightForAllSolarCollectorsCommand c = new ChangeBaseHeightForAllSolarCollectorsCommand(d.getClass());
                                    Scene.getInstance().setBaseHeightForAllParabolicDishes(val);
                                    SceneManager.getInstance().getUndoManager().addEdit(c);
                                }
                                selectedScopeIndex = 2;
                            }
                            if (changed) {
                                updateAfterEdit();
                            }
                            if (choice == options[0]) {
                                break;
                            }
                        }
                    }
                }
            }
        });
        final JMenuItem miStructureType = new JMenuItem("Structure Type...");
        miStructureType.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final String partInfo = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final Foundation foundation = d.getTopContainer();
                final String title = "<html>Structure Type of " + partInfo + "</html>";
                final String footnote = "<html><hr><font size=2></html>";
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel panel = new JPanel();
                gui.add(panel, BorderLayout.CENTER);
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                panel.add(rb1);
                panel.add(rb2);
                panel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                final JComboBox<String> comboBox = new JComboBox<String>(new String[] { "Central Pole", "Tripod" });
                comboBox.setSelectedIndex(d.getStructureType());
                gui.add(comboBox, BorderLayout.SOUTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { title, footnote, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Structure Type");
                while (true) {
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        final int structureType = comboBox.getSelectedIndex();
                        boolean changed = structureType != d.getStructureType();
                        if (rb1.isSelected()) {
                            if (changed) {
                                final SetParabolicDishStructureTypeCommand c = new SetParabolicDishStructureTypeCommand(d);
                                d.setStructureType(structureType);
                                d.draw();
                                SceneManager.getInstance().refresh();
                                SceneManager.getInstance().getUndoManager().addEdit(c);
                            }
                            selectedScopeIndex = 0;
                        } else if (rb2.isSelected()) {
                            if (!changed) {
                                for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                    if (structureType != x.getStructureType()) {
                                        changed = true;
                                        break;
                                    }
                                }
                            }
                            if (changed) {
                                final ChangeFoundationParabolicDishStructureTypeCommand c = new ChangeFoundationParabolicDishStructureTypeCommand(foundation);
                                foundation.setStructureTypeForParabolicDishes(structureType);
                                SceneManager.getInstance().getUndoManager().addEdit(c);
                            }
                            selectedScopeIndex = 1;
                        } else if (rb3.isSelected()) {
                            if (!changed) {
                                for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                    if (structureType != x.getStructureType()) {
                                        changed = true;
                                        break;
                                    }
                                }
                            }
                            if (changed) {
                                final ChangeStructureTypeForAllParabolicDishesCommand c = new ChangeStructureTypeForAllParabolicDishesCommand();
                                Scene.getInstance().setStructureTypeForAllParabolicDishes(structureType);
                                SceneManager.getInstance().getUndoManager().addEdit(c);
                            }
                            selectedScopeIndex = 2;
                        }
                        if (changed) {
                            updateAfterEdit();
                        }
                        if (choice == options[0]) {
                            break;
                        }
                    }
                }
            }
        });
        final JMenu labelMenu = new JMenu("Label");
        final JCheckBoxMenuItem miLabelNone = new JCheckBoxMenuItem("None", true);
        miLabelNone.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                if (miLabelNone.isSelected()) {
                    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                    if (selectedPart instanceof ParabolicDish) {
                        final ParabolicDish d = (ParabolicDish) selectedPart;
                        final SetParabolicDishLabelCommand c = new SetParabolicDishLabelCommand(d);
                        d.clearLabels();
                        d.draw();
                        SceneManager.getInstance().getUndoManager().addEdit(c);
                        Scene.getInstance().setEdited(true);
                        SceneManager.getInstance().refresh();
                    }
                }
            }
        });
        labelMenu.add(miLabelNone);
        final JCheckBoxMenuItem miLabelCustom = new JCheckBoxMenuItem("Custom");
        miLabelCustom.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (selectedPart instanceof ParabolicDish) {
                    final ParabolicDish d = (ParabolicDish) selectedPart;
                    final SetParabolicDishLabelCommand c = new SetParabolicDishLabelCommand(d);
                    d.setLabelCustom(miLabelCustom.isSelected());
                    if (d.getLabelCustom()) {
                        d.setLabelCustomText(JOptionPane.showInputDialog(MainFrame.getInstance(), "Custom Text", d.getLabelCustomText()));
                    }
                    d.draw();
                    SceneManager.getInstance().getUndoManager().addEdit(c);
                    Scene.getInstance().setEdited(true);
                    SceneManager.getInstance().refresh();
                }
            }
        });
        labelMenu.add(miLabelCustom);
        final JCheckBoxMenuItem miLabelId = new JCheckBoxMenuItem("ID");
        miLabelId.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (selectedPart instanceof ParabolicDish) {
                    final ParabolicDish d = (ParabolicDish) selectedPart;
                    final SetParabolicDishLabelCommand c = new SetParabolicDishLabelCommand(d);
                    d.setLabelId(miLabelId.isSelected());
                    d.draw();
                    SceneManager.getInstance().getUndoManager().addEdit(c);
                    Scene.getInstance().setEdited(true);
                    SceneManager.getInstance().refresh();
                }
            }
        });
        labelMenu.add(miLabelId);
        final JCheckBoxMenuItem miLabelEnergyOutput = new JCheckBoxMenuItem("Energy Output");
        miLabelEnergyOutput.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (selectedPart instanceof ParabolicDish) {
                    final ParabolicDish d = (ParabolicDish) selectedPart;
                    final SetParabolicDishLabelCommand c = new SetParabolicDishLabelCommand(d);
                    d.setLabelEnergyOutput(miLabelEnergyOutput.isSelected());
                    d.draw();
                    SceneManager.getInstance().getUndoManager().addEdit(c);
                    Scene.getInstance().setEdited(true);
                    SceneManager.getInstance().refresh();
                }
            }
        });
        labelMenu.add(miLabelEnergyOutput);
        popupMenuForParabolicDish = createPopupMenu(true, true, new Runnable() {

            @Override
            public void run() {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final ParabolicDish d = (ParabolicDish) selectedPart;
                Util.selectSilently(miLabelNone, !d.isLabelVisible());
                Util.selectSilently(miLabelCustom, d.getLabelCustom());
                Util.selectSilently(miLabelId, d.getLabelId());
                Util.selectSilently(miLabelEnergyOutput, d.getLabelEnergyOutput());
                Util.selectSilently(cbmiDrawSunBeams, d.isSunBeamVisible());
                Util.selectSilently(cbmiDisableEditPoint, d.getLockEdit());
            }
        });
        final JMenuItem miReflectance = new JMenuItem("Mirror Reflectance...");
        miReflectance.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final String partInfo = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final String title = "<html>Reflectance (%) of " + partInfo + "</html>";
                final String footnote = "<html><hr><font size=2>Reflectance can be affected by pollen and dust.<hr></html>";
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel panel = new JPanel();
                gui.add(panel, BorderLayout.CENTER);
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                panel.add(rb1);
                panel.add(rb2);
                panel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                final JTextField inputField = new JTextField(EnergyPanel.TWO_DECIMALS.format(d.getReflectance() * 100));
                gui.add(inputField, BorderLayout.SOUTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { title, footnote, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Mirror Reflectance");
                while (true) {
                    inputField.selectAll();
                    inputField.requestFocusInWindow();
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        double val = 0;
                        boolean ok = true;
                        try {
                            val = Double.parseDouble(inputField.getText());
                        } catch (final NumberFormatException exception) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), inputField.getText() + " is an invalid value!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (val < 50 || val > 99) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Parabolic dish reflectance must be between 50% and 99%.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                boolean changed = Math.abs(val * 0.01 - d.getReflectance()) > 0.000001;
                                if (rb1.isSelected()) {
                                    if (changed) {
                                        final ChangeSolarReflectorReflectanceCommand c = new ChangeSolarReflectorReflectanceCommand(d);
                                        d.setReflectance(val * 0.01);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    final Foundation foundation = d.getTopContainer();
                                    if (!changed) {
                                        for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getReflectance()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeFoundationSolarReflectorReflectanceCommand c = new ChangeFoundationSolarReflectorReflectanceCommand(foundation, d.getClass());
                                        foundation.setReflectanceForSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getReflectance()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeReflectanceForAllSolarReflectorsCommand c = new ChangeReflectanceForAllSolarReflectorsCommand(d.getClass());
                                        Scene.getInstance().setReflectanceForAllSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 2;
                                }
                                if (changed) {
                                    updateAfterEdit();
                                }
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        final JMenuItem miAbsorptance = new JMenuItem("Receiver Absorptance...");
        miAbsorptance.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final String partInfo = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final String title = "<html>Absorptance (%) of " + partInfo + "</html>";
                final String footnote = "<html><hr><font size=2><hr></html>";
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel panel = new JPanel();
                gui.add(panel, BorderLayout.CENTER);
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                panel.add(rb1);
                panel.add(rb2);
                panel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                final JTextField inputField = new JTextField(EnergyPanel.TWO_DECIMALS.format(d.getAbsorptance() * 100));
                gui.add(inputField, BorderLayout.SOUTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { title, footnote, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Receiver Absorptance");
                while (true) {
                    inputField.selectAll();
                    inputField.requestFocusInWindow();
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        double val = 0;
                        boolean ok = true;
                        try {
                            val = Double.parseDouble(inputField.getText());
                        } catch (final NumberFormatException exception) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), inputField.getText() + " is an invalid value!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (val < 50 || val > 99) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Parabolic dish absorptance must be between 50% and 99%.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                boolean changed = Math.abs(val * 0.01 - d.getAbsorptance()) > 0.000001;
                                if (rb1.isSelected()) {
                                    if (changed) {
                                        final ChangeSolarReflectorAbsorptanceCommand c = new ChangeSolarReflectorAbsorptanceCommand(d);
                                        d.setAbsorptance(val * 0.01);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    final Foundation foundation = d.getTopContainer();
                                    if (!changed) {
                                        for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getAbsorptance()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeFoundationSolarReflectorAbsorptanceCommand c = new ChangeFoundationSolarReflectorAbsorptanceCommand(foundation, d.getClass());
                                        foundation.setAbsorptanceForSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getAbsorptance()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeAbsorptanceForAllSolarReflectorsCommand c = new ChangeAbsorptanceForAllSolarReflectorsCommand(d.getClass());
                                        Scene.getInstance().setAbsorptanceForAllSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 2;
                                }
                                if (changed) {
                                    updateAfterEdit();
                                }
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        final JMenuItem miOpticalEfficiency = new JMenuItem("Optical Efficiency...");
        miOpticalEfficiency.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final String partInfo = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final String title = "<html>Opitical efficiency (%) of " + partInfo + "</html>";
                final String footnote = "<html><hr><font size=2>For example, the percentage of the effective area for reflection after deducting<br>the area of facet gaps, module frames, absorber shadow, etc.<hr></html>";
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel panel = new JPanel();
                gui.add(panel, BorderLayout.CENTER);
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                panel.add(rb1);
                panel.add(rb2);
                panel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                final JTextField inputField = new JTextField(EnergyPanel.TWO_DECIMALS.format(d.getOpticalEfficiency() * 100));
                gui.add(inputField, BorderLayout.SOUTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { title, footnote, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Optical Efficiency");
                while (true) {
                    inputField.selectAll();
                    inputField.requestFocusInWindow();
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        double val = 0;
                        boolean ok = true;
                        try {
                            val = Double.parseDouble(inputField.getText());
                        } catch (final NumberFormatException exception) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), inputField.getText() + " is an invalid value!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (val < 50 || val > 100) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Parabolic dish optical efficiency must be between 50% and 100%.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                boolean changed = Math.abs(val * 0.01 - d.getOpticalEfficiency()) > 0.000001;
                                if (rb1.isSelected()) {
                                    if (changed) {
                                        final ChangeSolarReflectorOpticalEfficiencyCommand c = new ChangeSolarReflectorOpticalEfficiencyCommand(d);
                                        d.setOpticalEfficiency(val * 0.01);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    final Foundation foundation = d.getTopContainer();
                                    if (!changed) {
                                        for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getOpticalEfficiency()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeFoundationSolarReflectorOpticalEfficiencyCommand c = new ChangeFoundationSolarReflectorOpticalEfficiencyCommand(foundation, d.getClass());
                                        foundation.setOpticalEfficiencyForSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getOpticalEfficiency()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeOpticalEfficiencyForAllSolarReflectorsCommand c = new ChangeOpticalEfficiencyForAllSolarReflectorsCommand(d.getClass());
                                        Scene.getInstance().setOpticalEfficiencyForAllSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 2;
                                }
                                if (changed) {
                                    updateAfterEdit();
                                }
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        final JMenuItem miThermalEfficiency = new JMenuItem("Thermal Efficiency...");
        miThermalEfficiency.addActionListener(new ActionListener() {

            // remember the scope selection as the next action will likely be applied to the same scope
            private int selectedScopeIndex = 0;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (!(selectedPart instanceof ParabolicDish)) {
                    return;
                }
                final String partInfo = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
                final ParabolicDish d = (ParabolicDish) selectedPart;
                final String title = "<html>Thermal efficiency (%) of " + partInfo + "</html>";
                final String footnote = "<html><hr><font size=2><hr></html>";
                final JPanel gui = new JPanel(new BorderLayout());
                final JPanel panel = new JPanel();
                gui.add(panel, BorderLayout.CENTER);
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                final JRadioButton rb1 = new JRadioButton("Only this Parabolic Dish", true);
                final JRadioButton rb2 = new JRadioButton("All Parabolic Dishes on this Foundation");
                final JRadioButton rb3 = new JRadioButton("All Parabolic Dishes");
                panel.add(rb1);
                panel.add(rb2);
                panel.add(rb3);
                final ButtonGroup bg = new ButtonGroup();
                bg.add(rb1);
                bg.add(rb2);
                bg.add(rb3);
                switch(selectedScopeIndex) {
                    case 0:
                        rb1.setSelected(true);
                        break;
                    case 1:
                        rb2.setSelected(true);
                        break;
                    case 2:
                        rb3.setSelected(true);
                        break;
                }
                final JTextField inputField = new JTextField(EnergyPanel.TWO_DECIMALS.format(d.getThermalEfficiency() * 100));
                gui.add(inputField, BorderLayout.SOUTH);
                final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                final JOptionPane optionPane = new JOptionPane(new Object[] { title, footnote, gui }, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Parabolic Dish Thermal Efficiency");
                while (true) {
                    inputField.selectAll();
                    inputField.requestFocusInWindow();
                    dialog.setVisible(true);
                    final Object choice = optionPane.getValue();
                    if (choice == options[1] || choice == null) {
                        break;
                    } else {
                        double val = 0;
                        boolean ok = true;
                        try {
                            val = Double.parseDouble(inputField.getText());
                        } catch (final NumberFormatException exception) {
                            JOptionPane.showMessageDialog(MainFrame.getInstance(), inputField.getText() + " is an invalid value!", "Error", JOptionPane.ERROR_MESSAGE);
                            ok = false;
                        }
                        if (ok) {
                            if (val < 5 || val > 80) {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Parabolic dish thermal efficiency must be between 5% and 80%.", "Range Error", JOptionPane.ERROR_MESSAGE);
                            } else {
                                boolean changed = Math.abs(val * 0.01 - d.getThermalEfficiency()) > 0.000001;
                                if (rb1.isSelected()) {
                                    if (changed) {
                                        final ChangeSolarReflectorThermalEfficiencyCommand c = new ChangeSolarReflectorThermalEfficiencyCommand(d);
                                        d.setThermalEfficiency(val * 0.01);
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 0;
                                } else if (rb2.isSelected()) {
                                    final Foundation foundation = d.getTopContainer();
                                    if (!changed) {
                                        for (final ParabolicDish x : foundation.getParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getThermalEfficiency()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeFoundationSolarReflectorThermalEfficiencyCommand c = new ChangeFoundationSolarReflectorThermalEfficiencyCommand(foundation, d.getClass());
                                        foundation.setThermalEfficiencyForSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 1;
                                } else if (rb3.isSelected()) {
                                    if (!changed) {
                                        for (final ParabolicDish x : Scene.getInstance().getAllParabolicDishes()) {
                                            if (Math.abs(val * 0.01 - x.getThermalEfficiency()) > 0.000001) {
                                                changed = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (changed) {
                                        final ChangeThermalEfficiencyForAllSolarReflectorsCommand c = new ChangeThermalEfficiencyForAllSolarReflectorsCommand(d.getClass());
                                        Scene.getInstance().setThermalEfficiencyForAllSolarReflectors(val * 0.01, d.getClass());
                                        SceneManager.getInstance().getUndoManager().addEdit(c);
                                    }
                                    selectedScopeIndex = 2;
                                }
                                if (changed) {
                                    updateAfterEdit();
                                }
                                if (choice == options[0]) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        });
        popupMenuForParabolicDish.addSeparator();
        popupMenuForParabolicDish.add(cbmiDisableEditPoint);
        popupMenuForParabolicDish.add(cbmiDrawSunBeams);
        popupMenuForParabolicDish.add(labelMenu);
        popupMenuForParabolicDish.addSeparator();
        popupMenuForParabolicDish.add(miRimRadius);
        popupMenuForParabolicDish.add(miFocalLength);
        popupMenuForParabolicDish.add(miBaseHeight);
        popupMenuForParabolicDish.add(miStructureType);
        popupMenuForParabolicDish.addSeparator();
        popupMenuForParabolicDish.add(miReflectance);
        popupMenuForParabolicDish.add(miAbsorptance);
        popupMenuForParabolicDish.add(miOpticalEfficiency);
        popupMenuForParabolicDish.add(miThermalEfficiency);
        popupMenuForParabolicDish.addSeparator();
        popupMenuForParabolicDish.add(miMesh);
        popupMenuForParabolicDish.add(miRib);
        popupMenuForParabolicDish.addSeparator();
        JMenuItem mi = new JMenuItem("Daily Yield Analysis...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                if (EnergyPanel.getInstance().adjustCellSize()) {
                    return;
                }
                if (SceneManager.getInstance().getSelectedPart() instanceof ParabolicDish) {
                    new ParabolicDishDailyAnalysis().show();
                }
            }
        });
        popupMenuForParabolicDish.add(mi);
        mi = new JMenuItem("Annual Yield Analysis...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                if (EnergyPanel.getInstance().adjustCellSize()) {
                    return;
                }
                if (SceneManager.getInstance().getSelectedPart() instanceof ParabolicDish) {
                    new ParabolicDishAnnualAnalysis().show();
                }
            }
        });
        popupMenuForParabolicDish.add(mi);
    }
    return popupMenuForParabolicDish;
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) SetPartSizeCommand(org.concord.energy3d.undo.SetPartSizeCommand) ChangeSolarReflectorOpticalEfficiencyCommand(org.concord.energy3d.undo.ChangeSolarReflectorOpticalEfficiencyCommand) SetRibsForParabolicDishesOnFoundationCommand(org.concord.energy3d.undo.SetRibsForParabolicDishesOnFoundationCommand) ChangeBaseHeightForAllSolarCollectorsCommand(org.concord.energy3d.undo.ChangeBaseHeightForAllSolarCollectorsCommand) SetFocalLengthForParabolicDishesOnFoundationCommand(org.concord.energy3d.undo.SetFocalLengthForParabolicDishesOnFoundationCommand) BorderLayout(java.awt.BorderLayout) ChangeAbsorptanceForAllSolarReflectorsCommand(org.concord.energy3d.undo.ChangeAbsorptanceForAllSolarReflectorsCommand) ParabolicDishAnnualAnalysis(org.concord.energy3d.simulation.ParabolicDishAnnualAnalysis) Foundation(org.concord.energy3d.model.Foundation) LockEditPointsOnFoundationCommand(org.concord.energy3d.undo.LockEditPointsOnFoundationCommand) ChangeFoundationSolarReflectorThermalEfficiencyCommand(org.concord.energy3d.undo.ChangeFoundationSolarReflectorThermalEfficiencyCommand) SetParabolicDishStructureTypeCommand(org.concord.energy3d.undo.SetParabolicDishStructureTypeCommand) ChangeReflectanceForAllSolarReflectorsCommand(org.concord.energy3d.undo.ChangeReflectanceForAllSolarReflectorsCommand) HousePart(org.concord.energy3d.model.HousePart) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ChangeSolarReflectorAbsorptanceCommand(org.concord.energy3d.undo.ChangeSolarReflectorAbsorptanceCommand) ChangeFoundationParabolicDishStructureTypeCommand(org.concord.energy3d.undo.ChangeFoundationParabolicDishStructureTypeCommand) ActionListener(java.awt.event.ActionListener) ChangeFoundationSolarCollectorBaseHeightCommand(org.concord.energy3d.undo.ChangeFoundationSolarCollectorBaseHeightCommand) JDialog(javax.swing.JDialog) SetRimRadiusForAllParabolicDishesCommand(org.concord.energy3d.undo.SetRimRadiusForAllParabolicDishesCommand) ChangeStructureTypeForAllParabolicDishesCommand(org.concord.energy3d.undo.ChangeStructureTypeForAllParabolicDishesCommand) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) ChangeSolarReflectorReflectanceCommand(org.concord.energy3d.undo.ChangeSolarReflectorReflectanceCommand) BoxLayout(javax.swing.BoxLayout) JTextField(javax.swing.JTextField) ChangeFoundationSolarReflectorAbsorptanceCommand(org.concord.energy3d.undo.ChangeFoundationSolarReflectorAbsorptanceCommand) GridLayout(java.awt.GridLayout) SetParabolicDishRibsCommand(org.concord.energy3d.undo.SetParabolicDishRibsCommand) JMenuItem(javax.swing.JMenuItem) SetRimRadiusForParabolicDishesOnFoundationCommand(org.concord.energy3d.undo.SetRimRadiusForParabolicDishesOnFoundationCommand) LockEditPointsCommand(org.concord.energy3d.undo.LockEditPointsCommand) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) ShowSunBeamCommand(org.concord.energy3d.undo.ShowSunBeamCommand) ChangeBaseHeightCommand(org.concord.energy3d.undo.ChangeBaseHeightCommand) ChangeOpticalEfficiencyForAllSolarReflectorsCommand(org.concord.energy3d.undo.ChangeOpticalEfficiencyForAllSolarReflectorsCommand) SetParabolicDishLabelCommand(org.concord.energy3d.undo.SetParabolicDishLabelCommand) ParabolicDish(org.concord.energy3d.model.ParabolicDish) LockEditPointsForClassCommand(org.concord.energy3d.undo.LockEditPointsForClassCommand) ChangeFoundationSolarReflectorReflectanceCommand(org.concord.energy3d.undo.ChangeFoundationSolarReflectorReflectanceCommand) ChangeSolarReflectorThermalEfficiencyCommand(org.concord.energy3d.undo.ChangeSolarReflectorThermalEfficiencyCommand) ChangeFoundationSolarReflectorOpticalEfficiencyCommand(org.concord.energy3d.undo.ChangeFoundationSolarReflectorOpticalEfficiencyCommand) ParabolicDishDailyAnalysis(org.concord.energy3d.simulation.ParabolicDishDailyAnalysis) SetRibsForAllParabolicDishesCommand(org.concord.energy3d.undo.SetRibsForAllParabolicDishesCommand) ButtonGroup(javax.swing.ButtonGroup) ChangeThermalEfficiencyForAllSolarReflectorsCommand(org.concord.energy3d.undo.ChangeThermalEfficiencyForAllSolarReflectorsCommand) SetFocalLengthForAllParabolicDishesCommand(org.concord.energy3d.undo.SetFocalLengthForAllParabolicDishesCommand) ItemListener(java.awt.event.ItemListener) SetParabolicDishFocalLengthCommand(org.concord.energy3d.undo.SetParabolicDishFocalLengthCommand) JMenu(javax.swing.JMenu)

Example 2 with ParabolicDish

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

the class TimeSeriesLogger method record.

private void record() {
    final URL url = Scene.getURL();
    if (url == null) {
        return;
    }
    /* write the header */
    String filename = url == null ? null : new File(url.getFile()).getName();
    if (Scene.isInternalFile()) {
        filename = "@" + filename;
    }
    final Date time = Calendar.getInstance().getTime();
    final String timestamp = TIME_FORMAT.format(time);
    String line = "";
    if (Scene.getInstance().getProjectName() != null && !Scene.getInstance().getProjectName().trim().equals("")) {
        line += "\"Project\": \"" + Scene.getInstance().getProjectName() + "\", ";
    }
    line += "\"File\": \"" + filename + "\"";
    if (action != null) {
        if ((lastTime != null && Math.abs(time.getTime() - lastTime.getTime()) < MINIMUM_INTERVAL) && action.equals(lastAction)) {
            // don't log too frequently for the same type of action
            return;
        }
        HousePart actedPart = null;
        String stateValue = null;
        // special treatments
        if (action.equals("Undo")) {
            String s = SceneManager.getInstance().getUndoManager().getRedoPresentationName();
            if (s.length() >= 4) {
                s = s.substring(4, s.length()).trim();
            }
            stateValue = "\"" + s + "\"";
        } else if (action.equals("Redo")) {
            String s = SceneManager.getInstance().getUndoManager().getUndoPresentationName();
            if (s.length() >= 4) {
                s = s.substring(4, s.length()).trim();
            }
            stateValue = "\"" + s + "\"";
        } else if (action.equals("Save")) {
            // append * at the end so that the ng3 suffix is not interpreted as a delimiter
            stateValue = "\"" + Scene.getURL().toString() + "*\"";
        } else if (action.equals("Note")) {
            final String s = MainPanel.getInstance().getNoteString();
            if (s.length() > 0) {
                stateValue = "\"" + s + "\"";
                MainPanel.getInstance().setNoteString("");
            }
        } else if (action.equals("Camera")) {
            stateValue = "{" + cameraPosition + ", \"Mode\": \"" + cameraMode + "\"}";
        } else if (action.equals("Graph Tab")) {
            stateValue = "\"" + graphTabName + "\"";
        } else if (action.equals("Adjust Thermostat")) {
            final HousePart p = SceneManager.getInstance().getSelectedPart();
            if (p instanceof Foundation) {
                stateValue = "{\"Building\": " + p.getId() + "}";
            }
        } else if (action.equals("Show Curve")) {
            stateValue = "{\"Graph\": \"" + graphName + "\", \"Name\": \"" + curveName + "\", \"Shown\": " + curveShown + "}";
        } else if (action.equals("Show Run")) {
            stateValue = "{\"Graph\": \"" + graphName + "\", \"ID\": \"" + runID + "\", \"Shown\": " + runShown + "}";
        } else if (action.equals("Clear Graph Data")) {
            stateValue = "\"" + graphName + "\"";
        } else {
            /* everything else */
            final UndoableEdit lastEdit = SceneManager.getInstance().getUndoManager().lastEdit();
            if (lastEdit instanceof AddPartCommand) {
                actedPart = ((AddPartCommand) lastEdit).getPart();
            } else if (lastEdit instanceof AddMultiplePartsCommand) {
                final AddMultiplePartsCommand c = (AddMultiplePartsCommand) lastEdit;
                if (c.getURL() != null) {
                    stateValue = "{\"Import\": \"" + c.getURL() + "\"}";
                }
            } else if (lastEdit instanceof AddArrayCommand) {
                final AddArrayCommand c = (AddArrayCommand) lastEdit;
                final HousePart p = c.getParent();
                if (p instanceof Foundation) {
                    final Foundation f = (Foundation) p;
                    stateValue = "{\"Foundation\": " + f.getId() + ", \"Old Array Size\": " + c.getOldArray().size() + ", \"New Array Size\": " + f.countParts(c.getTypes()) + "}";
                } else if (p instanceof Rack) {
                    final Foundation f = p.getTopContainer();
                    stateValue = "{\"Foundation\": " + f.getId() + ", \"Rack\": " + p.getId() + ", \"Old Array Size\": " + c.getOldArray().size() + ", \"New Array Size\": " + p.getChildren().size() + "}";
                }
            } else if (lastEdit instanceof PastePartCommand) {
                actedPart = ((PastePartCommand) lastEdit).getPart();
                if (actedPart instanceof Foundation) {
                    stateValue = "{\"Building\": " + actedPart.getId() + "}";
                    // FIXME: work around a bug related to pasting a building, fix later
                    actedPart = null;
                }
            } else if (lastEdit instanceof EditPartCommand) {
                actedPart = ((EditPartCommand) lastEdit).getPart();
            } else if (lastEdit instanceof RemovePartCommand) {
                actedPart = ((RemovePartCommand) lastEdit).getPart();
            } else if (lastEdit instanceof RemoveMultiplePartsCommand) {
                final Foundation f = ((RemoveMultiplePartsCommand) lastEdit).getFoundation();
                if (f != null) {
                    stateValue = "{\"Building\": " + f.getId() + "}";
                }
            } else if (lastEdit instanceof RotateBuildingCommand) {
                final RotateBuildingCommand c = (RotateBuildingCommand) lastEdit;
                final Foundation f = c.getFoundation();
                if (f != null) {
                    stateValue = "{\"Building\": " + f.getId() + ", \"Angle\": " + Math.toDegrees(c.getRotationAngle()) + "}";
                } else {
                    stateValue = "{\"Angle\": " + Math.toDegrees(c.getRotationAngle()) + "}";
                }
            } else if (lastEdit instanceof RescaleBuildingCommand) {
                final RescaleBuildingCommand c = (RescaleBuildingCommand) lastEdit;
                final Foundation f = c.getFoundation();
                if (f != null) {
                    stateValue = "{\"Building\": " + f.getId();
                    stateValue += ", \"Old X Length\": " + c.getOldXLength() + ", \"New X Length\": " + c.getNewXLength();
                    stateValue += ", \"Old Y Length\": " + c.getOldYLength() + ", \"New Y Length\": " + c.getNewYLength();
                    stateValue += ", \"Old Z Length\": " + c.getOldZLength() + ", \"New Z Length\": " + c.getNewZLength();
                    stateValue += "}";
                }
            } else if (lastEdit instanceof MovePartCommand) {
                final MovePartCommand c = (MovePartCommand) lastEdit;
                final HousePart p = c.getPart();
                final Vector3 d = c.getDisplacement();
                final String s = "\"(" + d.getX() + ", " + d.getY() + ")\"";
                if (p != null) {
                    stateValue = "{\"Part\": " + p.getId() + ", \"Displacement\": " + s + "}";
                } else {
                    stateValue = "{\"Displacement\": " + s + "}";
                }
            } else if (lastEdit instanceof DeleteUtilityBillCommand) {
                final DeleteUtilityBillCommand c = (DeleteUtilityBillCommand) lastEdit;
                final Foundation f = c.getFoundation();
                stateValue = "{\"Building\": " + f.getId() + "}";
            } else if (lastEdit instanceof AnimateSunCommand) {
                stateValue = "" + ((AnimateSunCommand) lastEdit).getNewValue();
            } else if (lastEdit instanceof ShowShadowCommand) {
                stateValue = "" + ((ShowShadowCommand) lastEdit).getNewValue();
            } else if (lastEdit instanceof ShowHeatFluxCommand) {
                stateValue = "" + ((ShowHeatFluxCommand) lastEdit).getNewValue();
            } else if (lastEdit instanceof SpinViewCommand) {
                stateValue = "" + ((SpinViewCommand) lastEdit).getNewValue();
            } else if (lastEdit instanceof ShowAxesCommand) {
                stateValue = "" + ((ShowAxesCommand) lastEdit).getNewValue();
            } else if (lastEdit instanceof ShowAnnotationCommand) {
                stateValue = "" + ((ShowAnnotationCommand) lastEdit).getNewValue();
            } else if (lastEdit instanceof ShowHeliodonCommand) {
                stateValue = "" + ((ShowHeliodonCommand) lastEdit).getNewValue();
            } else if (lastEdit instanceof TopViewCommand) {
                stateValue = "" + (SceneManager.getInstance().getViewMode() == ViewMode.TOP_VIEW);
            } else if (lastEdit instanceof ZoomCommand) {
                stateValue = "" + ((ZoomCommand) lastEdit).getValue();
            } else if (lastEdit instanceof RescaleCommand) {
                final RescaleCommand c = (RescaleCommand) lastEdit;
                stateValue = "{\"Old Value\": " + c.getOldValue() + ", \"New Value\": " + Scene.getInstance().getAnnotationScale() + "}";
            } else if (lastEdit instanceof ChangeBackgroundAlbedoCommand) {
                final ChangeBackgroundAlbedoCommand c = (ChangeBackgroundAlbedoCommand) lastEdit;
                stateValue = "{\"Old Value\": " + c.getOldValue() + ", \"New Value\": " + Scene.getInstance().getGround().getAlbedo() + "}";
            } else if (lastEdit instanceof ChangeGroundThermalDiffusivityCommand) {
                final ChangeGroundThermalDiffusivityCommand c = (ChangeGroundThermalDiffusivityCommand) lastEdit;
                stateValue = "{\"Old Value\": " + c.getOldValue() + ", \"New Value\": " + Scene.getInstance().getGround().getThermalDiffusivity() + "}";
            } else if (lastEdit instanceof ChangeAtmosphericDustLossCommand) {
                final ChangeAtmosphericDustLossCommand c = (ChangeAtmosphericDustLossCommand) lastEdit;
                final double[] oldValues = c.getOldValue();
                String oldValueString = "\"";
                for (final double x : oldValues) {
                    oldValueString += x + " ";
                }
                oldValueString.trim();
                oldValueString += "\"";
                String newValueString = "\"";
                for (int i = 0; i < 12; i++) {
                    newValueString += Scene.getInstance().getAtmosphere().getDustLoss(i) + " ";
                }
                newValueString.trim();
                newValueString += "\"";
                stateValue = "{\"Old Values\": " + oldValueString + ", \"New Values\": " + newValueString + "}";
            } else if (lastEdit instanceof ChangeSnowReflectionFactorCommand) {
                final ChangeSnowReflectionFactorCommand c = (ChangeSnowReflectionFactorCommand) lastEdit;
                final double[] oldValues = c.getOldValue();
                String oldValueString = "\"";
                for (final double x : oldValues) {
                    oldValueString += x + " ";
                }
                oldValueString.trim();
                oldValueString += "\"";
                String newValueString = "\"";
                for (int i = 0; i < 12; i++) {
                    newValueString += Scene.getInstance().getGround().getSnowReflectionFactor(i) + " ";
                }
                newValueString.trim();
                newValueString += "\"";
                stateValue = "{\"Old Values\": " + oldValueString + ", \"New Values\": " + newValueString + "}";
            } else if (lastEdit instanceof ChangeSolarHeatMapColorContrastCommand) {
                final ChangeSolarHeatMapColorContrastCommand c = (ChangeSolarHeatMapColorContrastCommand) lastEdit;
                stateValue = "{\"Old Value\": " + c.getOldValue() + ", \"New Value\": " + Scene.getInstance().getSolarHeatMapColorContrast() + "}";
            } else if (lastEdit instanceof ChangeLatitudeCommand) {
                final ChangeLatitudeCommand c = (ChangeLatitudeCommand) lastEdit;
                stateValue = "{\"Old Value\": " + Math.round(Math.toDegrees(c.getOldValue())) + ", \"New Value\": " + Math.round(Math.toDegrees(Heliodon.getInstance().getLatitude())) + "}";
            } else if (lastEdit instanceof ChangeCityCommand) {
                final ChangeCityCommand c = (ChangeCityCommand) lastEdit;
                stateValue = "{\"Old City\": \"" + c.getOldValue() + "\", \"New City\": \"" + Scene.getInstance().getCity() + "\"}";
            } else if (lastEdit instanceof ChangeDateCommand) {
                final ChangeDateCommand c = (ChangeDateCommand) lastEdit;
                final Calendar calendar = new GregorianCalendar();
                calendar.setTime(c.getOldDate());
                stateValue = "{\"Old Date\": \"" + (calendar.get(Calendar.MONTH) + 1) + "/" + calendar.get(Calendar.DAY_OF_MONTH) + "\"";
                calendar.setTime(Scene.getInstance().getDate());
                stateValue += ", \"New Date\": \"" + (calendar.get(Calendar.MONTH) + 1) + "/" + calendar.get(Calendar.DAY_OF_MONTH) + "\"}";
            } else if (lastEdit instanceof ChangeTimeCommand) {
                final ChangeTimeCommand c = (ChangeTimeCommand) lastEdit;
                final Calendar cal0 = new GregorianCalendar();
                cal0.setTime(c.getOldTime());
                stateValue = "{\"Old Time\": \"" + (cal0.get(Calendar.HOUR_OF_DAY)) + ":" + cal0.get(Calendar.MINUTE) + "\"";
                final Calendar cal1 = Heliodon.getInstance().getCalendar();
                stateValue += ", \"New Time\": \"" + (cal1.get(Calendar.HOUR_OF_DAY)) + ":" + cal1.get(Calendar.MINUTE) + "\"}";
            } else if (lastEdit instanceof ChangeTimeAndDateWithHeliodonCommand) {
                final ChangeTimeAndDateWithHeliodonCommand c = (ChangeTimeAndDateWithHeliodonCommand) lastEdit;
                final Calendar oldCal = new GregorianCalendar();
                oldCal.setTime(c.getOldTime());
                final Calendar newCal = Heliodon.getInstance().getCalendar();
                stateValue = "{\"Old Time\": \"" + (oldCal.get(Calendar.HOUR_OF_DAY)) + ":" + oldCal.get(Calendar.MINUTE) + "\"";
                stateValue += ", \"New Time\": \"" + (newCal.get(Calendar.HOUR_OF_DAY)) + ":" + newCal.get(Calendar.MINUTE) + "\"";
                stateValue += ", \"Old Date\": \"" + (oldCal.get(Calendar.MONTH) + 1) + "/" + oldCal.get(Calendar.DAY_OF_MONTH) + "\"";
                stateValue += ", \"New Date\": \"" + (newCal.get(Calendar.MONTH) + 1) + "/" + newCal.get(Calendar.DAY_OF_MONTH) + "\"}";
            } else if (lastEdit instanceof ChangeBuildingTextureCommand) {
                stateValue = "{\"Old Value\": ";
                TextureMode textureMode = ((ChangeBuildingTextureCommand) lastEdit).getOldValue();
                if (textureMode == TextureMode.Full) {
                    stateValue += "\"Full\"";
                } else if (textureMode == TextureMode.Simple) {
                    stateValue += "\"Simple\"";
                } else if (textureMode == TextureMode.None) {
                    stateValue += "\"None\"";
                }
                stateValue += ", \"New Value\": ";
                textureMode = Scene.getInstance().getTextureMode();
                if (textureMode == TextureMode.Full) {
                    stateValue += "\"Full\"";
                } else if (textureMode == TextureMode.Simple) {
                    stateValue += "\"Simple\"";
                } else if (textureMode == TextureMode.None) {
                    stateValue += "\"None\"";
                }
                stateValue += "}";
            } else if (lastEdit instanceof ChangeThemeCommand) {
                stateValue = "{\"Old Value\": " + ((ChangeThemeCommand) lastEdit).getOldValue() + ", \"New Value\": " + Scene.getInstance().getTheme() + "}";
            } else if (lastEdit instanceof ChangeRoofOverhangCommand) {
                final ChangeRoofOverhangCommand c = (ChangeRoofOverhangCommand) lastEdit;
                final Roof r = c.getRoof();
                stateValue = "{\"Building\": " + r.getTopContainer().getId() + ", \"ID\": " + r.getId();
                stateValue += ", \"Old Value\": " + c.getOldValue() * Scene.getInstance().getAnnotationScale();
                stateValue += ", \"New Value\": " + r.getOverhangLength() * Scene.getInstance().getAnnotationScale() + "}";
            } else if (lastEdit instanceof ChangeFoundationSizeCommand) {
                final ChangeFoundationSizeCommand c = (ChangeFoundationSizeCommand) lastEdit;
                final Foundation f = c.getFoundation();
                stateValue = "{\"Foundation\": " + f.getId();
                stateValue += ", \"Old Length\": " + c.getOldLength();
                stateValue += ", \"New Length\": " + c.getNewLength();
                stateValue += ", \"Old Width\": " + c.getOldWidth();
                stateValue += ", \"New Width\": " + c.getNewWidth();
                stateValue += ", \"Old Height\": " + c.getOldHeight();
                stateValue += ", \"New Height\": " + c.getNewHeight() + "}";
            } else if (lastEdit instanceof AdjustThermostatCommand) {
                final Foundation f = ((AdjustThermostatCommand) lastEdit).getFoundation();
                stateValue = "{\"Building\":" + f.getId() + "}";
            } else if (lastEdit instanceof ChangePartColorCommand) {
                final ChangePartColorCommand c = (ChangePartColorCommand) lastEdit;
                final HousePart p = c.getPart();
                final Foundation f = p instanceof Foundation ? (Foundation) p : p.getTopContainer();
                stateValue = "{\"Building\": " + f.getId() + ", \"ID\": " + p.getId();
                stateValue += ", \"Type\": \"" + p.getClass().getSimpleName() + "\"";
                stateValue += ", \"Old Color\": \"" + Util.toString(c.getOldColor()) + "\", \"New Color\": \"" + Util.toString(p.getColor()) + "\"}";
            } else if (lastEdit instanceof ChangeContainerWindowColorCommand) {
                final ChangeContainerWindowColorCommand cmd = (ChangeContainerWindowColorCommand) lastEdit;
                final HousePart container = cmd.getContainer();
                final List<Window> windows = Scene.getInstance().getWindowsOnContainer(container);
                final String containerType = container instanceof Wall ? "Wall" : "Roof";
                stateValue = "{\"" + containerType + "\":" + container.getId() + ", \"New Color\": \"" + Util.toString(windows.get(0).getColor()) + "\"}";
            } else if (lastEdit instanceof ChangeBuildingColorCommand) {
                final ChangeBuildingColorCommand c = (ChangeBuildingColorCommand) lastEdit;
                final HousePart p = c.getPart();
                String s = "{\"Building\":" + c.getFoundation().getId();
                s += ", \"Type\": \"" + p.getClass().getSimpleName() + "\"";
                s += ", \"New Color\": \"" + Util.toString(p.getColor()) + "\"}";
                stateValue = s;
            } else if (lastEdit instanceof ChangeLandColorCommand) {
                final ChangeLandColorCommand c = (ChangeLandColorCommand) lastEdit;
                stateValue = "{\"Old Color\": \"" + Util.toString(c.getOldColor()) + "\", \"New Color\": \"" + Util.toString(Scene.getInstance().getLandColor()) + "\"}";
            } else if (lastEdit instanceof ChangePartUValueCommand) {
                final ChangePartUValueCommand c = (ChangePartUValueCommand) lastEdit;
                final HousePart p = c.getPart();
                if (p instanceof Thermal) {
                    final Foundation f = p instanceof Foundation ? (Foundation) p : p.getTopContainer();
                    stateValue = "{\"Building\":" + f.getId() + ", \"ID\":" + p.getId();
                    stateValue += ", \"Type\": \"" + p.getClass().getSimpleName() + "\"";
                    stateValue += ", \"Old Value\": " + c.getOldValue();
                    stateValue += ", \"New Value\": " + ((Thermal) p).getUValue() + "}";
                }
            } else if (lastEdit instanceof ChangeBuildingUValueCommand) {
                final ChangeBuildingUValueCommand c = (ChangeBuildingUValueCommand) lastEdit;
                final HousePart p = c.getPart();
                if (p instanceof Thermal) {
                    final Foundation f = p instanceof Foundation ? (Foundation) p : p.getTopContainer();
                    stateValue = "{\"Building\":" + f.getId();
                    stateValue += ", \"Type\": \"" + p.getClass().getSimpleName() + "\"";
                    stateValue += ", \"New Value\": " + ((Thermal) p).getUValue() + "}";
                }
            } else if (lastEdit instanceof ChangeVolumetricHeatCapacityCommand) {
                final ChangeVolumetricHeatCapacityCommand c = (ChangeVolumetricHeatCapacityCommand) lastEdit;
                final HousePart p = c.getPart();
                if (p instanceof Thermal) {
                    final Foundation f = p instanceof Foundation ? (Foundation) p : p.getTopContainer();
                    stateValue = "{\"Building\":" + f.getId() + ", \"ID\":" + p.getId();
                    stateValue += ", \"Type\": \"" + p.getClass().getSimpleName() + "\"";
                    stateValue += ", \"Old Value\": " + c.getOldValue();
                    stateValue += ", \"New Value\": " + ((Thermal) p).getVolumetricHeatCapacity() + "}";
                }
            } else if (lastEdit instanceof ChangeFoundationSolarCollectorBaseHeightCommand) {
                final ChangeFoundationSolarCollectorBaseHeightCommand c = (ChangeFoundationSolarCollectorBaseHeightCommand) lastEdit;
                stateValue = "{\"Foundation\": " + c.getFoundation().getId() + ", \"New Value\": " + c.getFirstSolarCollector().getBaseHeight() + "}";
            } else if (lastEdit instanceof ChangeBaseHeightForAllSolarCollectorsCommand) {
                final ChangeBaseHeightForAllSolarCollectorsCommand c = (ChangeBaseHeightForAllSolarCollectorsCommand) lastEdit;
                stateValue = "{\"New Value\": " + c.getFirstSolarCollector().getBaseHeight() + "}";
            } else if (lastEdit instanceof ChangeTiltAngleCommand) {
                final ChangeTiltAngleCommand c = (ChangeTiltAngleCommand) lastEdit;
                final HousePart p = c.getPart();
                stateValue = "{\"Foundation\": " + p.getTopContainer().getId() + ", \"ID\": " + p.getId() + ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + c.getNewValue() + "}";
            } else if (lastEdit instanceof ChangeAzimuthCommand) {
                final ChangeAzimuthCommand c = (ChangeAzimuthCommand) lastEdit;
                final HousePart p = c.getPart();
                stateValue = "{\"Foundation\": " + (p instanceof Foundation ? (Foundation) p : p.getTopContainer()).getId() + ", \"ID\": " + p.getId() + ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + c.getNewValue() + "}";
            } else if (lastEdit instanceof ChangeBaseHeightCommand) {
                final ChangeBaseHeightCommand c = (ChangeBaseHeightCommand) lastEdit;
                final SolarCollector s = c.getPart();
                if (s instanceof HousePart) {
                    final HousePart p = (HousePart) s;
                    stateValue = "{\"Foundation\": " + p.getTopContainer().getId() + ", \"ID\": " + p.getId() + ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + c.getNewValue() + "}";
                }
            } else if (lastEdit instanceof SetPartSizeCommand) {
                final SetPartSizeCommand c = (SetPartSizeCommand) lastEdit;
                if (c.getPart() instanceof Mirror) {
                    final Mirror m = (Mirror) c.getPart();
                    stateValue = "{\"Foundation\": " + m.getTopContainer().getId() + ", \"ID\": " + m.getId();
                    stateValue += ", \"Old Width\": " + c.getOldWidth() + ", \"New Width\": " + m.getMirrorWidth();
                    stateValue += ", \"Old Height\": " + c.getOldHeight() + ", \"New Height\": " + m.getMirrorHeight() + "}";
                } else if (c.getPart() instanceof ParabolicDish) {
                    final ParabolicDish d = (ParabolicDish) c.getPart();
                    stateValue = "{\"Foundation\": " + d.getTopContainer().getId() + ", \"ID\": " + d.getId();
                    stateValue += ", \"Old Rim Radius\": " + c.getOldWidth() + ", \"New Rim Radius\": " + d.getRimRadius() + "}";
                } else if (c.getPart() instanceof ParabolicTrough) {
                    final ParabolicTrough t = (ParabolicTrough) c.getPart();
                    stateValue = "{\"Foundation\": " + t.getTopContainer().getId() + ", \"ID\": " + t.getId();
                    stateValue += ", \"Old Aperture\": " + c.getOldWidth() + ", \"New Aperture\": " + t.getApertureWidth();
                    stateValue += ", \"Old Length\": " + c.getOldHeight() + ", \"New Length\": " + t.getTroughLength();
                    stateValue += ", \"Old Module Length\": " + c.getOldModuleLength() + ", \"New Module Length\": " + t.getModuleLength() + "}";
                } else if (c.getPart() instanceof FresnelReflector) {
                    final FresnelReflector t = (FresnelReflector) c.getPart();
                    stateValue = "{\"Foundation\": " + t.getTopContainer().getId() + ", \"ID\": " + t.getId();
                    stateValue += ", \"Old Module Width\": " + c.getOldWidth() + ", \"New Module Width\": " + t.getModuleWidth();
                    stateValue += ", \"Old Length\": " + c.getOldHeight() + ", \"New Length\": " + t.getLength();
                    stateValue += ", \"Old Module Length\": " + c.getOldModuleLength() + ", \"New Module Length\": " + t.getModuleLength() + "}";
                } else if (c.getPart() instanceof Rack) {
                    final Rack r = (Rack) c.getPart();
                    stateValue = "{\"Foundation\": " + r.getTopContainer().getId() + ", \"ID\": " + r.getId();
                    stateValue += ", \"Old Width\": " + c.getOldWidth() + ", \"New Width\": " + r.getRackWidth();
                    stateValue += ", \"Old Height\": " + c.getOldHeight() + ", \"New Height\": " + r.getRackHeight() + "}";
                } else if (c.getPart() instanceof Window) {
                    final Window r = (Window) c.getPart();
                    stateValue = "{\"Foundation\": " + r.getTopContainer().getId() + ", \"ID\": " + r.getId();
                    stateValue += ", \"Old Width\": " + c.getOldWidth() + ", \"New Width\": " + r.getWindowWidth();
                    stateValue += ", \"Old Height\": " + c.getOldHeight() + ", \"New Height\": " + r.getWindowHeight() + "}";
                }
            } else if (lastEdit instanceof ChangeSolarPanelModelCommand) {
                final ChangeSolarPanelModelCommand c = (ChangeSolarPanelModelCommand) lastEdit;
                final SolarPanel sp = c.getSolarPanel();
                stateValue = "{\"Foundation\": " + sp.getTopContainer().getId() + ", \"ID\": " + sp.getId();
                stateValue += ", \"Old Model\": \"" + c.getOldModel().getModel() + "\", \"New Model\": \"" + sp.getPvModuleSpecs().getModel() + "\"}";
            } else if (lastEdit instanceof ChooseSolarPanelSizeCommand) {
                final ChooseSolarPanelSizeCommand c = (ChooseSolarPanelSizeCommand) lastEdit;
                final SolarPanel sp = c.getSolarPanel();
                stateValue = "{\"Foundation\": " + sp.getTopContainer().getId() + ", \"ID\": " + sp.getId();
                stateValue += ", \"Old Width\": " + c.getOldWidth() + ", \"New Width\": " + sp.getPanelWidth();
                stateValue += ", \"Old Height\": " + c.getOldHeight() + ", \"New Height\": " + sp.getPanelHeight() + "}";
            } else if (lastEdit instanceof RotateSolarPanelCommand) {
                final RotateSolarPanelCommand c = (RotateSolarPanelCommand) lastEdit;
                final SolarPanel sp = c.getSolarPanel();
                stateValue = "{\"Foundation\": " + sp.getTopContainer().getId() + ", \"ID\": " + sp.getId() + ", \"New Value\": " + sp.isRotated() + "}";
            } else if (lastEdit instanceof ChangeSolarCellPropertiesCommand) {
                final ChangeSolarCellPropertiesCommand c = (ChangeSolarCellPropertiesCommand) lastEdit;
                final SolarPanel sp = c.getSolarPanel();
                stateValue = "{\"Foundation\": " + sp.getTopContainer().getId() + ", \"ID\": " + sp.getId();
                stateValue += ", \"Old Efficiency\": " + c.getOldEfficiency() + ", \"New Efficiency\": " + sp.getCellEfficiency();
                stateValue += ", \"Old Type\": " + c.getOldType() + ", \"New Type\": " + sp.getCellType();
                stateValue += ", \"Old Color\": " + c.getOldColor() + ", \"New Color\": " + sp.getColorOption();
                stateValue += "}";
            } else if (lastEdit instanceof ChangeFoundationSolarCellPropertiesCommand) {
                final Foundation f = ((ChangeFoundationSolarCellPropertiesCommand) lastEdit).getFoundation();
                final List<SolarPanel> solarPanels = f.getSolarPanels();
                if (solarPanels.isEmpty()) {
                    stateValue = "{\"Foundation\": " + f.getId() + "}";
                } else {
                    final SolarPanel p = solarPanels.get(0);
                    stateValue = "{\"Foundation\": " + f.getId() + ", \"New Efficiency\": " + p.getCellEfficiency();
                    stateValue += ", \"New Type\": " + p.getCellType();
                    stateValue += ", \"New Color\": " + p.getColorOption() + "}";
                }
            } else if (lastEdit instanceof ChangeSolarCellPropertiesForAllCommand) {
                final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                if (solarPanels.isEmpty()) {
                    stateValue = "{}";
                } else {
                    final SolarPanel p = solarPanels.get(0);
                    stateValue = "{\"New Efficiency\": " + p.getCellEfficiency();
                    stateValue += ", \"New Type\": " + p.getCellType();
                    stateValue += ", \"New Color\": " + p.getColorOption() + "}";
                }
            } else if (lastEdit instanceof SetTemperatureEffectsCommand) {
                final SetTemperatureEffectsCommand c = (SetTemperatureEffectsCommand) lastEdit;
                final SolarPanel sp = c.getSolarPanel();
                stateValue = "{\"Foundation\": " + sp.getTopContainer().getId() + ", \"ID\": " + sp.getId() + ", \"Old Noct\": " + c.getOldNoct() + ", \"New Noct\": " + sp.getNominalOperatingCellTemperature() + ", \"Old Pmax\": " + c.getOldPmax() + ", \"New Pmax\": " + sp.getTemperatureCoefficientPmax() + "}";
            } else if (lastEdit instanceof SetFoundationTemperatureEffectsCommand) {
                final Foundation f = ((SetFoundationTemperatureEffectsCommand) lastEdit).getFoundation();
                final List<SolarPanel> solarPanels = f.getSolarPanels();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Pmax\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getTemperatureCoefficientPmax()) + "}";
            } else if (lastEdit instanceof SetTemperatrureEffectsForAllCommand) {
                final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                stateValue = "{\"New Pmax\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getTemperatureCoefficientPmax()) + "}";
            } else if (lastEdit instanceof ChangeInverterEfficiencyCommand) {
                final ChangeInverterEfficiencyCommand c = (ChangeInverterEfficiencyCommand) lastEdit;
                final SolarPanel sp = c.getSolarPanel();
                stateValue = "{\"Foundation\": " + sp.getTopContainer().getId() + ", \"ID\": " + sp.getId() + ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + sp.getInverterEfficiency() + "}";
            } else if (lastEdit instanceof ChangeFoundationInverterEfficiencyCommand) {
                final Foundation f = ((ChangeFoundationInverterEfficiencyCommand) lastEdit).getFoundation();
                final List<SolarPanel> solarPanels = f.getSolarPanels();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getInverterEfficiency()) + "}";
            } else if (lastEdit instanceof ChangeInverterEfficiencyForAllCommand) {
                final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                stateValue = "{\"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getInverterEfficiency()) + "}";
            } else if (lastEdit instanceof SetShadeToleranceCommand) {
                final SetShadeToleranceCommand c = (SetShadeToleranceCommand) lastEdit;
                final SolarPanel sp = c.getSolarPanel();
                stateValue = "{\"Foundation\": " + sp.getTopContainer().getId() + ", \"ID\": " + sp.getId() + ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + sp.getShadeTolerance() + "}";
            } else if (lastEdit instanceof SetShadeToleranceForSolarPanelsOnFoundationCommand) {
                final SetShadeToleranceForSolarPanelsOnFoundationCommand c = (SetShadeToleranceForSolarPanelsOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<SolarPanel> solarPanels = f.getSolarPanels();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getShadeTolerance()) + "}";
            } else if (lastEdit instanceof SetShadeToleranceForAllSolarPanelsCommand) {
                final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                stateValue = "{\"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getShadeTolerance()) + "}";
            } else if (lastEdit instanceof ChangeFoundationSolarPanelTiltAngleCommand) {
                final Foundation f = ((ChangeFoundationSolarPanelTiltAngleCommand) lastEdit).getFoundation();
                final List<SolarPanel> solarPanels = f.getSolarPanels();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getTiltAngle()) + "}";
            } else if (lastEdit instanceof ChangeTiltAngleForAllSolarPanelsCommand) {
                final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                stateValue = "{\"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getTiltAngle()) + "}";
            } else if (lastEdit instanceof ChangeFoundationSolarPanelAzimuthCommand) {
                final Foundation f = ((ChangeFoundationSolarPanelAzimuthCommand) lastEdit).getFoundation();
                final List<SolarPanel> solarPanels = f.getSolarPanels();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getRelativeAzimuth()) + "}";
            } else if (lastEdit instanceof ChangeAzimuthForAllSolarPanelsCommand) {
                final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                stateValue = "{\"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getRelativeAzimuth()) + "}";
            } else if (lastEdit instanceof ChangeFoundationSolarPanelModelCommand) {
                final Foundation f = ((ChangeFoundationSolarPanelModelCommand) lastEdit).getFoundation();
                final List<SolarPanel> solarPanels = f.getSolarPanels();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Model\": " + (solarPanels.isEmpty() ? null : "\"" + solarPanels.get(0).getPvModuleSpecs().getModel() + "\"") + "}";
            } else if (lastEdit instanceof ChangeModelForAllSolarPanelsCommand) {
                final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                stateValue = "{\"New Model\": " + (solarPanels.isEmpty() ? null : "\"" + solarPanels.get(0).getPvModuleSpecs().getModel() + "\"") + "}";
            } else if (lastEdit instanceof ChangeSolarPanelModelForRackCommand) {
                final ChangeSolarPanelModelForRackCommand c = (ChangeSolarPanelModelForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Model\": \"" + c.getOldModel().getModel() + "\", \"New Model\": \"" + rack.getSolarPanel().getPvModuleSpecs().getModel() + "\"}";
            } else if (lastEdit instanceof ChangeSolarPanelModelForRacksOnFoundationCommand) {
                final Foundation f = ((ChangeSolarPanelModelForRacksOnFoundationCommand) lastEdit).getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Model\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getPvModuleSpecs().getModel() + "\"") + "}";
            } else if (lastEdit instanceof ChangeSolarPanelModelForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Model\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getPvModuleSpecs().getModel() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarCellEfficiencyForRackCommand) {
                final SetSolarCellEfficiencyForRackCommand c = (SetSolarCellEfficiencyForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Value\": \"" + c.getOldValue() + "\", \"New Value\": \"" + rack.getSolarPanel().getCellEfficiency() + "\"}";
            } else if (lastEdit instanceof SetSolarCellEfficiencyForRacksOnFoundationCommand) {
                final SetSolarCellEfficiencyForRacksOnFoundationCommand c = (SetSolarCellEfficiencyForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getCellEfficiency() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarCellEfficiencyForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getCellEfficiency() + "\"") + "}";
            } else if (lastEdit instanceof SetNoctForRackCommand) {
                final SetNoctForRackCommand c = (SetNoctForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Value\": \"" + c.getOldValue() + "\", \"New Value\": \"" + rack.getSolarPanel().getNominalOperatingCellTemperature() + "\"}";
            } else if (lastEdit instanceof SetNoctForRacksOnFoundationCommand) {
                final SetNoctForRacksOnFoundationCommand c = (SetNoctForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getNominalOperatingCellTemperature() + "\"") + "}";
            } else if (lastEdit instanceof SetNoctForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getNominalOperatingCellTemperature() + "\"") + "}";
            } else if (lastEdit instanceof SetTemperatureCoefficientPmaxForRackCommand) {
                final SetTemperatureCoefficientPmaxForRackCommand c = (SetTemperatureCoefficientPmaxForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Value\": \"" + c.getOldValue() + "\", \"New Value\": \"" + rack.getSolarPanel().getTemperatureCoefficientPmax() + "\"}";
            } else if (lastEdit instanceof SetTemperatureCoefficientPmaxForRacksOnFoundationCommand) {
                final SetTemperatureCoefficientPmaxForRacksOnFoundationCommand c = (SetTemperatureCoefficientPmaxForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getTemperatureCoefficientPmax() + "\"") + "}";
            } else if (lastEdit instanceof SetTemperatureCoefficientPmaxForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getTemperatureCoefficientPmax() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarPanelCellTypeForRackCommand) {
                final SetSolarPanelCellTypeForRackCommand c = (SetSolarPanelCellTypeForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Type\": \"" + c.getOldValue() + "\", \"New Type\": \"" + rack.getSolarPanel().getCellType() + "\"}";
            } else if (lastEdit instanceof SetSolarPanelCellTypeForRacksOnFoundationCommand) {
                final SetSolarPanelCellTypeForRacksOnFoundationCommand c = (SetSolarPanelCellTypeForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Type\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getCellType() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarPanelCellTypeForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Type\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getCellType() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarPanelShadeToleranceForRackCommand) {
                final SetSolarPanelShadeToleranceForRackCommand c = (SetSolarPanelShadeToleranceForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Value\": \"" + c.getOldValue() + "\", \"New Value\": \"" + rack.getSolarPanel().getShadeTolerance() + "\"}";
            } else if (lastEdit instanceof SetSolarPanelShadeToleranceForRacksOnFoundationCommand) {
                final SetSolarPanelShadeToleranceForRacksOnFoundationCommand c = (SetSolarPanelShadeToleranceForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getShadeTolerance() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarPanelShadeToleranceForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getShadeTolerance() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarPanelColorForRackCommand) {
                final SetSolarPanelColorForRackCommand c = (SetSolarPanelColorForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Color\": \"" + c.getOldValue() + "\", \"New Color\": \"" + rack.getSolarPanel().getColorOption() + "\"}";
            } else if (lastEdit instanceof SetSolarPanelColorForRacksOnFoundationCommand) {
                final SetSolarPanelColorForRacksOnFoundationCommand c = (SetSolarPanelColorForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Color\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getColorOption() + "\"") + "}";
            } else if (lastEdit instanceof SetSolarPanelColorForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Color\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getColorOption() + "\"") + "}";
            } else if (lastEdit instanceof ChooseSolarPanelSizeForRackCommand) {
                final ChooseSolarPanelSizeForRackCommand c = (ChooseSolarPanelSizeForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Width\": " + c.getOldWidth() + ", \"New Width\": " + rack.getSolarPanel().getPanelWidth();
                stateValue += ", \"Old Height\": " + c.getOldHeight() + ", \"New Height\": " + rack.getSolarPanel().getPanelHeight() + "}";
            } else if (lastEdit instanceof SetSizeForRacksOnFoundationCommand) {
                final Foundation f = ((SetSizeForRacksOnFoundationCommand) lastEdit).getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Width\": " + (racks.isEmpty() ? -1 : racks.get(0).getRackWidth()) + ", \"New Height\": " + (racks.isEmpty() ? -1 : racks.get(0).getRackHeight()) + "}";
            } else if (lastEdit instanceof SetSizeForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Width\": " + (racks.isEmpty() ? -1 : racks.get(0).getRackWidth()) + ", \"New Height\": " + (racks.isEmpty() ? -1 : racks.get(0).getRackHeight()) + "}";
            } else if (lastEdit instanceof RotateSolarPanelsForRackCommand) {
                final RotateSolarPanelsForRackCommand c = (RotateSolarPanelsForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Value\": \"" + c.getOldValue() + "\", \"New Value\": \"" + rack.getSolarPanel().isRotated() + "\"}";
            } else if (lastEdit instanceof RotateSolarPanelsForRacksOnFoundationCommand) {
                final RotateSolarPanelsForRacksOnFoundationCommand c = (RotateSolarPanelsForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().isRotated() + "\"") + "}";
            } else if (lastEdit instanceof RotateSolarPanelsForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().isRotated() + "\"") + "}";
            } else if (lastEdit instanceof SetInverterEfficiencyForRackCommand) {
                final SetInverterEfficiencyForRackCommand c = (SetInverterEfficiencyForRackCommand) lastEdit;
                final Rack rack = c.getRack();
                stateValue = "{\"Foundation\": " + rack.getTopContainer().getId() + ", \"ID\": " + rack.getId();
                stateValue += ", \"Old Value\": \"" + c.getOldValue() + "\", \"New Value\": \"" + rack.getSolarPanel().getInverterEfficiency() + "\"}";
            } else if (lastEdit instanceof SetInverterEfficiencyForRacksOnFoundationCommand) {
                final SetInverterEfficiencyForRacksOnFoundationCommand c = (SetInverterEfficiencyForRacksOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getInverterEfficiency() + "\"") + "}";
            } else if (lastEdit instanceof SetInverterEfficiencyForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? null : "\"" + racks.get(0).getSolarPanel().getInverterEfficiency() + "\"") + "}";
            } else if (lastEdit instanceof ChangeFoundationRackTiltAngleCommand) {
                final Foundation f = ((ChangeFoundationRackTiltAngleCommand) lastEdit).getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? -1 : racks.get(0).getTiltAngle()) + "}";
            } else if (lastEdit instanceof ChangeTiltAngleForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? -1 : racks.get(0).getTiltAngle()) + "}";
            } else if (lastEdit instanceof ChangeFoundationRackAzimuthCommand) {
                final Foundation f = ((ChangeFoundationRackAzimuthCommand) lastEdit).getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? -1 : racks.get(0).getRelativeAzimuth()) + "}";
            } else if (lastEdit instanceof ChangeAzimuthForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Value\": " + (racks.isEmpty() ? -1 : racks.get(0).getRelativeAzimuth()) + "}";
            } else if (lastEdit instanceof SetSolarPanelSizeForRacksOnFoundationCommand) {
                final Foundation f = ((SetSolarPanelSizeForRacksOnFoundationCommand) lastEdit).getFoundation();
                final List<Rack> racks = f.getRacks();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Width\": " + (racks.isEmpty() ? -1 : racks.get(0).getSolarPanel().getPanelWidth()) + ", \"New Height\": " + (racks.isEmpty() ? -1 : racks.get(0).getSolarPanel().getPanelHeight()) + "}";
            } else if (lastEdit instanceof SetSolarPanelSizeForAllRacksCommand) {
                final List<Rack> racks = Scene.getInstance().getAllRacks();
                stateValue = "{\"New Width\": " + (racks.isEmpty() ? -1 : racks.get(0).getSolarPanel().getPanelWidth()) + ", \"New Height\": " + (racks.isEmpty() ? -1 : racks.get(0).getSolarPanel().getPanelHeight()) + "}";
            } else if (lastEdit instanceof SetSolarTrackerCommand) {
                final SetSolarTrackerCommand c = (SetSolarTrackerCommand) lastEdit;
                final Trackable tracker = c.getTracker();
                long bid = -1;
                long cid = -1;
                if (tracker instanceof HousePart) {
                    bid = ((HousePart) tracker).getTopContainer().getId();
                    cid = ((HousePart) tracker).getId();
                }
                stateValue = "{\"Foundation\": " + bid + ", \"ID\": " + cid + ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + tracker.getTracker() + "}";
            } else if (lastEdit instanceof SetSolarTrackersOnFoundationCommand) {
                final SetSolarTrackersOnFoundationCommand c = (SetSolarTrackersOnFoundationCommand) lastEdit;
                final Foundation f = c.getFoundation();
                final Trackable tracker = c.getTracker();
                if (tracker instanceof SolarPanel) {
                    final List<SolarPanel> solarPanels = f.getSolarPanels();
                    stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getTracker()) + "}";
                } else if (tracker instanceof Rack) {
                    final List<Rack> racks = f.getRacks();
                    stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (racks.isEmpty() ? -1 : racks.get(0).getTracker()) + "}";
                }
            } else if (lastEdit instanceof SetSolarTrackersForAllCommand) {
                final SetSolarTrackersForAllCommand c = (SetSolarTrackersForAllCommand) lastEdit;
                final Trackable tracker = c.getTracker();
                if (tracker instanceof SolarPanel) {
                    final List<SolarPanel> solarPanels = Scene.getInstance().getAllSolarPanels();
                    stateValue = "{\"New Value\": " + (solarPanels.isEmpty() ? -1 : solarPanels.get(0).getTracker()) + "}";
                } else if (tracker instanceof Rack) {
                    final List<Rack> racks = Scene.getInstance().getAllRacks();
                    stateValue = "{\"New Value\": " + (racks.isEmpty() ? -1 : racks.get(0).getTracker()) + "}";
                }
            } else if (lastEdit instanceof SetSizeForHeliostatsOnFoundationCommand) {
                final Foundation f = ((SetSizeForHeliostatsOnFoundationCommand) lastEdit).getFoundation();
                final List<Mirror> mirrors = f.getHeliostats();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Width\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getMirrorWidth()) + ", \"New Height\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getMirrorHeight()) + "}";
            } else if (lastEdit instanceof SetSizeForAllHeliostatsCommand) {
                final List<Mirror> mirrors = Scene.getInstance().getAllHeliostats();
                stateValue = "{\"New Width\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getMirrorWidth()) + ", \"New Height\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getMirrorHeight()) + "}";
            } else if (lastEdit instanceof ChangeHeliostatTargetCommand) {
                final ChangeHeliostatTargetCommand c = (ChangeHeliostatTargetCommand) lastEdit;
                final Mirror m = c.getMirror();
                stateValue = "{\"Foundation\": " + m.getTopContainer().getId() + ", \"ID\": " + m.getId();
                stateValue += ", \"Old Value\": " + (c.getOldValue() == null ? -1 : c.getOldValue().getId()) + ", \"New Value\": " + (c.getNewValue() == null ? -1 : c.getNewValue().getId()) + "}";
            } else if (lastEdit instanceof ChangeFoundationHeliostatTargetCommand) {
                final Foundation f = ((ChangeFoundationHeliostatTargetCommand) lastEdit).getFoundation();
                final List<Mirror> mirrors = f.getHeliostats();
                long newValue = -1;
                if (!mirrors.isEmpty()) {
                    final Foundation t = mirrors.get(0).getReceiver();
                    if (t != null) {
                        newValue = t.getId();
                    }
                }
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + newValue + "}";
            } else if (lastEdit instanceof ChangeTargetForAllHeliostatsCommand) {
                final List<Mirror> mirrors = Scene.getInstance().getAllHeliostats();
                long newValue = -1;
                if (!mirrors.isEmpty()) {
                    final Foundation t = mirrors.get(0).getReceiver();
                    if (t != null) {
                        newValue = t.getId();
                    }
                }
                stateValue = "{\"New Value\": " + newValue + "}";
            } else if (lastEdit instanceof ChangeFoundationHeliostatTiltAngleCommand) {
                final Foundation f = ((ChangeFoundationHeliostatTiltAngleCommand) lastEdit).getFoundation();
                final List<Mirror> mirrors = f.getHeliostats();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getTiltAngle()) + "}";
            } else if (lastEdit instanceof ChangeTiltAngleForAllHeliostatsCommand) {
                final List<Mirror> mirrors = Scene.getInstance().getAllHeliostats();
                stateValue = "{\"New Value\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getTiltAngle()) + "}";
            } else if (lastEdit instanceof ChangeFoundationHeliostatAzimuthCommand) {
                final Foundation f = ((ChangeFoundationHeliostatAzimuthCommand) lastEdit).getFoundation();
                final List<Mirror> mirrors = f.getHeliostats();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getRelativeAzimuth()) + "}";
            } else if (lastEdit instanceof ChangeAzimuthForAllHeliostatsCommand) {
                final List<Mirror> mirrors = Scene.getInstance().getAllHeliostats();
                stateValue = "{\"New Value\": " + (mirrors.isEmpty() ? -1 : mirrors.get(0).getRelativeAzimuth()) + "}";
            } else if (lastEdit instanceof SetShapeForParabolicTroughsOnFoundationCommand) {
                final Foundation f = ((SetShapeForParabolicTroughsOnFoundationCommand) lastEdit).getFoundation();
                final List<ParabolicTrough> troughs = f.getParabolicTroughs();
                final ParabolicTrough t = troughs.isEmpty() ? null : troughs.get(0);
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Aperture Width\": " + (t == null ? -1 : t.getApertureWidth()) + ", \"New Length\": " + (t == null ? -1 : t.getTroughLength()) + ", \"New Module Length\": " + (t == null ? -1 : t.getModuleLength()) + ", \"New Semilatus Rectum\": " + (t == null ? -1 : t.getSemilatusRectum()) + "}";
            } else if (lastEdit instanceof SetShapeForAllParabolicTroughsCommand) {
                final List<ParabolicTrough> troughs = Scene.getInstance().getAllParabolicTroughs();
                final ParabolicTrough t = troughs.isEmpty() ? null : troughs.get(0);
                stateValue = "{\"New Aperture Width\": " + (t == null ? -1 : t.getApertureWidth()) + ", \"New Length\": " + (t == null ? -1 : t.getTroughLength()) + ", \"New Module Length\": " + (t == null ? -1 : t.getModuleLength()) + ", \"New Semilatus Rectum\": " + (t == null ? -1 : t.getSemilatusRectum()) + "}";
            } else if (lastEdit instanceof SetRimRadiusForParabolicDishesOnFoundationCommand) {
                final Foundation f = ((SetRimRadiusForParabolicDishesOnFoundationCommand) lastEdit).getFoundation();
                final List<ParabolicDish> dishes = f.getParabolicDishes();
                final ParabolicDish d = dishes.isEmpty() ? null : dishes.get(0);
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Rim Radius\": " + (d == null ? -1 : d.getRimRadius()) + "}";
            } else if (lastEdit instanceof SetRimRadiusForAllParabolicDishesCommand) {
                final List<ParabolicDish> dishes = Scene.getInstance().getAllParabolicDishes();
                final ParabolicDish d = dishes.isEmpty() ? null : dishes.get(0);
                stateValue = "{\"New Rim Radius\": " + (d == null ? -1 : d.getRimRadius()) + "}";
            } else if (lastEdit instanceof SetSizeForFresnelReflectorsOnFoundationCommand) {
                final Foundation f = ((SetSizeForFresnelReflectorsOnFoundationCommand) lastEdit).getFoundation();
                final List<FresnelReflector> reflectors = f.getFresnelReflectors();
                final FresnelReflector r = reflectors.isEmpty() ? null : reflectors.get(0);
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Length\": " + (r == null ? -1 : r.getLength()) + ", \"New Module Length\": " + (r == null ? -1 : r.getModuleLength()) + ", \"New Module Width\": " + (r == null ? -1 : r.getModuleWidth()) + "}";
            } else if (lastEdit instanceof SetSizeForAllFresnelReflectorsCommand) {
                final List<FresnelReflector> reflectors = Scene.getInstance().getAllFresnelReflectors();
                final FresnelReflector r = reflectors.isEmpty() ? null : reflectors.get(0);
                stateValue = "{\"New Length\": " + (r == null ? -1 : r.getLength()) + ", \"New Module Length\": " + (r == null ? -1 : r.getModuleLength()) + ", \"New Module Width\": " + (r == null ? -1 : r.getModuleWidth()) + "}";
            } else if (lastEdit instanceof ChangeWallTypeCommand) {
                final ChangeWallTypeCommand c = (ChangeWallTypeCommand) lastEdit;
                final Wall w = c.getWall();
                stateValue = "{\"Building\": " + w.getContainer().getId() + ", \"ID\": " + w.getId();
                stateValue += ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + w.getType() + "}";
            } else if (lastEdit instanceof ChangeWallThicknessCommand) {
                final ChangeWallThicknessCommand c = (ChangeWallThicknessCommand) lastEdit;
                final Wall w = c.getWall();
                stateValue = "{\"Building\": " + w.getContainer().getId() + ", \"ID\": " + w.getId();
                stateValue += ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + w.getThickness() + "}";
            } else if (lastEdit instanceof ChangeFoundationWallThicknessCommand) {
                final ChangeFoundationWallThicknessCommand c = (ChangeFoundationWallThicknessCommand) lastEdit;
                final Foundation f = c.getFoundation();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + c.getWalls().get(0).getThickness() + "}";
            } else if (lastEdit instanceof ChangeThicknessForAllWallsCommand) {
                final ChangeThicknessForAllWallsCommand c = (ChangeThicknessForAllWallsCommand) lastEdit;
                stateValue = "{\"New Value\": " + (c.getWalls().isEmpty() ? -1 : ((Wall) c.getWalls().get(0)).getThickness()) + "}";
            } else if (lastEdit instanceof ChangeWallHeightCommand) {
                final ChangeWallHeightCommand c = (ChangeWallHeightCommand) lastEdit;
                final Wall w = c.getWall();
                stateValue = "{\"Building\": " + w.getContainer().getId() + ", \"ID\": " + w.getId();
                stateValue += ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + w.getHeight() + "}";
            } else if (lastEdit instanceof ChangeFoundationWallHeightCommand) {
                final ChangeFoundationWallHeightCommand c = (ChangeFoundationWallHeightCommand) lastEdit;
                final Foundation f = c.getFoundation();
                stateValue = "{\"Foundation\": " + f.getId() + ", \"New Value\": " + c.getWalls().get(0).getHeight() + "}";
            } else if (lastEdit instanceof ChangeHeightForAllWallsCommand) {
                final ChangeHeightForAllWallsCommand c = (ChangeHeightForAllWallsCommand) lastEdit;
                stateValue = "{\"New Value\": " + (c.getWalls().isEmpty() ? -1 : ((Wall) c.getWalls().get(0)).getHeight()) + "}";
            } else if (lastEdit instanceof ChangeHeightForConnectedWallsCommand) {
                final ChangeHeightForConnectedWallsCommand c = (ChangeHeightForConnectedWallsCommand) lastEdit;
                stateValue = "{\"New Value\": " + (c.getWalls().isEmpty() ? -1 : c.getWalls().get(0).getHeight()) + "}";
            } else if (lastEdit instanceof ChangeWindowShgcCommand) {
                final ChangeWindowShgcCommand c = (ChangeWindowShgcCommand) lastEdit;
                final Window w = c.getWindow();
                stateValue = "{\"Building\": " + w.getTopContainer().getId() + ", \"ID\": " + w.getId() + ", \"Old Value\": " + c.getOldValue() + ", \"New Value\": " + w.getSolarHeatGainCoefficient() + "}";
            } else if (lastEdit instanceof ChangeContainerWindowShgcCommand) {
                final ChangeContainerWindowShgcCommand c = (ChangeContainerWindowShgcCommand) lastEdit;
                final HousePart container = c.getContainer();
                final List<Window> windows = Scene.getInstance().getWindowsOnContainer(container);
                final String containerType = container instanceof Wall ? "Wall" : "Roof";
                stateValue = "{\"" + containerType + "\": " + container.getId() + ", \"New Value\": " + (windows.isEmpty() ? -1 : windows.get(0).getSolarHeatGainCoefficient()) + "}";
            } else if (lastEdit instanceof ChangeBuildingWindowShgcCommand) {
                final ChangeBuildingWindowShgcCommand c = (ChangeBuildingWindowShgcCommand) lastEdit;
                final Foundation foundation = c.getFoundation();
                final List<Window> windows = Scene.getInstance().getWindowsOfBuilding(foundation);
                stateValue = "{\"Building\": " + foundation.getId() + ", \"New Value\": " + (windows.isEmpty() ? -1 : windows.get(0).getSolarHeatGainCoefficient()) + "}";
            }
        }
        line += ", \"" + action + "\": ";
        if (actedPart != null) {
            line += LoggerUtil.getInfo(actedPart);
        } else if (stateValue != null) {
            line += stateValue;
        } else {
            line += "null";
        }
        lastAction = action;
    }
    if (analysisRequester != null) {
        final HousePart analyzedPart = SceneManager.getInstance().getSelectedPart();
        line += ", \"" + analysisRequester.getClass().getSimpleName() + "\": ";
        if (analysisRequester instanceof AnnualSensorData) {
            line += ((AnnualSensorData) analysisRequester).toJson();
        } else if (analysisRequester instanceof DailySensorData) {
            line += ((DailySensorData) analysisRequester).toJson();
        } else if (analysisRequester instanceof DailyEnvironmentalTemperature) {
            line += ((DailyEnvironmentalTemperature) analysisRequester).toJson();
        } else if (analysisRequester instanceof AnnualEnvironmentalTemperature) {
            line += ((AnnualEnvironmentalTemperature) analysisRequester).toJson();
        } else {
            if (analyzedPart != null && !(analyzedPart instanceof Tree) && !(analyzedPart instanceof Human)) {
                // if something analyzable is selected
                if (analysisRequester instanceof EnergyDailyAnalysis) {
                    line += ((EnergyDailyAnalysis) analysisRequester).toJson();
                } else if (analysisRequester instanceof BuildingDailyEnergyGraph) {
                    line += ((BuildingDailyEnergyGraph) analysisRequester).toJson();
                    final String result = Building.getBuildingSolarPotentials();
                    if (result != null) {
                        line += ", \"Solar Potential\": " + result;
                    }
                } else if (analysisRequester instanceof EnergyAnnualAnalysis) {
                    line += ((EnergyAnnualAnalysis) analysisRequester).toJson();
                } else if (analysisRequester instanceof EnergyAngularAnalysis) {
                    line += ((EnergyAngularAnalysis) analysisRequester).toJson();
                } else if (analysisRequester instanceof ProjectCost) {
                    line += ((ProjectCost) analysisRequester).toJson();
                }
            } else {
                if (analysisRequester instanceof ProjectCost) {
                    line += ((ProjectCost) analysisRequester).toJson();
                } else if (analysisRequester instanceof BuildingDailyEnergyGraph) {
                    line += ((BuildingDailyEnergyGraph) analysisRequester).toJson();
                    final String result = Building.getBuildingSolarPotentials();
                    if (result != null) {
                        line += ", \"Solar Potential\": " + result;
                    }
                }
            }
            if (analysisRequester instanceof PvDailyAnalysis) {
                line += ((PvDailyAnalysis) analysisRequester).toJson();
            } else if (analysisRequester instanceof PvAnnualAnalysis) {
                line += ((PvAnnualAnalysis) analysisRequester).toJson();
            }
            if (analysisRequester instanceof GroupDailyAnalysis) {
                line += ((GroupDailyAnalysis) analysisRequester).toJson();
            } else if (analysisRequester instanceof GroupAnnualAnalysis) {
                line += ((GroupAnnualAnalysis) analysisRequester).toJson();
            }
        }
    }
    if (firstRecord) {
        firstRecord = false;
    } else {
        writer.write(",\n");
    }
    writer.write("{\"Timestamp\": \"" + timestamp + "\", " + line + "}");
    writer.flush();
    lastTime = time;
}
Also used : PvAnnualAnalysis(org.concord.energy3d.simulation.PvAnnualAnalysis) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) Human(org.concord.energy3d.model.Human) GregorianCalendar(java.util.GregorianCalendar) SolarPanel(org.concord.energy3d.model.SolarPanel) ProjectCost(org.concord.energy3d.simulation.ProjectCost) GroupDailyAnalysis(org.concord.energy3d.simulation.GroupDailyAnalysis) URL(java.net.URL) SolarCollector(org.concord.energy3d.model.SolarCollector) PvDailyAnalysis(org.concord.energy3d.simulation.PvDailyAnalysis) Window(org.concord.energy3d.model.Window) AnnualEnvironmentalTemperature(org.concord.energy3d.simulation.AnnualEnvironmentalTemperature) GroupAnnualAnalysis(org.concord.energy3d.simulation.GroupAnnualAnalysis) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) UndoableEdit(javax.swing.undo.UndoableEdit) Tree(org.concord.energy3d.model.Tree) List(java.util.List) BuildingDailyEnergyGraph(org.concord.energy3d.gui.BuildingDailyEnergyGraph) TextureMode(org.concord.energy3d.scene.Scene.TextureMode) EnergyAngularAnalysis(org.concord.energy3d.simulation.EnergyAngularAnalysis) DailySensorData(org.concord.energy3d.simulation.DailySensorData) File(java.io.File) Mirror(org.concord.energy3d.model.Mirror) Thermal(org.concord.energy3d.model.Thermal) EnergyAnnualAnalysis(org.concord.energy3d.simulation.EnergyAnnualAnalysis) Wall(org.concord.energy3d.model.Wall) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Date(java.util.Date) DailyEnvironmentalTemperature(org.concord.energy3d.simulation.DailyEnvironmentalTemperature) ParabolicDish(org.concord.energy3d.model.ParabolicDish) EnergyDailyAnalysis(org.concord.energy3d.simulation.EnergyDailyAnalysis) AnnualSensorData(org.concord.energy3d.simulation.AnnualSensorData) Trackable(org.concord.energy3d.model.Trackable)

Example 3 with ParabolicDish

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

the class Scene method setFocalLengthForAllParabolicDishes.

public void setFocalLengthForAllParabolicDishes(final double curvatureParameter) {
    for (final HousePart p : parts) {
        if (p instanceof ParabolicDish) {
            ((ParabolicDish) p).setFocalLength(curvatureParameter);
            p.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) HousePart(org.concord.energy3d.model.HousePart)

Example 4 with ParabolicDish

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

the class Scene method removeAllParabolicDishes.

public void removeAllParabolicDishes() {
    final ArrayList<HousePart> dishes = new ArrayList<HousePart>();
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart != null) {
        final Foundation foundation = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
        for (final HousePart part : parts) {
            if (part instanceof ParabolicDish && part.getTopContainer() == foundation) {
                dishes.add(part);
            }
        }
    } else {
        for (final HousePart part : parts) {
            if (part instanceof ParabolicDish) {
                dishes.add(part);
            }
        }
    }
    if (dishes.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no parabolic dish to remove.", "No Parabolic Dish", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + dishes.size() + " parabolic dishes" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(dishes);
    for (final HousePart part : dishes) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 5 with ParabolicDish

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

the class Scene method setRimRadiusForAllParabolicDishes.

public void setRimRadiusForAllParabolicDishes(final double apertureRadius) {
    for (final HousePart p : parts) {
        if (p instanceof ParabolicDish) {
            ((ParabolicDish) p).setRimRadius(apertureRadius);
            p.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

ParabolicDish (org.concord.energy3d.model.ParabolicDish)43 HousePart (org.concord.energy3d.model.HousePart)26 Foundation (org.concord.energy3d.model.Foundation)20 FresnelReflector (org.concord.energy3d.model.FresnelReflector)17 Mirror (org.concord.energy3d.model.Mirror)17 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)17 Rack (org.concord.energy3d.model.Rack)15 SolarPanel (org.concord.energy3d.model.SolarPanel)13 Window (org.concord.energy3d.model.Window)13 Wall (org.concord.energy3d.model.Wall)10 Door (org.concord.energy3d.model.Door)9 Roof (org.concord.energy3d.model.Roof)9 ArrayList (java.util.ArrayList)5 Calendar (java.util.Calendar)5 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)3 CullHint (com.ardor3d.scenegraph.hint.CullHint)3 List (java.util.List)3 JDialog (javax.swing.JDialog)3 Human (org.concord.energy3d.model.Human)3 SolarCollector (org.concord.energy3d.model.SolarCollector)3