use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.
the class Scene method redrawFoundationNow.
// special case for redrawing the specified foundation (this is needed when we deal with a lot of solar collectors or a lot of foundations)
public void redrawFoundationNow(final Foundation foundation) {
System.out.println("redrawFoundationNow()");
foundation.connectWalls();
List<Roof> roofs = null;
for (final HousePart part : parts) {
if (part instanceof Roof) {
if (part.getTopContainer() == foundation) {
if (roofs == null) {
roofs = new ArrayList<Roof>();
}
roofs.add((Roof) part);
part.draw();
}
}
}
for (final HousePart part : parts) {
if (!(part instanceof Roof)) {
if (part.getTopContainer() == foundation || part == foundation) {
part.draw();
}
}
}
if (roofs != null && !roofs.isEmpty()) {
// need to draw roof again because roof holes depend on drawn windows
for (final Roof r : roofs) {
r.draw();
}
roofs.clear();
}
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.
the class Scene method removeAllRoofs.
public void removeAllRoofs() {
final ArrayList<HousePart> roofs = new ArrayList<HousePart>();
for (final HousePart part : parts) {
if (part instanceof Roof && !part.getLockEdit()) {
roofs.add(part);
}
}
if (roofs.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no roof to remove.", "No Roof", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + roofs.size() + " roofs?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(roofs);
for (final HousePart part : roofs) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.
the class Scene method removeAllChildren.
public void removeAllChildren(final HousePart parent) {
final List<HousePart> children = parent.getChildren();
final String s = parent.getClass().getSimpleName();
// make a copy to avoid ConcurrentModificationException
final List<HousePart> copy = new ArrayList<HousePart>();
for (final HousePart p : children) {
if (p instanceof Roof) {
// make an exception of roof (it is a child of a wall)
continue;
}
copy.add(p);
}
if (copy.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no element to remove from " + s + ".", "No Element", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + copy.size() + " elements of " + s + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(copy);
for (final HousePart p : copy) {
remove(p, false);
}
parent.draw();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.
the class Scene method redrawAllNow.
public void redrawAllNow() {
System.out.println("redrawAllNow()");
final int n = parts.size();
final boolean showProgress = n > 1000;
if (showProgress) {
SceneManager.getInstance().cursorWait(true);
}
final long t = System.nanoTime();
if (cleanup) {
cleanup();
cleanup = false;
}
connectWalls();
Snap.clearAnnotationDrawn();
List<Roof> roofs = null;
for (final HousePart part : parts) {
if (part instanceof Roof) {
if (roofs == null) {
roofs = new ArrayList<Roof>();
}
roofs.add((Roof) part);
part.draw();
}
}
int i = 0;
for (final HousePart part : parts) {
if (!(part instanceof Roof)) {
part.draw();
if (showProgress) {
final int index = i++;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
EnergyPanel.getInstance().progress((int) Math.round(100.0 * index / n));
}
});
}
}
}
if (roofs != null && !roofs.isEmpty()) {
// need to draw roof again because roof holes depend on drawn windows
for (final Roof r : roofs) {
r.draw();
}
roofs.clear();
}
if (Heliodon.getInstance().isVisible()) {
Heliodon.getInstance().updateSize();
}
System.out.println("Scene rendering time: " + (System.nanoTime() - t) / 1000000000.0);
// no need for redrawing print parts because they will be regenerated from original parts anyways
redrawAll = false;
if (showProgress) {
SceneManager.getInstance().cursorWait(false);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
EnergyPanel.getInstance().progress(0);
}
});
}
}
use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.
the class Scene method redrawAllWallsNow.
// special case for redrawing walls and roofs that are interconnected (this is needed when we deal with a lot of solar collectors)
public void redrawAllWallsNow() {
System.out.println("redrawAllWallsNow()");
connectWalls();
List<Roof> roofs = null;
for (final HousePart part : parts) {
if (part instanceof Roof) {
if (roofs == null) {
roofs = new ArrayList<Roof>();
}
roofs.add((Roof) part);
part.draw();
}
}
for (final HousePart part : parts) {
if (part instanceof Wall) {
part.draw();
part.drawChildren();
}
}
if (roofs != null && !roofs.isEmpty()) {
// need to draw roof again because roof holes depend on drawn windows
for (final Roof r : roofs) {
r.draw();
}
roofs.clear();
}
SceneManager.getInstance().refresh();
}
Aggregations