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;
}
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;
}
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;
}
Aggregations