Changeset 1491
- Timestamp:
- 04/07/14 08:43:22 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/commands/CMDcondenseHTMLGUIModel.java
r1439 r1491 17 17 import java.util.ArrayList; 18 18 import java.util.Arrays; 19 import java.util.Collection; 19 20 import java.util.Comparator; 20 21 import java.util.HashSet; 22 import java.util.IdentityHashMap; 21 23 import java.util.LinkedList; 22 24 import java.util.List; 25 import java.util.Map; 23 26 import java.util.Set; 24 27 import java.util.logging.Level; 25 28 26 29 import de.ugoe.cs.autoquest.CommandHelpers; 30 import de.ugoe.cs.autoquest.SequenceInstanceOf; 31 import de.ugoe.cs.autoquest.eventcore.Event; 27 32 import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel; 28 33 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; … … 125 130 GUIModel model = (GUIModel) dataObject; 126 131 132 // >>>>>>>>>>>>>>>>>>>>>>>>>>>> Just to test the distance measure 133 134 System.out.println("checking distance measure correctness"); 135 Collection<List<Event>> sequences = null; 136 dataObject = GlobalDataContainer.getInstance().getData(sequencesName); 137 if (dataObject == null) { 138 CommandHelpers.objectNotFoundMessage(sequencesName); 139 return; 140 } 141 if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) { 142 CommandHelpers.objectNotType(sequencesName, "Collection<List<Event<?>>>"); 143 return; 144 } 145 146 sequences = (Collection<List<Event>>) dataObject; 147 148 Map<IGUIElement, IGUIElement> guiElements = new IdentityHashMap<IGUIElement, IGUIElement>(); 149 150 for (List<Event> sequence : sequences) { 151 for (Event event : sequence) { 152 guiElements.put((IGUIElement) event.getTarget(), (IGUIElement) event.getTarget()); 153 } 154 } 155 156 System.out.println("got " + guiElements.size() + " utilized GUI elements"); 157 158 IGUIElement[] guiElementArray = 159 guiElements.keySet().toArray(new IGUIElement[guiElements.size()]); 160 161 Arrays.sort(guiElementArray, new Comparator<IGUIElement>() { 162 @Override 163 public int compare(IGUIElement o1, IGUIElement o2) { 164 return o1.getStringIdentifier().compareTo(o2.getStringIdentifier()); 165 } 166 167 }); 168 169 int checkSize = Math.min(guiElements.size() * guiElements.size(), 100000000); 170 double[] expectedDistances = new double[checkSize]; 171 int index = 0; 172 173 OUTER: 174 for (int i = 0; i < guiElementArray.length; i++) { 175 for (int j = 0; j < guiElementArray.length; j++) { 176 if (i == j) { 177 continue; 178 } 179 180 if (index == 1703) { 181 System.out.println("blub"); 182 } 183 184 expectedDistances[index++] = guiElementArray[i].getDistanceTo(guiElementArray[j]); 185 186 if (index == checkSize) { 187 break OUTER; 188 } 189 } 190 } 191 192 System.out.println("calculated " + expectedDistances.length + " distances"); 193 194 // <<<<<<<<<<<<<<<<<<<<<<<<<<<< Just to test the distance measure 195 127 196 for (IGUIElement root : model.getRootElements()) { 128 197 if (root instanceof HTMLServer) { … … 137 206 } 138 207 } 208 209 // >>>>>>>>>>>>>>>>>>>>>>>>>>>> Just to test the distance measure 210 index = 0; 211 212 System.out.println("checking, if distances are still the same"); 213 OUTER: 214 for (int i = 0; i < guiElementArray.length; i++) { 215 for (int j = 0; j < guiElementArray.length; j++) { 216 if (i == j) { 217 continue; 218 } 219 220 if (index == 1703) { 221 System.out.println("blub"); 222 } 223 224 double newDistance = guiElementArray[i].getDistanceTo(guiElementArray[j]); 225 if ((expectedDistances[index] != newDistance) && 226 (expectedDistances[index] != 0.5) && (newDistance != 0.2)) 227 { 228 System.out.println((index ) + ": distance between " + guiElementArray[i] + 229 " and " + guiElementArray[j] + " changed due to condense. " + 230 "Was " + expectedDistances[index] + " and is now " + 231 guiElementArray[i].getDistanceTo(guiElementArray[j]) + "."); 232 } 233 234 index++; 235 236 if (index == checkSize) { 237 break OUTER; 238 } 239 } 240 } 241 // <<<<<<<<<<<<<<<<<<<<<<<<<<<< Just to test the distance measure 242 139 243 } 140 244
Note: See TracChangeset
for help on using the changeset viewer.