Changeset 2047 for trunk/autoquest-ui-swt/src/main/java
- Timestamp:
- 10/20/15 10:16:11 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowUsabilityEvaluationResultDialog.java
r1920 r2047 22 22 import java.util.LinkedList; 23 23 import java.util.List; 24 import java.util.ListIterator; 24 25 import java.util.Map; 25 26 … … 215 216 */ 216 217 private void buildSmellTree() { 218 int groupCount = 5; 219 int groupSize = 30; 220 217 221 List<UsabilitySmell> smells = usabilityEvalResult.getAllSmells(); 218 219 int[] eventCoverageQuantileGroups = { 990, 975, 950, 0, -1 }; 220 int[] minEventCoverages = new int[eventCoverageQuantileGroups.length]; 221 int[] maxEventCoverages = new int[eventCoverageQuantileGroups.length]; 222 223 final List<Map<String, List<UsabilitySmell>>> sortedSmells = 224 new LinkedList<Map<String, List<UsabilitySmell>>>(); 225 226 for (int i = 0; i < eventCoverageQuantileGroups.length; i++) { 227 sortedSmells.add(new HashMap<String, List<UsabilitySmell>>()); 228 } 229 222 223 final Map<String, List<UsabilitySmell>> sortedSmells = new HashMap<>(); 224 230 225 for (UsabilitySmell smell : smells) { 231 int eventCoverageQuantile = smell.getIntensity().getEventCoverageQuantile(); 232 233 for (int i = 0; i < eventCoverageQuantileGroups.length; i++) { 234 if (eventCoverageQuantile >= eventCoverageQuantileGroups[i]) { 235 Map<String, List<UsabilitySmell>> smellMap = sortedSmells.get(i); 236 237 List<UsabilitySmell> smellList = smellMap.get(smell.getBriefDescription()); 238 239 if (smellList == null) { 240 smellList = new ArrayList<UsabilitySmell>(); 241 smellMap.put(smell.getBriefDescription(), smellList); 242 } 226 List<UsabilitySmell> smellList = sortedSmells.get(smell.getBriefDescription()); 227 228 if (smellList == null) { 229 smellList = new ArrayList<UsabilitySmell>(); 230 sortedSmells.put(smell.getBriefDescription(), smellList); 231 } 232 233 ListIterator<UsabilitySmell> it = smellList.listIterator(); 234 boolean added = false; 235 236 while (it.hasNext()) { 237 if (smell.getIntensity().getEventCoverage() > 238 it.next().getIntensity().getEventCoverage()) 239 { 240 it.previous(); 241 it.add(smell); 242 added = true; 243 break; 244 } 245 } 246 247 if (!added) { 248 smellList.add(smell); 249 } 250 } 251 252 final Map<Integer, Map<String, List<UsabilitySmell>>> allSortedSmells = 253 new HashMap<Integer, Map<String, List<UsabilitySmell>>>(); 254 255 for (Map.Entry<String, List<UsabilitySmell>> entry : sortedSmells.entrySet()) { 256 // we create groupCount groups of size groupSize 257 int overallIndex = 0; 258 259 for (int i = 0; i < groupCount; i++) { 260 List<UsabilitySmell> smellList = new LinkedList<>(); 261 for (int j = 0; overallIndex < entry.getValue().size() && 262 ((j < groupSize) || (i == (groupCount - 1))); j++) 263 { 264 UsabilitySmell smell = entry.getValue().get(overallIndex++); 243 265 244 266 int ratio = smell.getIntensity().getRatio(); … … 258 280 259 281 smellList.add(index, smell); 282 } 283 284 if (smellList.size() > 0) { 285 Map<String, List<UsabilitySmell>> smellGroups = allSortedSmells.get(i); 286 287 if (smellGroups == null) { 288 smellGroups = new HashMap<>(); 289 allSortedSmells.put(i, smellGroups); 290 } 291 292 smellGroups.put(entry.getKey(), smellList); 293 } 294 } 295 } 296 297 if (smellList.getListeners(SWT.Expand).length == 0) { 298 smellList.addListener(SWT.Expand, new Listener() { 299 public void handleEvent(final Event event) { 300 ensureChildren((TreeItem) event.item); 301 ((TreeItem) event.item).setExpanded(true); 302 } 303 }); 304 } 305 306 for (int i = 0; i < allSortedSmells.size(); i++) { 307 createRootItem("smells group " + (i + 1), allSortedSmells.get(i)); 308 } 309 310 } 311 312 /** 313 * convenience method for creating the display of the instances 314 */ 315 /*private void buildSmellTree() { 316 List<UsabilitySmell> smells = usabilityEvalResult.getAllSmells(); 317 318 int[] eventCoverageQuantileGroups = { 990, 975, 950, 0, -1 }; 319 int[] minEventCoverages = new int[eventCoverageQuantileGroups.length]; 320 int[] maxEventCoverages = new int[eventCoverageQuantileGroups.length]; 321 322 final List<Map<String, List<UsabilitySmell>>> sortedSmells = 323 new LinkedList<Map<String, List<UsabilitySmell>>>(); 324 325 for (int i = 0; i < eventCoverageQuantileGroups.length; i++) { 326 sortedSmells.add(new HashMap<String, List<UsabilitySmell>>()); 327 } 328 329 for (UsabilitySmell smell : smells) { 330 int eventCoverageQuantile = smell.getIntensity().getEventCoverageQuantile(); 331 332 for (int i = 0; i < eventCoverageQuantileGroups.length; i++) { 333 if (eventCoverageQuantile >= eventCoverageQuantileGroups[i]) { 334 Map<String, List<UsabilitySmell>> smellMap = sortedSmells.get(i); 335 336 List<UsabilitySmell> smellList = smellMap.get(smell.getBriefDescription()); 337 338 if (smellList == null) { 339 smellList = new ArrayList<UsabilitySmell>(); 340 smellMap.put(smell.getBriefDescription(), smellList); 341 } 342 343 int ratio = smell.getIntensity().getRatio(); 344 int eventCoverage = smell.getIntensity().getEventCoverage(); 345 int index = 0; 346 for (index = 0; index < smellList.size(); index++) { 347 UsabilitySmellIntensity candidate = smellList.get(index).getIntensity(); 348 if ((ratio == candidate.getRatio()) && 349 (eventCoverage > candidate.getEventCoverage())) 350 { 351 break; 352 } 353 else if (ratio > candidate.getRatio()) { 354 break; 355 } 356 } 357 358 smellList.add(index, smell); 260 359 261 360 if (minEventCoverages[i] == 0) {
Note: See TracChangeset
for help on using the changeset viewer.