use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class PvAnnualAnalysis method runAnalysis.
@Override
void runAnalysis(final JDialog parent) {
graph.info = "Calculating...";
graph.repaint();
onStart();
final EnergyPanel e = EnergyPanel.getInstance();
for (final int m : MONTHS) {
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
if (!analysisStopped) {
final Calendar c = Heliodon.getInstance().getCalendar();
c.set(Calendar.MONTH, m);
final Calendar today = (Calendar) c.clone();
Scene.getInstance().updateTrackables();
final Throwable t = compute();
if (t != null) {
stopAnalysis();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
BugReporter.report(t);
}
});
}
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Foundation) {
// synchronize with daily graph
final PvProjectDailyEnergyGraph g = e.getPvProjectDailyEnergyGraph();
if (g.hasGraph()) {
g.setCalendar(today);
g.updateGraph();
}
}
final Calendar today2 = today;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
e.getDateSpinner().setValue(c.getTime());
if (selectedPart instanceof Foundation) {
final PvProjectDailyEnergyGraph g = e.getPvProjectDailyEnergyGraph();
e.getPvProjectTabbedPane().setSelectedComponent(g);
if (!g.hasGraph()) {
g.setCalendar(today2);
g.addGraph((Foundation) selectedPart);
}
}
}
});
}
return null;
}
});
}
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
onCompletion();
if (Heliodon.getInstance().getCalendar().get(Calendar.MONTH) != Calendar.DECEMBER) {
// annual calculation aborted
return;
}
final String current = Graph.TWO_DECIMALS.format(getResult("Solar"));
final Map<String, Double> recordedResults = getRecordedResults("Solar");
final int n = recordedResults.size();
if (n > 0) {
String previousRuns = "";
final Object[] keys = recordedResults.keySet().toArray();
for (int i = n - 1; i >= 0; i--) {
previousRuns += keys[i] + " : " + Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + " kWh<br>";
}
final Object[] options = new Object[] { "OK", "Copy Data" };
final String msg = "<html>The calculated annual output is <b>" + current + " kWh</b>.<br><hr>Results from previously recorded tests:<br>" + previousRuns + "</html>";
final JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Annual Photovoltaic Output");
dialog.setVisible(true);
final Object choice = optionPane.getValue();
if (choice == options[1]) {
String output = "";
for (int i = 0; i < n; i++) {
output += Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + "\n";
}
output += current;
final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(new StringSelection(output), null);
JOptionPane.showMessageDialog(MainFrame.getInstance(), "<html>" + (n + 1) + " data points copied to system clipboard.<br><hr>" + output, "Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(parent, "<html>The calculated annual output is <b>" + current + " kWh</b>.</html>", "Annual Photovoltaic Output", JOptionPane.INFORMATION_MESSAGE);
}
}
});
return null;
}
});
}
use of org.concord.energy3d.model.Foundation 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.Foundation in project energy3d by concord-consortium.
the class RescaleBuildingCommand method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
if (foundation.isGroupMaster()) {
final List<Foundation> g = Scene.getInstance().getFoundationGroup(foundation);
for (final Foundation f : g) {
f.rescale(newXLength / oldXLength, newYLength / oldYLength, newZLength / oldZLength);
f.draw();
f.drawChildren();
}
} else {
foundation.rescale(newXLength / oldXLength, newYLength / oldYLength, newZLength / oldZLength);
foundation.draw();
foundation.drawChildren();
}
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class ChangeSolarReceiverEfficiencyForAllReflectorsCommand method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
final int n = reflectors.size();
for (int i = 0; i < n; i++) {
final SolarReflector r = reflectors.get(i);
if (r instanceof HousePart) {
final Foundation f = ((HousePart) r).getTopContainer();
f.setSolarReceiverEfficiency(newValues[i]);
}
}
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class ChangeSolarReceiverEfficiencyForAllReflectorsCommand method undo.
@Override
public void undo() throws CannotUndoException {
super.undo();
final int n = reflectors.size();
newValues = new double[n];
for (int i = 0; i < n; i++) {
final SolarReflector r = reflectors.get(i);
if (r instanceof HousePart) {
final Foundation f = ((HousePart) r).getTopContainer();
newValues[i] = f.getSolarReceiverEfficiency();
f.setSolarReceiverEfficiency(oldValues[i]);
}
}
}
Aggregations