use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.
the class SetPartSizeCommand method undo.
@Override
public void undo() throws CannotUndoException {
super.undo();
if (part instanceof Mirror) {
final Mirror m = (Mirror) part;
newWidth = m.getMirrorWidth();
newHeight = m.getMirrorHeight();
m.setMirrorWidth(oldWidth);
m.setMirrorHeight(oldHeight);
} else if (part instanceof ParabolicTrough) {
final ParabolicTrough t = (ParabolicTrough) part;
newWidth = t.getApertureWidth();
newHeight = t.getTroughLength();
newModuleLength = t.getModuleLength();
t.setApertureWidth(oldWidth);
t.setTroughLength(oldHeight);
t.setModuleLength(oldModuleLength);
} else if (part instanceof ParabolicDish) {
final ParabolicDish d = (ParabolicDish) part;
newWidth = d.getRimRadius();
d.setRimRadius(oldWidth);
} else if (part instanceof FresnelReflector) {
final FresnelReflector r = (FresnelReflector) part;
newWidth = r.getModuleWidth();
newHeight = r.getLength();
newModuleLength = r.getModuleLength();
r.setModuleWidth(oldWidth);
r.setLength(oldHeight);
r.setModuleLength(oldModuleLength);
} else if (part instanceof Rack) {
final Rack r = (Rack) part;
newWidth = r.getRackWidth();
newHeight = r.getRackHeight();
r.setRackWidth(oldWidth);
r.setRackHeight(oldHeight);
} else if (part instanceof Window) {
final Window w = (Window) part;
newWidth = w.getWindowWidth();
newHeight = w.getWindowHeight();
w.setWindowWidth(oldWidth);
w.setWindowHeight(oldHeight);
w.getContainer().draw();
} else if (part instanceof Door) {
final Door d = (Door) part;
newWidth = d.getDoorWidth();
newHeight = d.getDoorHeight();
d.setDoorWidth(oldWidth);
d.setDoorHeight(oldHeight);
d.getContainer().draw();
}
part.draw();
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.
the class MovePartCommand method move.
private void move(final Vector3 v) {
SceneManager.getInstance().setSelectedPart(part);
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() throws Exception {
if (part == null) {
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof Foundation) {
((Foundation) p).move(v, p.getGridSize());
}
}
} else if (part instanceof Foundation) {
final Foundation f = (Foundation) part;
if (f.isGroupMaster()) {
final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
for (final Foundation x : g) {
x.move(v, part.getGridSize());
}
} else {
f.move(v, part.getGridSize());
}
} else if (part instanceof Window) {
final Window w = (Window) part;
w.move(v);
w.draw();
} else if (part instanceof SolarPanel) {
final SolarPanel s = (SolarPanel) part;
s.move(v, part.getGridSize());
s.draw();
} else if (part instanceof Rack) {
final Rack r = (Rack) part;
r.move(v, part.getGridSize());
r.draw();
} else if (part instanceof Mirror) {
final Mirror m = (Mirror) part;
m.move(v, part.getGridSize());
m.draw();
} else if (part instanceof ParabolicTrough) {
final ParabolicTrough t = (ParabolicTrough) part;
t.move(v, part.getGridSize());
t.draw();
} else if (part instanceof ParabolicDish) {
final ParabolicDish d = (ParabolicDish) part;
d.move(v, part.getGridSize());
d.draw();
} else if (part instanceof FresnelReflector) {
final FresnelReflector f = (FresnelReflector) part;
f.move(v, part.getGridSize());
f.draw();
}
return null;
}
});
}
use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.
the class CspProjectDailyEnergyGraph method updateGraph.
public void updateGraph() {
if (base == null) {
return;
}
graph.clearData();
final List<ParabolicTrough> troughs = base.getParabolicTroughs();
if (!troughs.isEmpty()) {
// favor parabolic troughs if there are also mirrors or Fresnel reflectors
for (int i = 0; i < 24; i++) {
SolarRadiation.getInstance().computeEnergyAtHour(i);
double output = 0;
for (final ParabolicTrough t : troughs) {
output += t.getSolarPotentialNow() * t.getSystemEfficiency();
}
graph.addData("Solar", output);
}
} else {
final List<ParabolicDish> dishes = base.getParabolicDishes();
if (!dishes.isEmpty()) {
for (int i = 0; i < 24; i++) {
SolarRadiation.getInstance().computeEnergyAtHour(i);
double output = 0;
for (final ParabolicDish d : dishes) {
output += d.getSolarPotentialNow() * d.getSystemEfficiency();
}
graph.addData("Solar", output);
}
} else {
final List<FresnelReflector> fresnels = base.getFresnelReflectors();
if (!fresnels.isEmpty()) {
for (int i = 0; i < 24; i++) {
SolarRadiation.getInstance().computeEnergyAtHour(i);
double output = 0;
for (final FresnelReflector r : fresnels) {
output += r.getSolarPotentialNow() * r.getSystemEfficiency();
}
graph.addData("Solar", output);
}
} else {
final List<Mirror> mirrors = base.getHeliostats();
if (!mirrors.isEmpty()) {
for (int i = 0; i < 24; i++) {
SolarRadiation.getInstance().computeEnergyAtHour(i);
double output = 0;
for (final Mirror m : mirrors) {
output += m.getSolarPotentialNow() * m.getSystemEfficiency();
}
graph.addData("Solar", output);
}
}
}
}
}
repaint();
}
use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.
the class CspProjectCostGraph method calculateCost.
private void calculateCost() {
landSum = 0;
collectorSum = 0;
receiverSum = 0;
if (foundation.hasSolarReceiver()) {
receiverSum = CspProjectCost.getPartCost(foundation);
} else {
landSum = CspProjectCost.getPartCost(foundation);
final List<Mirror> mirrors = foundation.getHeliostats();
if (!mirrors.isEmpty()) {
final ArrayList<Foundation> towers = new ArrayList<Foundation>();
for (final Mirror m : mirrors) {
if (m.getReceiver() != null) {
if (!towers.contains(m.getReceiver())) {
towers.add(m.getReceiver());
}
}
}
if (!towers.isEmpty()) {
for (final Foundation tower : towers) {
receiverSum += CspProjectCost.getPartCost(tower);
}
}
} else {
final List<FresnelReflector> reflectors = foundation.getFresnelReflectors();
if (!reflectors.isEmpty()) {
final ArrayList<Foundation> absorbers = new ArrayList<Foundation>();
for (final FresnelReflector r : reflectors) {
if (r.getReceiver() != null) {
if (!absorbers.contains(r.getReceiver())) {
absorbers.add(r.getReceiver());
}
}
}
if (!absorbers.isEmpty()) {
for (final Foundation absorber : absorbers) {
receiverSum += CspProjectCost.getPartCost(absorber);
}
}
}
}
}
for (final HousePart p : Scene.getInstance().getParts()) {
if (p.getTopContainer() == foundation) {
if (p instanceof SolarCollector) {
// assuming that sensor doesn't cost anything
collectorSum += CspProjectCost.getPartCost(p);
}
}
}
totalCost = landSum + collectorSum + receiverSum;
}
use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.
the class Scene method removeAllFresnelReflectors.
public void removeAllFresnelReflectors() {
final ArrayList<HousePart> reflectors = new ArrayList<HousePart>();
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart != null) {
final Foundation foundation = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
for (final HousePart part : parts) {
if (part instanceof FresnelReflector && part.getTopContainer() == foundation) {
reflectors.add(part);
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof FresnelReflector) {
reflectors.add(part);
}
}
}
if (reflectors.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no Fresnel reflector to remove.", "No Fresnel Reflector", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + reflectors.size() + " Fresnel reflectors" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(reflectors);
for (final HousePart part : reflectors) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
Aggregations