Changeset 589 for trunk/quest-core-events/src/main/java/de/ugoe
- Timestamp:
- 08/23/12 10:42:41 (12 years ago)
- Location:
- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIModel.java
r576 r589 8 8 9 9 import java.util.ArrayList; 10 import java.util.LinkedList; 10 11 import java.util.List; 11 12 … … 106 107 IGUIElementSpec specToIntegrateElementFor = remainingPath.remove(0); 107 108 108 List<TreeNode> matchingChildren = new ArrayList<TreeNode>(); 109 int maximumSimilarity = 0; 109 List<TreeNode> matchingChildren = new LinkedList<TreeNode>(); 110 110 111 111 if (parentNode.children != null) { 112 112 for (TreeNode child : parentNode.children) { 113 int similarityLevel = getSimilarityLevel 114 (specToIntegrateElementFor, child.guiElement.getSpecification()); 115 116 if (similarityLevel >= maximumSimilarity) { 117 if (maximumSimilarity == 100) { 118 throw new GUIModelException 119 ("several children of gui element " + parentNode.guiElement + 120 " pretend to fully match specification " + specToIntegrateElementFor); 121 } 122 123 if (maximumSimilarity != similarityLevel) { 124 matchingChildren.clear(); 125 maximumSimilarity = similarityLevel; 126 } 127 113 if( specToIntegrateElementFor.getSimilarity(child.guiElement.getSpecification())) { 128 114 matchingChildren.add(child); 129 115 } 130 116 } 131 }132 133 // we do not see something as matching if the similarity level is below 80%134 if (maximumSimilarity < 80) {135 matchingChildren.clear();136 117 } 137 118 … … 150 131 151 132 if (remainingPath.size() > 0) { 133 // TODO update spec here matchingChildren.get(0).guiElement 134 matchingChildren.get(0).guiElement.updateSpecification(specToIntegrateElementFor); 152 135 return integratePath(matchingChildren.get(0), remainingPath, guiElementFactory); 153 136 } 154 137 else { 155 138 return matchingChildren.get(0).guiElement; 156 }157 }158 159 /**160 * <p>161 * TODO: comment162 * </p>163 *164 * @param spec1165 * @param spec2166 * @return167 * @throws GUIModelException168 */169 private int getSimilarityLevel(IGUIElementSpec spec1, IGUIElementSpec spec2)170 throws GUIModelException171 {172 if (spec1 == spec2) {173 return 100;174 }175 else if (spec1 != null) {176 int level = spec1.getSimilarity(spec2);177 178 if ((level < 0) || (100 < level)) {179 throw new GUIModelException("invalid tree node similarity provided (" + level +180 "). Must be between 0 and 100.");181 }182 183 return level;184 }185 else {186 return 0;187 139 } 188 140 } -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElement.java
r576 r589 32 32 */ 33 33 public int hashCode(); 34 35 public void updateSpecification(IGUIElementSpec specToIntegrateElementFor); 34 36 } -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementSpec.java
r576 r589 33 33 * @return 34 34 */ 35 public intgetSimilarity(IGUIElementSpec otherParameters);35 public boolean getSimilarity(IGUIElementSpec otherParameters); 36 36 37 37 /**
Note: See TracChangeset
for help on using the changeset viewer.