Search in sources :

Example 46 with Wall

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

the class BuildingCost method showPieChart.

@Override
void showPieChart() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    final Foundation selectedBuilding;
    if (selectedPart == null || selectedPart instanceof Tree || selectedPart instanceof Human) {
        selectedBuilding = null;
    } else if (selectedPart instanceof Foundation) {
        selectedBuilding = (Foundation) selectedPart;
    } else {
        selectedBuilding = selectedPart.getTopContainer();
        selectedPart.setEditPointsVisible(false);
        SceneManager.getInstance().setSelectedPart(selectedBuilding);
    }
    String details = "";
    int count = 0;
    for (final HousePart p : Scene.getInstance().getParts()) {
        if (p instanceof Foundation) {
            count++;
            if (selectedBuilding == null) {
                final Foundation foundation = (Foundation) p;
                details += "$" + (int) getCostByFoundation(foundation) + " (" + foundation.getId() + ") | ";
            }
        }
    }
    if (selectedBuilding == null) {
        if (count > 0) {
            details = details.substring(0, details.length() - 2);
        }
    }
    double wallSum = 0;
    double floorSum = 0;
    double windowSum = 0;
    double roofSum = 0;
    double foundationSum = 0;
    double doorSum = 0;
    double solarPanelSum = 0;
    double treeSum = 0;
    String info;
    if (selectedBuilding != null) {
        info = "Building #" + selectedBuilding.getId();
        foundationSum = getPartCost(selectedBuilding);
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p.getTopContainer() == selectedBuilding) {
                if (p instanceof Wall) {
                    wallSum += getPartCost(p);
                } else if (p instanceof Floor) {
                    floorSum += getPartCost(p);
                } else if (p instanceof Window) {
                    windowSum += getPartCost(p);
                } else if (p instanceof Roof) {
                    roofSum += getPartCost(p);
                } else if (p instanceof Door) {
                    doorSum += getPartCost(p);
                } else if (p instanceof SolarPanel || p instanceof Rack) {
                    solarPanelSum += getPartCost(p);
                }
            }
            if (count <= 1) {
                if (p instanceof Tree && !p.getLockEdit()) {
                    treeSum += getPartCost(p);
                }
            }
        }
    } else {
        info = count + " buildings";
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p instanceof Wall) {
                wallSum += getPartCost(p);
            } else if (p instanceof Floor) {
                floorSum += getPartCost(p);
            } else if (p instanceof Window) {
                windowSum += getPartCost(p);
            } else if (p instanceof Roof) {
                roofSum += getPartCost(p);
            } else if (p instanceof Foundation) {
                foundationSum += getPartCost(p);
            } else if (p instanceof Door) {
                doorSum += getPartCost(p);
            } else if (p instanceof SolarPanel || p instanceof Rack) {
                solarPanelSum += getPartCost(p);
            } else if (p instanceof Tree && !p.getLockEdit()) {
                treeSum += getPartCost(p);
            }
        }
    }
    final double[] data = new double[] { wallSum, windowSum, roofSum, foundationSum, floorSum, doorSum, solarPanelSum, treeSum };
    // show them in a popup window
    final PieChart pie = new PieChart(data, BuildingCostGraph.colors, BuildingCostGraph.legends, "$", info, count > 1 ? details : null, true);
    pie.setBackground(Color.WHITE);
    pie.setBorder(BorderFactory.createEtchedBorder());
    final JDialog dialog = new JDialog(MainFrame.getInstance(), "Project Costs by Category", true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.getContentPane().add(pie, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JButton buttonItemize = new JButton("Itemize");
    buttonItemize.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            showItemizedCost();
        }
    });
    buttonPanel.add(buttonItemize);
    final JButton buttonClose = new JButton("Close");
    buttonClose.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dialog.dispose();
        }
    });
    buttonPanel.add(buttonClose);
    dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setLocationRelativeTo(MainFrame.getInstance());
    dialog.setVisible(true);
}
Also used : Human(org.concord.energy3d.model.Human) Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) JPanel(javax.swing.JPanel) Wall(org.concord.energy3d.model.Wall) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Door(org.concord.energy3d.model.Door) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) ActionListener(java.awt.event.ActionListener) SolarPanel(org.concord.energy3d.model.SolarPanel) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Example 47 with Wall

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

the class ChangeHeightForAllWallsCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = walls.size();
    newValues = new double[n];
    for (int i = 0; i < n; i++) {
        final Wall w = (Wall) walls.get(i);
        newValues[i] = w.getHeight();
        w.setHeight(oldValues[i], true);
    }
    Scene.getInstance().redrawAllWallsNow();
}
Also used : Wall(org.concord.energy3d.model.Wall)

Example 48 with Wall

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

the class ChangeHeightForConnectedWallsCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = walls.size();
    newValues = new double[n];
    for (int i = 0; i < n; i++) {
        final Wall w = walls.get(i);
        newValues[i] = w.getHeight();
        w.setHeight(oldValues[i], true);
    }
    Scene.getInstance().redrawAllWallsNow();
    updateLinkedObjects();
}
Also used : Wall(org.concord.energy3d.model.Wall)

Example 49 with Wall

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

the class ChangeWallTextureCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    newValue = Scene.getInstance().getWallTextureType();
    Scene.getInstance().setWallTextureType(oldValue);
    for (final HousePart p : Scene.getInstance().getParts()) {
        if (p instanceof Wall) {
            p.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : Wall(org.concord.energy3d.model.Wall) HousePart(org.concord.energy3d.model.HousePart)

Example 50 with Wall

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

the class RemovePartCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    Scene.getInstance().add(part, true);
    if (part instanceof Wall) {
        final Roof roof = ((Wall) part).getRoof();
        if (roof != null && gableInfo.size() == 1) {
            roof.setGableEditPointToWallMap(gableInfo.get(0));
        }
    } else if (part instanceof Foundation) {
        final List<Roof> roofs = ((Foundation) part).getRoofs();
        if (!roofs.isEmpty() && !gableInfo.isEmpty()) {
            for (int i = 0; i < roofs.size(); i++) {
                roofs.get(i).setGableEditPointToWallMap(gableInfo.get(i));
            }
        }
    }
    SceneManager.getInstance().setSelectedPart(part);
    if (part.getContainer() != null) {
        // redraw its container since we are not calling the costly redrawAll any more
        part.getContainer().draw();
    }
    if (SceneManager.getInstance().getSolarHeatMap()) {
        EnergyPanel.getInstance().updateRadiationHeatMap();
    }
}
Also used : Roof(org.concord.energy3d.model.Roof) Wall(org.concord.energy3d.model.Wall) Foundation(org.concord.energy3d.model.Foundation) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Wall (org.concord.energy3d.model.Wall)57 HousePart (org.concord.energy3d.model.HousePart)45 Foundation (org.concord.energy3d.model.Foundation)37 Roof (org.concord.energy3d.model.Roof)31 Window (org.concord.energy3d.model.Window)28 Door (org.concord.energy3d.model.Door)25 Rack (org.concord.energy3d.model.Rack)23 SolarPanel (org.concord.energy3d.model.SolarPanel)23 ArrayList (java.util.ArrayList)16 Mirror (org.concord.energy3d.model.Mirror)14 FresnelReflector (org.concord.energy3d.model.FresnelReflector)12 Floor (org.concord.energy3d.model.Floor)11 List (java.util.List)10 ParabolicDish (org.concord.energy3d.model.ParabolicDish)10 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)10 ActionEvent (java.awt.event.ActionEvent)9 ActionListener (java.awt.event.ActionListener)9 Tree (org.concord.energy3d.model.Tree)8 JMenuItem (javax.swing.JMenuItem)7 JPanel (javax.swing.JPanel)7