Search in sources :

Example 26 with Tree

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

the class PopupMenuForTree method getPopupMenu.

static JPopupMenu getPopupMenu() {
    if (popupMenuForTree == null) {
        final JCheckBoxMenuItem miPolygon = new JCheckBoxMenuItem("Show Polygon");
        miPolygon.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                final HousePart p = SceneManager.getInstance().getSelectedPart();
                if (p instanceof Tree) {
                    ((Tree) p).setShowPolygons(miPolygon.isSelected());
                }
                Scene.getInstance().setEdited(true);
            }
        });
        final JCheckBoxMenuItem miLock = new JCheckBoxMenuItem("Lock");
        miLock.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (selectedPart instanceof Tree) {
                    final Tree tree = (Tree) selectedPart;
                    SceneManager.getInstance().getUndoManager().addEdit(new LockEditPointsCommand(tree));
                    final boolean lock = miLock.isSelected();
                    tree.setLockEdit(lock);
                    if (lock) {
                        SceneManager.getInstance().hideAllEditPoints();
                    }
                    tree.draw();
                    Scene.getInstance().setEdited(true);
                }
            }
        });
        popupMenuForTree = createPopupMenu(true, true, new Runnable() {

            @Override
            public void run() {
                final HousePart p = SceneManager.getInstance().getSelectedPart();
                if (p instanceof Tree) {
                    Util.selectSilently(miPolygon, ((Tree) p).getShowPolygons());
                    Util.selectSilently(miLock, p.getLockEdit());
                }
            }
        });
        popupMenuForTree.addSeparator();
        popupMenuForTree.add(miLock);
        popupMenuForTree.add(miPolygon);
    }
    return popupMenuForTree;
}
Also used : ItemEvent(java.awt.event.ItemEvent) LockEditPointsCommand(org.concord.energy3d.undo.LockEditPointsCommand) Tree(org.concord.energy3d.model.Tree) ItemListener(java.awt.event.ItemListener) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) HousePart(org.concord.energy3d.model.HousePart)

Example 27 with Tree

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

the class BuildingCostGraph method calculateCost.

private void calculateCost() {
    int countBuildings = 0;
    for (final HousePart p : Scene.getInstance().getParts()) {
        if (p instanceof Foundation) {
            countBuildings++;
        }
    }
    wallSum = 0;
    floorSum = 0;
    windowSum = 0;
    roofSum = 0;
    doorSum = 0;
    solarPanelSum = 0;
    treeSum = 0;
    foundationSum = BuildingCost.getPartCost(foundation);
    for (final HousePart p : Scene.getInstance().getParts()) {
        if (p.getTopContainer() == foundation) {
            if (p instanceof Wall) {
                wallSum += BuildingCost.getPartCost(p);
            } else if (p instanceof Floor) {
                floorSum += BuildingCost.getPartCost(p);
            } else if (p instanceof Window) {
                windowSum += BuildingCost.getPartCost(p);
            } else if (p instanceof Roof) {
                roofSum += BuildingCost.getPartCost(p);
            } else if (p instanceof Door) {
                doorSum += BuildingCost.getPartCost(p);
            } else if (p instanceof SolarPanel) {
                solarPanelSum += BuildingCost.getPartCost(p);
            } else if (p instanceof Rack) {
                solarPanelSum += BuildingCost.getPartCost(p);
            }
        }
        if (countBuildings <= 1) {
            if (p instanceof Tree && !p.getLockEdit()) {
                treeSum += BuildingCost.getPartCost(p);
            }
        }
    }
    totalCost = wallSum + windowSum + roofSum + doorSum + solarPanelSum + treeSum + foundationSum + floorSum;
}
Also used : Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) Wall(org.concord.energy3d.model.Wall) SolarPanel(org.concord.energy3d.model.SolarPanel) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) Door(org.concord.energy3d.model.Door)

Example 28 with Tree

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

the class LoggerUtil method getInfo.

static Object getInfo(final HousePart p) {
    if (p == null)
        return null;
    long bid = Building.getBuildingId(p);
    String s;
    if (p instanceof Human) {
        s = "{\"Name\": \"" + ((Human) p).getHumanName() + "\", ";
    } else if (p instanceof Tree) {
        s = "{\"Species\": \"" + ((Tree) p).getTreeName() + "\", ";
    } else {
        s = "{\"Type\": \"" + p.getClass().getSimpleName() + "\", ";
    }
    if (bid != -1)
        s += "\"Building\": " + bid + ", ";
    s += "\"ID\": " + p.getId();
    int n = p.getPoints().size();
    if (n > 0) {
        s += ", \"Coordinates\": [";
        boolean exist;
        for (int i = 0; i < n; i++) {
            exist = false;
            for (int j = 0; j < i; j++) {
                if (p.getPoints().get(j).equals(p.getPoints().get(i))) {
                    exist = true;
                    break;
                }
            }
            if (!exist) {
                Vector3 v = p.getAbsPoint(i);
                s += "{\"x\": " + FORMAT.format(v.getX()) + ", \"y\": " + FORMAT.format(v.getY()) + ", \"z\": " + FORMAT.format(v.getZ()) + "}";
                if (i < n - 1)
                    s += ", ";
            }
        }
        s = s.trim();
        if (s.endsWith(",")) {
            s = s.substring(0, s.length() - 1);
        }
        s += "]";
    }
    if (bid != -1 && bid == p.getId()) {
        if (p instanceof Foundation) {
            Building b = new Building((Foundation) p);
            if (b.isWallComplete()) {
                s += ", " + b.geometryToJson();
            }
        }
    }
    s += "}";
    return s;
}
Also used : Human(org.concord.energy3d.model.Human) Building(org.concord.energy3d.model.Building) Tree(org.concord.energy3d.model.Tree) Vector3(com.ardor3d.math.Vector3) Foundation(org.concord.energy3d.model.Foundation)

Aggregations

Tree (org.concord.energy3d.model.Tree)28 HousePart (org.concord.energy3d.model.HousePart)26 Foundation (org.concord.energy3d.model.Foundation)24 Human (org.concord.energy3d.model.Human)19 Window (org.concord.energy3d.model.Window)12 Rack (org.concord.energy3d.model.Rack)10 Roof (org.concord.energy3d.model.Roof)9 SolarPanel (org.concord.energy3d.model.SolarPanel)9 Wall (org.concord.energy3d.model.Wall)8 Vector3 (com.ardor3d.math.Vector3)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 JDialog (javax.swing.JDialog)7 Door (org.concord.energy3d.model.Door)7 Floor (org.concord.energy3d.model.Floor)7 SolarCollector (org.concord.energy3d.model.SolarCollector)7 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)6 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 JPanel (javax.swing.JPanel)6