[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/actions ToolsEnergyActionListener.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-09-11 09:20:39
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7586/src/net/sourceforge/bprocessor/gui/actions Modified Files: ToolsEnergyActionListener.java Log Message: moved the energycalculations to the model Index: ToolsEnergyActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ToolsEnergyActionListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ToolsEnergyActionListener.java 5 Sep 2006 07:28:39 -0000 1.5 --- ToolsEnergyActionListener.java 11 Sep 2006 09:19:54 -0000 1.6 *************** *** 7,18 **** package net.sourceforge.bprocessor.gui.actions; ! import net.sourceforge.bprocessor.model.Project; ! import net.sourceforge.bprocessor.model.Space; ! import net.sourceforge.bprocessor.model.Surface; ! import net.sourceforge.bprocessor.model.Vertex; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ! import java.util.Iterator; import javax.swing.JOptionPane; --- 7,15 ---- package net.sourceforge.bprocessor.gui.actions; ! import net.sourceforge.bprocessor.model.EnergyCalc; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ! import javax.swing.JOptionPane; *************** *** 39,180 **** public void actionPerformed(ActionEvent e) { ! Iterator it = Project.getInstance().getSurfaces().iterator(); ! double totalloss = 0; ! ! while (it.hasNext()) { ! Surface current = (Surface) it.next(); ! if (current.getFrontDomain().getClassification().equalsIgnoreCase("Exteriør")) { ! totalloss = totalloss + calcloss(current.getBackDomain(), current); ! } ! if (current.getFrontDomain().getClassification().equalsIgnoreCase("Uopvarmet rum")) { ! totalloss = totalloss + calcloss(current.getBackDomain(), current); ! } ! if (current.getBackDomain().getClassification().equalsIgnoreCase("Exteriør")) { ! totalloss = totalloss + calcloss(current.getFrontDomain(), current); ! } ! if (current.getBackDomain().getClassification().equalsIgnoreCase("Uopvarmet rum")) { ! totalloss = totalloss + calcloss(current.getFrontDomain(), current); ! } ! } ! ! JOptionPane.showMessageDialog(null, "The total energytransmission loss is: " + totalloss); ! ! ! } ! ! /** ! * Calculates energyloss of a surface ! * @param classification The classifaction of the surface ! * @param current The current Surface ! * @return the loss ! */ ! private double calcloss(Space classification, Surface current) { ! double loss = 0; ! boolean first = true; ! if (isrelevant(classification, current)) { ! Iterator it = classification.getElements().iterator(); ! ! ! while (it.hasNext()) { ! Space elemcheck = (Space) it.next(); ! if (elemcheck.getName().equalsIgnoreCase("Void") && first) { ! ! if (classification.getClassification().equalsIgnoreCase("Terrandæk")) { ! loss = 0.15 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().equalsIgnoreCase("Tagkonstruktion")) { ! loss = 0.15 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().equalsIgnoreCase("Loft")) { ! loss = 0.15 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().equalsIgnoreCase("Ydervæg")) { ! loss = 0.25 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().equalsIgnoreCase("Ældre termovindue")) { ! loss = 2.5 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().equalsIgnoreCase("2-lags lavenergivindue")) { ! loss = 1.5 * current.getArea(); ! return loss; ! } ! ! if (classification.getClassification().equalsIgnoreCase("3-lags lavenergivindue")) { ! loss = 0.8 * current.getArea(); ! return loss; ! } ! ! if (classification.getClassification().equalsIgnoreCase("Dør")) { ! loss = 1.5 * current.getArea(); ! return loss; ! } ! System.out.println("void - no more element spaces"); ! } ! if (!elemcheck.getName().equalsIgnoreCase("Void")) { ! System.out.println(elemcheck.getName()); ! } ! first = false; ! } ! ! } ! return loss; ! } ! ! /** ! * Test if the surface is relevant for thermiccalculation ! * @param classification The classifaction of the surface ! * @param current The current Surface ! * @return true if the surface is relevant ! */ ! private boolean isrelevant(Space classification, Surface current) { ! boolean relevant = false; ! Vertex normal = current.normal(); ! if (current.getBackDomain().isConstructionSpace()) { ! normal.scale(-1); ! } ! Vertex origin = current.center(); ! double distance = 0; ! Surface closest = null; ! Space spa = null; ! ! Iterator it = Project.getInstance().getSurfaces().iterator(); ! ! while (it.hasNext()) { ! Surface sur = (Surface) it.next(); ! Vertex interpoint = sur.plane().intersection(origin, normal, true); ! if (interpoint != null) { ! if (sur.surrounds(interpoint)) { ! if (sur.getFrontDomain().isFunctionalSpace() || sur.getBackDomain().isFunctionalSpace()) { ! if (origin.distance(interpoint) != 0 && ! (distance == 0 || distance > origin.distance(interpoint))) { ! distance = origin.distance(interpoint); ! closest = sur; ! } ! } ! } ! } ! } ! if (closest != null && closest.getFrontDomain().isFunctionalSpace()) { ! spa = closest.getFrontDomain(); ! } ! if (closest != null && closest.getBackDomain().isFunctionalSpace()) { ! spa = closest.getBackDomain(); ! } ! ! if (spa != null && ! (spa.getClassification().equalsIgnoreCase("Stue") || ! spa.getClassification().equalsIgnoreCase("Badeværelse") || ! spa.getClassification().equalsIgnoreCase("Opvarmet rum"))) { ! relevant = true; - } - - - return relevant; } } --- 36,42 ---- public void actionPerformed(ActionEvent e) { ! JOptionPane.showMessageDialog(null, ! "The total energytransmission loss is: " + EnergyCalc.energyLoss()); } } |