[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Space.java, 1.165, 1.166 Attribute.j
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-08-09 16:08:00
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4350/src/net/sourceforge/bprocessor/model Modified Files: Space.java Attribute.java Persistence.java Surface.java Classification.java ClassificationType.java Project.java ClassificationFileReader.java Log Message: Made the way the attributes are pressented for classification and classificationtype look better and added a types folder to the DBK tree. Made the project hold all the possible types to make it possible to alter them. Space can now hold their own classificationtype parameter values if they are altered there. Index: ClassificationFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ClassificationFileReader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClassificationFileReader.java 23 Jul 2007 13:58:13 -0000 1.3 --- ClassificationFileReader.java 9 Aug 2007 16:07:53 -0000 1.4 *************** *** 45,51 **** new File(args[0] + "Classification.xml")); log.info("Wrote XML"); ! Classification[] loaded = Persistence.loadDBK(new File(args[0] + "Classification.xml")); ! construction = loaded[0]; ! functional = loaded[1]; log.info("Read XML"); } --- 45,51 ---- new File(args[0] + "Classification.xml")); log.info("Wrote XML"); ! Object[] loaded = Persistence.loadDBK(new File(args[0] + "Classification.xml")); ! construction = (Classification)loaded[0]; ! functional = (Classification)loaded[1]; log.info("Read XML"); } Index: Classification.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Classification.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Classification.java 23 Jul 2007 13:58:13 -0000 1.20 --- Classification.java 9 Aug 2007 16:07:53 -0000 1.21 *************** *** 171,175 **** res.add(new Attribute("Name", getName(), false)); res.add(new Attribute("Code", getFullId(null), false)); ! res.add(new Attribute("Type link", possibleTypes, possibleTypes)); return res; } --- 171,175 ---- res.add(new Attribute("Name", getName(), false)); res.add(new Attribute("Code", getFullId(null), false)); ! res.add(new Attribute("Classification Type", null, possibleTypes)); return res; } Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.171 retrieving revision 1.172 diff -C2 -d -r1.171 -r1.172 *** Surface.java 20 Jul 2007 13:33:26 -0000 1.171 --- Surface.java 9 Aug 2007 16:07:53 -0000 1.172 *************** *** 1864,1877 **** * @param p The plane to extrude onto * @param sides The the collection of already extruded sides (if none the resulting is added) * @param tops The top surfaces * @return the new created extrusion top surface */ ! public Surface extrusionAllOnto(Plane p, Collection sides, Set tops) { ! Surface top = extrusionOnto(p, sides); tops.add(top); Iterator iter = getHoles().iterator(); while (iter.hasNext()) { Surface hole = (Surface) iter.next(); ! Surface holetop = hole.extrusionAllOnto(p, sides, tops); top.addHole(holetop); } --- 1864,1879 ---- * @param p The plane to extrude onto * @param sides The the collection of already extruded sides (if none the resulting is added) + * @param distance the distance of the extrusion as a backup if the plane is orthogonal * @param tops The top surfaces * @return the new created extrusion top surface */ ! public Surface extrusionAllOnto(Plane p, double distance, ! Collection<Surface> sides, Set<Surface> tops) { ! Surface top = extrusionOnto(p, distance, sides); tops.add(top); Iterator iter = getHoles().iterator(); while (iter.hasNext()) { Surface hole = (Surface) iter.next(); ! Surface holetop = hole.extrusionAllOnto(p, distance, sides, tops); top.addHole(holetop); } *************** *** 1882,1888 **** * @param p the plane to extrude onto * @param sides the collection of all resulting side surfaces * @return the new extrusion top surface */ ! public Surface extrusionOnto(Plane p, Collection sides) { if (p == null) { log.info("p were null for " + this); --- 1884,1891 ---- * @param p the plane to extrude onto * @param sides the collection of all resulting side surfaces + * @param distance The distance of the extrusion as a backup when plane is orthogonal * @return the new extrusion top surface */ ! public Surface extrusionOnto(Plane p, double distance, Collection<Surface> sides) { if (p == null) { log.info("p were null for " + this); *************** *** 1908,1913 **** vmap[i] = inter; } else { ! log.info("The found intersection were null"); ! vmap[i] = v[i].copy().add(normal); } } --- 1911,1917 ---- vmap[i] = inter; } else { ! Vertex ncopy = normal.copy(); ! ncopy.scale(distance); ! vmap[i] = v[i].copy().add(ncopy); } } Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** Project.java 23 Jul 2007 13:58:13 -0000 1.131 --- Project.java 9 Aug 2007 16:07:53 -0000 1.132 *************** *** 60,63 **** --- 60,65 ---- /** The classification */ private static Classification functionalClas = null; + + private static Collection<ClassificationType> classificatioTypes; /** The cameras */ *************** *** 120,126 **** instance = new Project(); try { ! Classification[] loaded = Persistence.loadDBK(new File("Classification.xml")); ! constructionClas = loaded[0]; ! functionalClas = loaded[1]; /*Map<String, ClassificationType> typeMap = ClassificationFileReader.loadTypes(""); constructionClas = ClassificationFileReader.loadClassification(true, "", typeMap); --- 122,129 ---- instance = new Project(); try { ! Object[] loaded = Persistence.loadDBK(new File("Classification.xml")); ! constructionClas = (Classification)loaded[0]; ! functionalClas = (Classification)loaded[1]; ! classificatioTypes = (Collection<ClassificationType>)loaded[2]; /*Map<String, ClassificationType> typeMap = ClassificationFileReader.loadTypes(""); constructionClas = ClassificationFileReader.loadClassification(true, "", typeMap); *************** *** 850,854 **** * @return Classification the construction space classification * */ ! public Classification getConstructionClas () { return constructionClas; } --- 853,857 ---- * @return Classification the construction space classification * */ ! public static Classification getConstructionClas () { return constructionClas; } *************** *** 858,862 **** * @return Classification the funcational space classification * */ ! public Classification getFunctionalClas () { return functionalClas; } --- 861,865 ---- * @return Classification the funcational space classification * */ ! public static Classification getFunctionalClas () { return functionalClas; } *************** *** 994,996 **** --- 997,1014 ---- return copyBuffer; } + + /** + * @return the classificatioTypes + */ + public static Collection<ClassificationType> getClassificatioTypes() { + return classificatioTypes; + } + + /** + * @param classificatioTypes the classificatioTypes to set + */ + public static void setClassificatioTypes( + List<ClassificationType> classificatioTypes) { + Project.classificatioTypes = classificatioTypes; + } } Index: Attribute.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Attribute.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Attribute.java 23 Jul 2007 13:58:11 -0000 1.21 --- Attribute.java 9 Aug 2007 16:07:53 -0000 1.22 *************** *** 100,105 **** public Attribute(String name, Object value, Classification classification, Space level) { setName(name); ! setValue(value); ! setThe2ndValue(classification); setLevel(level); editable = true; --- 100,105 ---- public Attribute(String name, Object value, Classification classification, Space level) { setName(name); ! setThe2ndValue(value); ! setValue(classification); setLevel(level); editable = true; *************** *** 109,113 **** * Constructor for Classification Attribute * @param name The name ! * @param rootClassification The outermost possible type * @param selectedClassification The chosen type (can be null) */ --- 109,113 ---- * Constructor for Classification Attribute * @param name The name ! * @param rootClassification The outermost possible type (null for a link) * @param selectedClassification The chosen type (can be null) */ *************** *** 116,121 **** ClassificationType selectedClassification) { setName(name); ! setThe2ndValue(selectedClassification); ! setValue(rootClassification); editable = true; } --- 116,121 ---- ClassificationType selectedClassification) { setName(name); ! setValue(selectedClassification); ! setThe2ndValue(rootClassification); editable = true; } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** Space.java 26 Jul 2007 09:52:32 -0000 1.165 --- Space.java 9 Aug 2007 16:07:53 -0000 1.166 *************** *** 142,146 **** private String room = "0"; ! private Map<String, Attribute> ownParameters = new HashMap<String, Attribute>(); /** --- 142,146 ---- private String room = "0"; ! private LinkedHashMap<String, Object> ownParameters = new LinkedHashMap<String, Object>(); /** *************** *** 945,949 **** */ public void setClassification(Classification classification) { ! if (classification != null) { this.classification = classification; setClassificationType(classification.getPossibleTypes()); --- 945,949 ---- */ public void setClassification(Classification classification) { ! if (classification != null && this.classification != classification) { this.classification = classification; setClassificationType(classification.getPossibleTypes()); *************** *** 963,967 **** */ public void setClassificationType(ClassificationType productType) { ! this.productType = productType; } --- 963,970 ---- */ public void setClassificationType(ClassificationType productType) { ! if (this.productType != productType) { ! this.productType = productType; ! ownParameters.clear(); ! } } *************** *** 1302,1305 **** --- 1305,1309 ---- public void setAttributes(List<Attribute> attributes) { Iterator iter = attributes.iterator(); + boolean changedType = false; while (iter.hasNext()) { Attribute a = (Attribute)iter.next(); *************** *** 1307,1315 **** setName((String)a.getValue()); } else if (a.getName().equals("Classification")) { ! setClassification(((Classification)a.getThe2ndValue())); } else if (a.getName().equals("Type")) { ! ClassificationType cst = (ClassificationType)a.getThe2ndValue(); ! if (getClassification().getPossibleTypes().isPossibleSubtype(cst)) { setClassificationType(cst); } } else if (a.getName().equals("Building")) { --- 1311,1322 ---- setName((String)a.getValue()); } else if (a.getName().equals("Classification")) { ! setClassification(((Classification)a.getValue())); } else if (a.getName().equals("Type")) { ! ClassificationType cst = (ClassificationType)a.getValue(); ! if (getClassification() != null && ! getClassificationType() != cst && ! getClassification().getPossibleTypes().isPossibleSubtype(cst)) { setClassificationType(cst); + changedType = true; } } else if (a.getName().equals("Building")) { *************** *** 1325,1328 **** --- 1332,1342 ---- } else if (a.getName().equals("Description")) { setDescription(((String)a.getValue().toString())); + } else { + if (!changedType && getClassificationType() != null) { + if (getClassificationType().getParameter(a.getName()) != null && + !getClassificationType().getParameter(a.getName()).getValue().equals(a.getValue())) { + setOwnParameter(a.getName(), a.getValue()); + } + } } } *************** *** 1354,1358 **** } } else { ! if (getOwner().getClassification() != null) { res.add(new Attribute("Classification", getOwner().getClassification(), getClassification(), this)); --- 1368,1372 ---- } } else { ! if (getOwner() != null && getOwner().getClassification() != null) { res.add(new Attribute("Classification", getOwner().getClassification(), getClassification(), this)); *************** *** 1366,1370 **** res.add(new Attribute("Type", getClassification().getPossibleTypes(), getClassificationType())); ! res.addAll(getOwnParameters().values()); } if (isFunctionalSpace()) { --- 1380,1387 ---- res.add(new Attribute("Type", getClassification().getPossibleTypes(), getClassificationType())); ! HashMap<String, Object> param = getOwnParameters(); ! for (String s : param.keySet()) { ! res.add(new Attribute(s, param.get(s))); ! } } if (isFunctionalSpace()) { *************** *** 2807,2812 **** * @return A linkedHashMap with alle the parameters */ ! public LinkedHashMap<String, Attribute> getOwnParameters() { ! LinkedHashMap<String, Attribute> res = new LinkedHashMap<String, Attribute>(); if (getClassificationType() != null) { res.putAll(getClassificationType().getAllParameters()); --- 2824,2829 ---- * @return A linkedHashMap with alle the parameters */ ! public LinkedHashMap<String, Object> getOwnParameters() { ! LinkedHashMap<String, Object> res = new LinkedHashMap<String, Object>(); if (getClassificationType() != null) { res.putAll(getClassificationType().getAllParameters()); *************** *** 2823,2828 **** */ public Attribute getParameter(String string) { ! Attribute a = ownParameters.get(string); ! if (a == null) { a = getClassificationType().getParameter(string); } --- 2840,2845 ---- */ public Attribute getParameter(String string) { ! Attribute a = new Attribute(string, ownParameters.get(string)); ! if (a == null && getClassificationType() != null) { a = getClassificationType().getParameter(string); } *************** *** 2831,2834 **** --- 2848,2860 ---- /** + * Set a parameter of the space + * @param key The string rep + * @param object The object to associate with the key + */ + public void setOwnParameter(String key, Object object) { + ownParameters.put(key, object); + } + + /** * Verify that everything is OK */ Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Persistence.java 23 Jul 2007 13:58:13 -0000 1.44 --- Persistence.java 9 Aug 2007 16:07:53 -0000 1.45 *************** *** 85,88 **** --- 85,89 ---- import java.util.HashSet; import java.util.Iterator; + import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; *************** *** 1501,1506 **** } Map map = new HashMap(); ! for (Attribute a : type.getAllParameters().values()) { ! xml.getAttributes().add(externalizeKeyValue(a.getName(), a.getValue(), map)); } return xml; --- 1502,1508 ---- } Map map = new HashMap(); ! HashMap<String, Object> param = type.getAllParameters(); ! for (String s : param.keySet()) { ! xml.getAttributes().add(externalizeKeyValue(s, param.get(s), map)); } return xml; *************** *** 1514,1524 **** * @throws Exception Either an file read exception or some exception from the JAXB framework */ ! public static Classification[] loadDBK(File file) throws Exception { FileInputStream input = new FileInputStream(file); DBK xml = (DBK)loadFile(input); XMLSpecificTypeType rootType = xml.getXMLSpecificType(); ! Map<Long, ClassificationType> typeMap = new HashMap<Long, ClassificationType>(); for (XMLSpecificTypeType specType : (List<XMLSpecificTypeType>)rootType.getXMLSpecificType()) { ! internalizeTypes(specType, typeMap); } Classification construction = internalizeClassification( --- 1516,1528 ---- * @throws Exception Either an file read exception or some exception from the JAXB framework */ ! public static Object[] loadDBK(File file) throws Exception { FileInputStream input = new FileInputStream(file); DBK xml = (DBK)loadFile(input); XMLSpecificTypeType rootType = xml.getXMLSpecificType(); ! LinkedHashMap<Long, ClassificationType> typeMap = ! new LinkedHashMap<Long, ClassificationType>(); ! List<ClassificationType> types = new LinkedList<ClassificationType>(); for (XMLSpecificTypeType specType : (List<XMLSpecificTypeType>)rootType.getXMLSpecificType()) { ! types.add(internalizeTypes(specType, typeMap)); } Classification construction = internalizeClassification( *************** *** 1526,1530 **** Classification functional = internalizeClassification( (XMLClassificationType)xml.getXMLClassification().get(1), typeMap, Space.FUNCTIONAL); ! return new Classification[]{construction, functional}; } --- 1530,1534 ---- Classification functional = internalizeClassification( (XMLClassificationType)xml.getXMLClassification().get(1), typeMap, Space.FUNCTIONAL); ! return new Object[]{construction, functional, types}; } Index: ClassificationType.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ClassificationType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClassificationType.java 23 Jul 2007 13:58:13 -0000 1.3 --- ClassificationType.java 9 Aug 2007 16:07:53 -0000 1.4 *************** *** 18,22 **** public class ClassificationType extends Structure<ClassificationType> implements Parametric { private static int nextClassificationId = 0; ! private LinkedHashMap<String, Attribute> parameter; private long id; private int index; --- 18,22 ---- public class ClassificationType extends Structure<ClassificationType> implements Parametric { private static int nextClassificationId = 0; ! private LinkedHashMap<String, Object> parameter; private long id; private int index; *************** *** 45,49 **** public ClassificationType() { super(); ! parameter = new LinkedHashMap<String, Attribute>(); } --- 45,49 ---- public ClassificationType() { super(); ! parameter = new LinkedHashMap<String, Object>(); } *************** *** 64,68 **** List<Attribute> res = new ArrayList<Attribute>(); res.add(new Attribute("Name", getName())); ! res.addAll(getAllParameters().values()); return res; } --- 64,70 ---- List<Attribute> res = new ArrayList<Attribute>(); res.add(new Attribute("Name", getName())); ! for (String s : parameter.keySet()) { ! res.add(new Attribute(s, parameter.get(s))); ! } return res; } *************** *** 89,93 **** * @return the parameters */ ! public LinkedHashMap<String, Attribute> getAllParameters() { return parameter; } --- 91,95 ---- * @return the parameters */ ! public LinkedHashMap<String, Object> getAllParameters() { return parameter; } *************** *** 99,103 **** */ private void addParameter(String name, Object o) { ! parameter.put(name, new Attribute(name, o, true)); } --- 101,105 ---- */ private void addParameter(String name, Object o) { ! parameter.put(name, o); } *************** *** 109,114 **** */ public Attribute getParameter(String string) { ! Attribute a = parameter.get(string); ! return a; } --- 111,120 ---- */ public Attribute getParameter(String string) { ! Object param = parameter.get(string); ! if (param != null) { ! return new Attribute(string, param, true); ! } else { ! return null; ! } } |