Search in sources :

Example 71 with Foundation

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

the class ChangeRoofOverhangCommand method redo.

@Override
public void redo() throws CannotRedoException {
    super.redo();
    roof.setOverhangLength(newValue);
    roof.draw();
    // can't just use Roof.draw() as we also need to draw the wall parts
    final Foundation f = roof.getTopContainer();
    f.drawChildren();
    SceneManager.getInstance().refresh();
}
Also used : Foundation(org.concord.energy3d.model.Foundation)

Example 72 with Foundation

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

the class ChangeRoofOverhangCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    newValue = roof.getOverhangLength();
    roof.setOverhangLength(oldValue);
    roof.draw();
    // can't just use Roof.draw() as we also need to draw the wall parts
    final Foundation f = roof.getTopContainer();
    f.drawChildren();
    SceneManager.getInstance().refresh();
}
Also used : Foundation(org.concord.energy3d.model.Foundation)

Example 73 with Foundation

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

the class MainFrame method getAnnualParabolicDishAnalysisMenuItem.

private JMenuItem getAnnualParabolicDishAnalysisMenuItem() {
    if (annualParabolicDishAnalysisMenuItem == null) {
        annualParabolicDishAnalysisMenuItem = new JMenuItem("Annual Yield Analysis of Parabolic Dishes...");
        annualParabolicDishAnalysisMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                if (EnergyPanel.getInstance().checkCity()) {
                    int n = Scene.getInstance().countParts(ParabolicDish.class);
                    if (n <= 0) {
                        JOptionPane.showMessageDialog(MainFrame.this, "There is no parabolic dish to analyze.", "No Parabolic Dish", JOptionPane.WARNING_MESSAGE);
                        return;
                    }
                    if (EnergyPanel.getInstance().adjustCellSize()) {
                        return;
                    }
                    final ParabolicDishAnnualAnalysis a = new ParabolicDishAnnualAnalysis();
                    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                    if (selectedPart != null) {
                        Foundation foundation;
                        if (selectedPart instanceof Foundation) {
                            foundation = (Foundation) selectedPart;
                        } else {
                            foundation = selectedPart.getTopContainer();
                        }
                        if (foundation != null) {
                            n = foundation.countParts(ParabolicDish.class);
                            if (n <= 0) {
                                JOptionPane.showMessageDialog(MainFrame.this, "There is no parabolic dish on this foundation to analyze.", "No Parabolic Dish", JOptionPane.WARNING_MESSAGE);
                                return;
                            }
                        }
                    }
                    a.show();
                }
            }
        });
    }
    return annualParabolicDishAnalysisMenuItem;
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ParabolicDishAnnualAnalysis(org.concord.energy3d.simulation.ParabolicDishAnnualAnalysis) Foundation(org.concord.energy3d.model.Foundation) JMenuItem(javax.swing.JMenuItem) HousePart(org.concord.energy3d.model.HousePart)

Example 74 with Foundation

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

the class MainFrame method getAnnualParabolicTroughAnalysisMenuItem.

private JMenuItem getAnnualParabolicTroughAnalysisMenuItem() {
    if (annualParabolicTroughAnalysisMenuItem == null) {
        annualParabolicTroughAnalysisMenuItem = new JMenuItem("Annual Yield Analysis of Parabolic Troughs...");
        annualParabolicTroughAnalysisMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                if (EnergyPanel.getInstance().checkCity()) {
                    int n = Scene.getInstance().countParts(ParabolicTrough.class);
                    if (n <= 0) {
                        JOptionPane.showMessageDialog(MainFrame.this, "There is no parabolic trough to analyze.", "No Parabolic Trough", JOptionPane.WARNING_MESSAGE);
                        return;
                    }
                    if (EnergyPanel.getInstance().adjustCellSize()) {
                        return;
                    }
                    final ParabolicTroughAnnualAnalysis a = new ParabolicTroughAnnualAnalysis();
                    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                    if (selectedPart != null) {
                        Foundation foundation;
                        if (selectedPart instanceof Foundation) {
                            foundation = (Foundation) selectedPart;
                        } else {
                            foundation = selectedPart.getTopContainer();
                        }
                        if (foundation != null) {
                            n = foundation.countParts(ParabolicTrough.class);
                            if (n <= 0) {
                                JOptionPane.showMessageDialog(MainFrame.this, "There is no parabolic trough on this foundation to analyze.", "No Parabolic Trough", JOptionPane.WARNING_MESSAGE);
                                return;
                            }
                        }
                    }
                    a.show();
                }
            }
        });
    }
    return annualParabolicTroughAnalysisMenuItem;
}
Also used : ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) ParabolicTroughAnnualAnalysis(org.concord.energy3d.simulation.ParabolicTroughAnnualAnalysis) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Foundation(org.concord.energy3d.model.Foundation) JMenuItem(javax.swing.JMenuItem) HousePart(org.concord.energy3d.model.HousePart)

Example 75 with Foundation

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

the class MainFrame method showColorDialogForParts.

void showColorDialogForParts() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    ActionListener colorActionListener;
    if (selectedPart == null) {
        final ReadOnlyColorRGBA color = Scene.getInstance().getLandColor();
        if (color != null) {
            colorChooser.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        }
        colorActionListener = new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final float[] newColor = colorChooser.getColor().getComponents(null);
                final ColorRGBA rgba = new ColorRGBA(newColor[0], newColor[1], newColor[2], 0.5f);
                if (!Scene.getInstance().getLandColor().equals(rgba)) {
                    final ChangeLandColorCommand cmd = new ChangeLandColorCommand();
                    Scene.getInstance().setLandColor(rgba);
                    Scene.getInstance().setEdited(true);
                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                }
            }
        };
    } else {
        if (Scene.getInstance().getTextureMode() != TextureMode.None) {
            // when the user wants to set the color, automatically switch to no texture
            if (JOptionPane.showConfirmDialog(this, "To set color for an individual part, we have to remove the texture. Is that OK?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
                return;
            }
            Scene.getInstance().setTextureMode(TextureMode.None);
        }
        final ReadOnlyColorRGBA color = selectedPart.getColor();
        if (color != null) {
            colorChooser.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        }
        colorActionListener = new ActionListener() {

            private boolean changed;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (selectedPart == null) {
                    return;
                }
                final Color c = colorChooser.getColor();
                final float[] newColor = c.getComponents(null);
                final boolean restartPrintPreview = Scene.getInstance().getRoofColor().equals(ColorRGBA.WHITE) || c.equals(Color.WHITE);
                final ColorRGBA color = new ColorRGBA(newColor[0], newColor[1], newColor[2], newColor[3]);
                final JPanel panel = new JPanel();
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                if (selectedPart instanceof Wall) {
                    final JRadioButton rb1 = new JRadioButton("Only this Wall", true);
                    final JRadioButton rb2 = new JRadioButton("All Walls Connected to This One (Direct and Indirect)");
                    final JRadioButton rb3 = new JRadioButton("All Walls of this Building");
                    final JRadioButton rb4 = new JRadioButton("All Walls");
                    panel.add(rb1);
                    panel.add(rb2);
                    panel.add(rb3);
                    panel.add(rb4);
                    final ButtonGroup bg = new ButtonGroup();
                    bg.add(rb1);
                    bg.add(rb2);
                    bg.add(rb3);
                    bg.add(rb4);
                    final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                    final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                    final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Wall Color");
                    while (true) {
                        changed = false;
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            break;
                        } else {
                            changed = !color.equals(selectedPart.getColor());
                            if (rb1.isSelected()) {
                                // apply to only this part
                                if (changed) {
                                    final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                                    selectedPart.setColor(color);
                                    selectedPart.draw();
                                    SceneManager.getInstance().refresh();
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else if (rb2.isSelected()) {
                                final Wall w = (Wall) selectedPart;
                                if (!changed) {
                                    w.visitNeighbors(new WallVisitor() {

                                        @Override
                                        public void visit(final Wall currentWall, final Snap prev, final Snap next) {
                                            if (!color.equals(currentWall.getColor())) {
                                                changed = true;
                                            }
                                        }
                                    });
                                }
                                if (changed) {
                                    final ChangeColorOfConnectedWallsCommand cmd = new ChangeColorOfConnectedWallsCommand(w);
                                    Scene.getInstance().setColorOfConnectedWalls(w, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else if (rb3.isSelected()) {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getPartsOfSameTypeInBuilding(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeBuildingColorCommand cmd = new ChangeBuildingColorCommand(selectedPart);
                                    Scene.getInstance().setPartColorOfBuilding(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else if (rb4.isSelected()) {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getAllPartsOfSameType(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeColorOfAllPartsOfSameTypeCommand cmd = new ChangeColorOfAllPartsOfSameTypeCommand(selectedPart);
                                    Scene.getInstance().setColorOfAllPartsOfSameType(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            }
                            // remember the color decision for the next wall to be added
                            Scene.getInstance().setWallColor(color);
                            if (choice == options[0]) {
                                break;
                            }
                        }
                    }
                } else if (selectedPart instanceof Roof) {
                    final JRadioButton rb1 = new JRadioButton("Only this Roof", true);
                    final JRadioButton rb2 = new JRadioButton("All Roofs");
                    panel.add(rb1);
                    panel.add(rb2);
                    final ButtonGroup bg = new ButtonGroup();
                    bg.add(rb1);
                    bg.add(rb2);
                    final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                    final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                    final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Roof Color");
                    while (true) {
                        changed = false;
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            break;
                        } else {
                            changed = !color.equals(selectedPart.getColor());
                            if (rb1.isSelected()) {
                                // apply to only this part
                                if (changed) {
                                    final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                                    selectedPart.setColor(color);
                                    selectedPart.draw();
                                    SceneManager.getInstance().refresh();
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getAllPartsOfSameType(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeColorOfAllPartsOfSameTypeCommand cmd = new ChangeColorOfAllPartsOfSameTypeCommand(selectedPart);
                                    Scene.getInstance().setColorOfAllPartsOfSameType(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            }
                            // remember the color decision for the next roof to be added
                            Scene.getInstance().setRoofColor(color);
                            if (choice == options[0]) {
                                break;
                            }
                        }
                    }
                } else if (selectedPart instanceof Foundation) {
                    final JRadioButton rb1 = new JRadioButton("Only this Foundation", true);
                    final JRadioButton rb2 = new JRadioButton("All Foundations");
                    panel.add(rb1);
                    panel.add(rb2);
                    final ButtonGroup bg = new ButtonGroup();
                    bg.add(rb1);
                    bg.add(rb2);
                    final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                    final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                    final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Foundation Color");
                    while (true) {
                        changed = false;
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            break;
                        } else {
                            changed = !color.equals(selectedPart.getColor());
                            if (rb1.isSelected()) {
                                // apply to only this part
                                if (changed) {
                                    final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                                    selectedPart.setColor(color);
                                    selectedPart.draw();
                                    SceneManager.getInstance().refresh();
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getAllPartsOfSameType(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeColorOfAllPartsOfSameTypeCommand cmd = new ChangeColorOfAllPartsOfSameTypeCommand(selectedPart);
                                    Scene.getInstance().setColorOfAllPartsOfSameType(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            }
                            // remember the color decision for the next foundation to be added
                            Scene.getInstance().setFoundationColor(color);
                            if (choice == options[0]) {
                                break;
                            }
                        }
                    }
                } else {
                    changed = !color.equals(selectedPart.getColor());
                    if (changed) {
                        final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                        selectedPart.setColor(color);
                        selectedPart.draw();
                        SceneManager.getInstance().refresh();
                        SceneManager.getInstance().getUndoManager().addEdit(cmd);
                        if (selectedPart instanceof Door) {
                            // remember the color decision for the next part
                            Scene.getInstance().setDoorColor(color);
                        } else if (selectedPart instanceof Floor) {
                            Scene.getInstance().setFloorColor(color);
                        }
                    }
                }
                Scene.getInstance().setTextureMode(Scene.getInstance().getTextureMode());
                if (restartPrintPreview && PrintController.getInstance().isPrintPreview()) {
                    PrintController.getInstance().restartAnimation();
                }
                MainPanel.getInstance().getEnergyButton().setSelected(false);
                Scene.getInstance().setEdited(changed);
            }
        };
    }
    JColorChooser.createDialog(this, "Select Color", true, colorChooser, colorActionListener, null).setVisible(true);
}
Also used : ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) JPanel(javax.swing.JPanel) Wall(org.concord.energy3d.model.Wall) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) Snap(org.concord.energy3d.model.Snap) ChangeColorOfConnectedWallsCommand(org.concord.energy3d.undo.ChangeColorOfConnectedWallsCommand) WallVisitor(org.concord.energy3d.util.WallVisitor) Roof(org.concord.energy3d.model.Roof) ChangePartColorCommand(org.concord.energy3d.undo.ChangePartColorCommand) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) ChangeLandColorCommand(org.concord.energy3d.undo.ChangeLandColorCommand) Floor(org.concord.energy3d.model.Floor) ChangeColorOfAllPartsOfSameTypeCommand(org.concord.energy3d.undo.ChangeColorOfAllPartsOfSameTypeCommand) Color(java.awt.Color) JOptionPane(javax.swing.JOptionPane) Door(org.concord.energy3d.model.Door) ActionListener(java.awt.event.ActionListener) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) ButtonGroup(javax.swing.ButtonGroup) ChangeBuildingColorCommand(org.concord.energy3d.undo.ChangeBuildingColorCommand) JDialog(javax.swing.JDialog)

Aggregations

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