[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Classification.java, NONE, 1.1 Energ
Status: Pre-Alpha
Brought to you by:
henryml
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9449/src/net/sourceforge/bprocessor/model Modified Files: EnergyCalc.java Space.java Project.java Attribute.java Persistence.java Added Files: Classification.java Log Message: Changed the classification,to use the new classification model --- NEW FILE: Classification.java --- //--------------------------------------------------------------------------------- // $Id: Classification.java,v 1.1 2006/10/24 20:40:48 nbramsen Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Vector; import org.apache.log4j.Logger; /** * This class persist the model from/to an XML document */ public class Classification { /** The logger */ private static Logger log = Logger.getLogger(Classification.class); /** The name of the classification */ private String name; /** The id of the classification */ private Integer id; /** The children of this classification */ private Vector children = new Vector(); /** The parent of this classification */ private Classification parent; /** * The constructor for a new classification * @param id the id * @param name the name * @param parent the parent */ public Classification(Integer id, String name, Classification parent) { setName(name); setId(id); setParent(parent); } /** * Constructor for base element */ public Classification() { setName("World"); setId(new Integer(0)); } /** * Get the vector containing this classifications children * @return the children */ public Vector getChildren() { return children; } /** * Get the name of this classification * @return the name */ public String getName() { return name; } /** * Sets the name of the classification * @param name the new name for the classification */ public void setName (String name) { this.name = name; } /** * Get the id of this classification * @return the id */ public Integer getId () { return id; } /** * Set the id of this classification * @param id the id to be set */ public void setId (Integer id) { this.id = id; } /** * Adds a child to the classification * @param child the child to be added */ public void addChild(Classification child) { children.add(child); } /** * Returns the parent of this classification * @return the parent */ public Classification getParent() { return parent; } /** * Set the parent of this classification * @param parent the new parent */ public void setParent(Classification parent) { this.parent = parent; } /** * Generates the full id for this classification * @return the full id */ public String getFullId() { String fullId = id.toString(); Classification par = parent; while (!par.getName().equalsIgnoreCase("World")) { fullId = par.getId() + "." + fullId; par = par.getParent(); } return fullId; } /** * returns the name of the classification if toString is called * @return returns the name as a string */ public String toString() { return name; } } Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Persistence.java 16 Oct 2006 12:19:32 -0000 1.15 --- Persistence.java 24 Oct 2006 20:40:48 -0000 1.16 *************** *** 164,168 **** space.setId(new Long(xml.getProgid())); space.setDescription(xml.getDescription()); ! space.setClassification(xml.getClassification()); mapper.put(new Long(xml.getId()), space); --- 164,168 ---- space.setId(new Long(xml.getProgid())); space.setDescription(xml.getDescription()); ! //space.setClassification(xml.getClassification()); mapper.put(new Long(xml.getId()), space); *************** *** 689,693 **** xml.setTransparent(space.isTransparent()); xml.setDescription(space.getDescription().toString()); ! xml.setClassification(space.getClassification().toString()); map.put(space, xml); if (!space.isInstance()) { --- 689,693 ---- xml.setTransparent(space.isTransparent()); xml.setDescription(space.getDescription().toString()); ! //xml.setClassification(space.getClassification().toString()); map.put(space, xml); if (!space.isInstance()) { Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Project.java 17 Oct 2006 09:11:07 -0000 1.85 --- Project.java 24 Oct 2006 20:40:48 -0000 1.86 *************** *** 8,12 **** --- 8,14 ---- package net.sourceforge.bprocessor.model; + import java.io.BufferedReader; import java.io.File; + import java.io.FileReader; import java.util.ArrayList; import java.util.Collection; *************** *** 17,20 **** --- 19,23 ---- import java.util.List; import java.util.Stack; + import java.util.StringTokenizer; import net.sourceforge.bprocessor.model.modellor.LayerModellor; *************** *** 43,46 **** --- 46,52 ---- private Space world; + /** The classification */ + private Classification clas = new Classification(); + /** The cameras */ private HashMap cameras = new HashMap(); *************** *** 123,126 **** --- 129,138 ---- globals.put("pi", Math.PI); Modellor.registerModellor(new LayerModellor()); + try { + loadClassification(); + } catch (Exception e) { + System.out.println("loading classification"); + e.printStackTrace(); + } makeClean(); } *************** *** 791,793 **** --- 803,865 ---- log.info(object); } + + /** + * This method loads the classification document from a file + * @exception Exception Thrown if an exception occurs + */ + public void loadClassification() throws Exception { + String current = ""; + String token = ""; + String curname = ""; + Integer curid; + Classification parent = new Classification(); + Classification last = new Classification(); + int depth = 0; + int lastdepth = 0; + BufferedReader bf = new BufferedReader(new FileReader("classification.csv")); + current = bf.readLine(); + while (!current.equalsIgnoreCase("--stop--")) { + StringTokenizer st = new StringTokenizer(current, ";", true); + while (st.hasMoreTokens()) { + token = st.nextToken(); + if (depth == 0 && !token.equalsIgnoreCase(";")) { + curid = new Integer(token); + st.nextToken(); + curname = st.nextToken(); + Classification curclas = new Classification(curid, curname, clas); + parent = curclas; + clas.addChild(curclas); + lastdepth = 0; + last = curclas; + } else if (token.equalsIgnoreCase(";")) { + depth++; + } else if (depth != 0 && !token.equalsIgnoreCase(";")) { + curid = new Integer(token); + st.nextToken(); + curname = st.nextToken(); + if (depth > lastdepth) { + parent = last; + } + if (depth < lastdepth) { + parent = parent.getParent(); + } + Classification curclas = new Classification(curid, curname, parent); + parent.addChild(curclas); + last = curclas; + lastdepth = depth; + } + } + depth = 0; + current = bf.readLine(); + } + } + + /** + * this method returns the classification + * @return Classification the classification + * */ + public Classification getClassification () { + return clas; + } + } Index: Attribute.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Attribute.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Attribute.java 17 Jul 2006 08:37:00 -0000 1.12 --- Attribute.java 24 Oct 2006 20:40:48 -0000 1.13 *************** *** 28,32 **** /** The classification */ ! private String classification; /** The precision of the object */ --- 28,32 ---- /** The classification */ ! private Classification classification; /** The precision of the object */ *************** *** 93,97 **** * @param classification The classification */ ! public Attribute(String name, Object value, String classification) { setName(name); setValue(value); --- 93,97 ---- * @param classification The classification */ ! public Attribute(String name, Object value, Classification classification) { setName(name); setValue(value); *************** *** 131,135 **** * @return Returns the classification. */ ! public String getClassification() { return classification; } --- 131,135 ---- * @return Returns the classification. */ ! public Classification getClassification() { return classification; } *************** *** 138,142 **** * @param classification The classification to set. */ ! public void setClassification(String classification) { this.classification = classification; } --- 138,142 ---- * @param classification The classification to set. */ ! public void setClassification(Classification classification) { this.classification = classification; } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** Space.java 23 Oct 2006 06:48:46 -0000 1.86 --- Space.java 24 Oct 2006 20:40:48 -0000 1.87 *************** *** 120,124 **** /** The classification */ ! private String classification; /** If the constructionspace is transparent */ --- 120,124 ---- /** The classification */ ! private Classification classification; /** If the constructionspace is transparent */ *************** *** 198,202 **** this.level = level; setTransparent(false); - setClassification("None"); this.container = container; description = new Description(""); --- 198,201 ---- *************** *** 1015,1019 **** * @return The classification */ ! public String getClassification() { return classification; } --- 1014,1018 ---- * @return The classification */ ! public Classification getClassification() { return classification; } *************** *** 1022,1026 **** * @param classification The classification */ ! public void setClassification(String classification) { this.classification = classification; } --- 1021,1025 ---- * @param classification The classification */ ! public void setClassification(Classification classification) { this.classification = classification; } *************** *** 1318,1322 **** setName((String)a.getValue()); } else if (a.getName().equals("Classification")) { ! setClassification(((String)a.getValue().toString())); } else if (a.getName().equals("Transparent")) { setTransparent((((Boolean)a.getValue()).booleanValue())); --- 1317,1332 ---- setName((String)a.getValue()); } else if (a.getName().equals("Classification")) { ! if (getOwner() == Project.getInstance().world()) { ! setClassification(((Classification)a.getValue())); ! } ! if (getLevel() == Space.ELEMENT_LEVEL) { ! setClassification(((Classification)a.getValue())); ! getOwner().setClassification(classification.getParent()); ! } ! if (getLevel() == Space.PART_LEVEL) { ! setClassification(((Classification)a.getValue())); ! getOwner().setClassification(classification.getParent()); ! getOwner().getOwner().setClassification(classification.getParent().getParent()); ! } } else if (a.getName().equals("Transparent")) { setTransparent((((Boolean)a.getValue()).booleanValue())); *************** *** 1337,1344 **** res.add(new Attribute("Owner", getOwner(), false)); if (getOwner() == Project.getInstance().world()) { ! if (isConstructionSpace()) { ! res.add(new Attribute("Classification", constructionOptions, getClassification())); } else { ! res.add(new Attribute("Classification", functionalOptions, getClassification())); } } else { --- 1347,1356 ---- res.add(new Attribute("Owner", getOwner(), false)); if (getOwner() == Project.getInstance().world()) { ! if (isConstructionSpace()) { ! ! res.add(new Attribute("Classification", ! Project.getInstance().getClassification(), getClassification())); } else { ! //res.add(new Attribute("Classification", functionalOptions, getClassification())); } } else { *************** *** 1346,1358 **** if (getLevel() == Space.ELEMENT_LEVEL) { if (isConstructionSpace()) { ! res.add(new Attribute("Classification", elementConstructionOptions, getClassification())); } else { ! res.add(new Attribute("Classification", elementFunctionalOptions, getClassification())); } } else if (getLevel() == Space.PART_LEVEL) { if (isConstructionSpace()) { ! res.add(new Attribute("Classification", partConstructionOptions, getClassification())); } else { ! res.add(new Attribute("Classification", partFunctionalOptions, getClassification())); } } --- 1358,1382 ---- if (getLevel() == Space.ELEMENT_LEVEL) { if (isConstructionSpace()) { ! if (getOwner().getClassification() != null) { ! res.add(new Attribute("Classification", ! getOwner().getClassification(), getClassification())); ! } else { ! res.add(new Attribute("Classification", ! Project.getInstance().getClassification(), getClassification())); ! } } else { ! //res.add(new Attribute("Classification", elementFunctionalOptions, getClassification())); } } else if (getLevel() == Space.PART_LEVEL) { if (isConstructionSpace()) { ! if (getOwner().getClassification() != null) { ! res.add(new Attribute("Classification", ! getOwner().getClassification(), getClassification())); ! } else { ! res.add(new Attribute("Classification", ! Project.getInstance().getClassification(), getClassification())); ! } } else { ! //res.add(new Attribute("Classification", partFunctionalOptions, getClassification())); } } *************** *** 1384,1388 **** return res; } ! /** * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() --- 1408,1412 ---- return res; } ! /** * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() Index: EnergyCalc.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/EnergyCalc.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EnergyCalc.java 5 Oct 2006 11:27:04 -0000 1.2 --- EnergyCalc.java 24 Oct 2006 20:40:48 -0000 1.3 *************** *** 24,37 **** 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); } --- 24,38 ---- while (it.hasNext()) { Surface current = (Surface) it.next(); ! if (current.getFrontDomain().getClassification().getName().equalsIgnoreCase("Exteriør")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); } ! if (current.getFrontDomain().getClassification().getName(). ! equalsIgnoreCase("Uopvarmet rum")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); } ! if (current.getBackDomain().getClassification().getName().equalsIgnoreCase("Exteriør")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); } ! if (current.getBackDomain().getClassification().getName().equalsIgnoreCase("Uopvarmet rum")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); } *************** *** 58,92 **** 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; --- 59,95 ---- if (elemcheck.getName().equalsIgnoreCase("Void") && first) { ! if (classification.getClassification().getName().equalsIgnoreCase("Terrandæk")) { loss = 0.15 * current.getArea(); return loss; } ! if (classification.getClassification().getName().equalsIgnoreCase("Tagkonstruktion")) { loss = 0.15 * current.getArea(); return loss; } ! if (classification.getClassification().getName().equalsIgnoreCase("Loft")) { loss = 0.15 * current.getArea(); return loss; } ! if (classification.getClassification().getName().equalsIgnoreCase("Ydervæg")) { loss = 0.25 * current.getArea(); return loss; } ! if (classification.getClassification().getName().equalsIgnoreCase("Ældre termovindue")) { loss = 2.5 * current.getArea(); return loss; } ! if (classification.getClassification(). ! getName().equalsIgnoreCase("2-lags lavenergivindue")) { loss = 1.5 * current.getArea(); return loss; } ! if (classification.getClassification(). ! getName().equalsIgnoreCase("3-lags lavenergivindue")) { loss = 0.8 * current.getArea(); return loss; } ! if (classification.getClassification().getName().equalsIgnoreCase("Dør")) { loss = 1.5 * current.getArea(); return loss; *************** *** 146,152 **** if (spa != null && ! (spa.getClassification().equalsIgnoreCase("Stue") || ! spa.getClassification().equalsIgnoreCase("Badeværelse") || ! spa.getClassification().equalsIgnoreCase("Opvarmet rum"))) { relevant = true; --- 149,155 ---- if (spa != null && ! (spa.getClassification().getName().equalsIgnoreCase("Stue") || ! spa.getClassification().getName().equalsIgnoreCase("Badeværelse") || ! spa.getClassification().getName().equalsIgnoreCase("Opvarmet rum"))) { relevant = true; *************** *** 171,177 **** spa = current.getFrontDomain(); if (spa.getClassification() != null && ! (spa.getClassification().equalsIgnoreCase("Stue") || ! spa.getClassification().equalsIgnoreCase("Badeværelse") || ! spa.getClassification().equalsIgnoreCase("Opvarmet rum"))) { tha = tha + current.getArea(); } --- 174,180 ---- spa = current.getFrontDomain(); if (spa.getClassification() != null && ! (spa.getClassification().getName().equalsIgnoreCase("Stue") || ! spa.getClassification().getName().equalsIgnoreCase("Badeværelse") || ! spa.getClassification().getName().equalsIgnoreCase("Opvarmet rum"))) { tha = tha + current.getArea(); } *************** *** 180,186 **** spa = current.getBackDomain(); if (spa.getClassification() != null && ! (spa.getClassification().equalsIgnoreCase("Stue") || ! spa.getClassification().equalsIgnoreCase("Badeværelse") || ! spa.getClassification().equalsIgnoreCase("Opvarmet rum"))) { tha = tha + current.getArea(); } --- 183,189 ---- spa = current.getBackDomain(); if (spa.getClassification() != null && ! (spa.getClassification().getName().equalsIgnoreCase("Stue") || ! spa.getClassification().getName().equalsIgnoreCase("Badeværelse") || ! spa.getClassification().getName().equalsIgnoreCase("Opvarmet rum"))) { tha = tha + current.getArea(); } |