use of org.concord.energy3d.gui.EnergyPanel in project energy3d by concord-consortium.
the class Scene method init.
private void init() {
root.detachAllChildren();
originalHouseRoot.detachAllChildren();
notReceivingShadowRoot.detachAllChildren();
root.attachChild(originalHouseRoot);
root.attachChild(notReceivingShadowRoot);
if (url != null) {
for (final HousePart p : parts) {
final boolean b = p instanceof Tree || p instanceof Human;
(b ? notReceivingShadowRoot : originalHouseRoot).attachChild(p.getRoot());
}
System.out.println("initSceneNow done");
}
root.updateWorldBound(true);
SceneManager.getInstance().updateHeliodonAndAnnotationSize();
SceneManager.getInstance().setAxesVisible(!hideAxes);
SceneManager.getInstance().getSolarLand().setVisible(solarMapForLand);
setTheme(theme);
SceneManager.getInstance().getLand().setDefaultColor(landColor != null ? landColor : new ColorRGBA(0, 1, 0, 0.5f));
PvModulesData.getInstance();
final EnergyPanel energyPanel = EnergyPanel.getInstance();
if (calendar != null) {
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (url == null) {
// if a new file is created, its default time is always set to noon so that the user does not get a dark night scene
calendar.set(Calendar.HOUR_OF_DAY, 12);
calendar.set(Calendar.MINUTE, 0);
}
final Date time = calendar.getTime();
Heliodon.getInstance().setDate(time);
Heliodon.getInstance().setTime(time);
Util.setSilently(energyPanel.getDateSpinner(), time);
Util.setSilently(energyPanel.getTimeSpinner(), time);
if ("Boston".equals(city) || city == null || "".equals(city)) {
city = "Boston, MA";
latitude = 42;
}
// already silent
energyPanel.setLatitude(latitude);
Util.selectSilently(energyPanel.getCityComboBox(), city);
final LocationData ld = LocationData.getInstance();
if (ld.getLatitudes().get(city) != null) {
energyPanel.getCityComboBox().setToolTipText("<html>(" + ld.getLatitudes().get(city) + "°, " + ld.getLongitudes().get(city) + "°), elevation " + ld.getAltitudes().get(city).intValue() + "m<br>Use Edit>Set Region... to select country and region.</html>");
} else {
JOptionPane.showMessageDialog(MainFrame.getInstance(), city + " not supported. Please upgrade your Energy3D to the latest.", "Missing City", JOptionPane.ERROR_MESSAGE);
}
Scene.getInstance().updateTreeLeaves();
SceneManager.getInstance().changeSkyTexture();
if (!first) {
SceneManager.getInstance().setHeliodonVisible(isHeliodonVisible);
Util.selectSilently(MainPanel.getInstance().getHeliodonButton(), isHeliodonVisible);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
MainPanel.getInstance().getSunAnimationButton().setEnabled(isHeliodonVisible);
}
});
}
Heliodon.getInstance().drawSun();
SceneManager.getInstance().setShading(Heliodon.getInstance().isNightTime());
}
// previous versions do not have the following classes
if (designSpecs == null) {
designSpecs = new DesignSpecs();
} else {
designSpecs.setDefaultValues();
}
if (pvDesignSpecs == null) {
pvDesignSpecs = new PvDesignSpecs();
} else {
pvDesignSpecs.setDefaultValues();
}
if (cspDesignSpecs == null) {
cspDesignSpecs = new CspDesignSpecs();
} else {
cspDesignSpecs.setDefaultValues();
}
if (pvCustomPrice == null) {
pvCustomPrice = new PvCustomPrice();
} else {
pvCustomPrice.setDefaultValues();
}
if (cspCustomPrice == null) {
cspCustomPrice = new CspCustomPrice();
} else {
cspCustomPrice.setDefaultValues();
}
if (ground == null) {
ground = new Ground();
}
if (atmosphere == null) {
atmosphere = new Atmosphere();
}
if (unit == null) {
unit = Unit.InternationalSystemOfUnits;
}
// restore the default values
if (Util.isZero(heatVectorLength)) {
heatVectorLength = 5000;
}
if (Util.isZero(heatFluxGridSize)) {
heatFluxGridSize = 2;
}
if (Util.isZero(solarStep)) {
solarStep = 2;
}
if (Util.isZero(timeStep)) {
timeStep = 15;
}
if (Util.isZero(solarPanelNx)) {
solarPanelNx = 4;
}
if (Util.isZero(solarPanelNy)) {
solarPanelNy = 4;
}
if (Util.isZero(rackNx)) {
rackNx = 8;
}
if (Util.isZero(rackNy)) {
rackNy = 8;
}
if (Util.isZero(mirrorNx)) {
mirrorNx = 4;
}
if (Util.isZero(mirrorNy)) {
mirrorNy = 4;
}
if (Util.isZero(parabolicDishN)) {
parabolicDishN = 4;
}
if (Util.isZero(rackCellSize)) {
rackCellSize = 1;
}
if (Util.isZero(solarContrast)) {
solarContrast = 50;
}
// in case we need to have more instruction sheets
if (instructionSheetText != null) {
if (instructionSheetText.length < INSTRUCTION_SHEET_NUMBER) {
final String[] tmp = new String[INSTRUCTION_SHEET_NUMBER];
System.arraycopy(instructionSheetText, 0, tmp, 0, instructionSheetText.length);
instructionSheetText = tmp;
}
}
if (instructionSheetTextType != null) {
if (instructionSheetTextType.length < INSTRUCTION_SHEET_NUMBER) {
final String[] tmp = new String[INSTRUCTION_SHEET_NUMBER];
System.arraycopy(instructionSheetTextType, 0, tmp, 0, instructionSheetTextType.length);
instructionSheetTextType = tmp;
}
}
setEdited(false);
setCopyBuffer(null);
Util.setSilently(energyPanel.getColorMapSlider(), solarContrast);
// need to do this to avoid logging
Util.setSilently(MainPanel.getInstance().getNoteTextArea(), note == null ? "" : note);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
energyPanel.updateThermostat();
// necessary for the scroll bars to show up appropriately
MainPanel.getInstance().setNoteVisible(MainPanel.getInstance().isNoteVisible());
// moved from OpenNow to here to avoid triggering EnergyComputer -> RedrawAllNow before open is completed
MainPanel.getInstance().getEnergyButton().setSelected(false);
SceneManager.getInstance().getUndoManager().discardAllEdits();
MainApplication.getEventLog().clear();
}
});
}
use of org.concord.energy3d.gui.EnergyPanel in project energy3d by concord-consortium.
the class ParabolicTroughAnnualAnalysis 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 CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
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 CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
e.getCspProjectTabbedPane().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 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 Output", JOptionPane.INFORMATION_MESSAGE);
}
}
});
return null;
}
});
}
use of org.concord.energy3d.gui.EnergyPanel 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.gui.EnergyPanel in project energy3d by concord-consortium.
the class EnergyAnnualAnalysis 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() throws Exception {
Calendar today;
if (!analysisStopped) {
final Calendar c = Heliodon.getInstance().getCalendar();
c.set(Calendar.MONTH, m);
today = (Calendar) c.clone();
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
if (e.getBuildingDailyEnergyGraph().hasGraph()) {
e.getBuildingDailyEnergyGraph().setCalendar(today);
e.getBuildingDailyEnergyGraph().updateGraph();
}
}
final Calendar today2 = today;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
EnergyPanel.getInstance().getDateSpinner().setValue(c.getTime());
if (selectedPart instanceof Foundation) {
e.getBuildingTabbedPane().setSelectedComponent(e.getBuildingDailyEnergyGraph());
if (!e.getBuildingDailyEnergyGraph().hasGraph()) {
e.getBuildingDailyEnergyGraph().setCalendar(today2);
e.getBuildingDailyEnergyGraph().addGraph((Foundation) selectedPart);
}
}
}
});
}
return null;
}
});
}
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() throws Exception {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
onCompletion();
if (graph instanceof BuildingEnergyAnnualGraph) {
if (Heliodon.getInstance().getCalendar().get(Calendar.MONTH) != Calendar.DECEMBER) {
// annual calculation aborted
return;
}
final int net = (int) Math.round(getResult("Net"));
final Map<String, Double> recordedResults = getRecordedResults("Net");
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 net energy is <b>" + net + " 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 Net Energy");
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 += Graph.TWO_DECIMALS.format(getResult("Net"));
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 net energy is <b>" + net + " kWh</b>.</html>", "Annual Net Energy", JOptionPane.INFORMATION_MESSAGE);
}
}
}
});
return null;
}
});
}
use of org.concord.energy3d.gui.EnergyPanel in project energy3d by concord-consortium.
the class FresnelReflectorAnnualAnalysis 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 CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
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 CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
e.getCspProjectTabbedPane().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 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 Output", JOptionPane.INFORMATION_MESSAGE);
}
}
});
return null;
}
});
}
Aggregations