|
Lines 415-420
Link Here
|
| 415 |
} |
415 |
} |
| 416 |
} |
416 |
} |
| 417 |
|
417 |
|
|
|
418 |
/** |
| 419 |
* Policy is that a parent should not have an interest lower than that of one of its children. This meets our goal |
| 420 |
* of having them decay no faster than the children while having their interest be proportional to the interest of |
| 421 |
* their children. |
| 422 |
*/ |
| 418 |
private void propegateInterestToParents(IInteractionContext interactionContext, InteractionEvent.Kind kind, |
423 |
private void propegateInterestToParents(IInteractionContext interactionContext, InteractionEvent.Kind kind, |
| 419 |
IInteractionElement node, float previousInterest, float decayOffset, int level, |
424 |
IInteractionElement node, float previousInterest, float decayOffset, int level, |
| 420 |
List<IInteractionElement> interestDelta) { |
425 |
List<IInteractionElement> interestDelta) { |
|
Lines 425-433
Link Here
|
| 425 |
} |
430 |
} |
| 426 |
|
431 |
|
| 427 |
checkForLandmarkDeltaAndNotify(previousInterest, node); |
432 |
checkForLandmarkDeltaAndNotify(previousInterest, node); |
| 428 |
|
|
|
| 429 |
level++; // original is 1st level |
433 |
level++; // original is 1st level |
| 430 |
float propagatedIncrement = node.getInterest().getValue() - previousInterest + decayOffset; |
434 |
|
|
|
435 |
// NOTE: original code summed parent interest |
| 436 |
// float propagatedIncrement = node.getInterest().getValue() - previousInterest + decayOffset; |
| 431 |
|
437 |
|
| 432 |
AbstractContextStructureBridge bridge = ContextCorePlugin.getDefault() |
438 |
AbstractContextStructureBridge bridge = ContextCorePlugin.getDefault() |
| 433 |
.getStructureBridge(node.getContentType()); |
439 |
.getStructureBridge(node.getContentType()); |
|
Lines 449-488
Link Here
|
| 449 |
} |
455 |
} |
| 450 |
|
456 |
|
| 451 |
if (parentHandle != null) { |
457 |
if (parentHandle != null) { |
| 452 |
InteractionEvent propagationEvent = new InteractionEvent(InteractionEvent.Kind.PROPAGATION, |
458 |
String parentContentType = bridge.getContentType(parentHandle); |
| 453 |
bridge.getContentType(node.getHandleIdentifier()), parentHandle, SOURCE_ID_MODEL_PROPAGATION, |
459 |
|
| 454 |
CONTAINMENT_PROPAGATION_ID, propagatedIncrement); |
460 |
IInteractionElement parentElement = interactionContext.get(parentHandle); |
| 455 |
IInteractionElement previous = interactionContext.get(propagationEvent.getStructureHandle()); |
461 |
float parentPreviousInterest = 0; |
| 456 |
if (previous != null && previous.getInterest() != null) { |
462 |
if (parentElement != null && parentElement.getInterest() != null) { |
| 457 |
previousInterest = previous.getInterest().getValue(); |
463 |
parentPreviousInterest = parentElement.getInterest().getValue(); |
| 458 |
} |
464 |
} |
| 459 |
IInteractionElement parentNode = addInteractionEvent(interactionContext, propagationEvent); |
465 |
|
| 460 |
if (kind.isUserEvent() |
466 |
float increment = interactionContext.getScaling().getInteresting(); |
| 461 |
&& parentNode.getInterest().getEncodedValue() < commonContextScaling.getInteresting()) { |
467 |
if (parentPreviousInterest < node.getInterest().getValue()) { |
| 462 |
float parentOffset = ((-1) * parentNode.getInterest().getEncodedValue()) + 1; |
468 |
increment = node.getInterest().getValue() - parentPreviousInterest; |
|
|
469 |
InteractionEvent propagationEvent = new InteractionEvent(InteractionEvent.Kind.PROPAGATION, |
| 470 |
parentContentType, parentHandle, SOURCE_ID_MODEL_PROPAGATION, CONTAINMENT_PROPAGATION_ID, increment); |
| 471 |
parentElement = addInteractionEvent(interactionContext, propagationEvent); |
| 472 |
} |
| 473 |
|
| 474 |
// NOTE: this might be redundant |
| 475 |
if (parentElement != null && kind.isUserEvent() && parentElement.getInterest().getValue() < commonContextScaling.getInteresting()) { |
| 476 |
float parentOffset = commonContextScaling.getInteresting() - parentElement.getInterest().getValue() + increment; |
| 463 |
addInteractionEvent(interactionContext, new InteractionEvent(InteractionEvent.Kind.MANIPULATION, |
477 |
addInteractionEvent(interactionContext, new InteractionEvent(InteractionEvent.Kind.MANIPULATION, |
| 464 |
parentNode.getContentType(), parentNode.getHandleIdentifier(), SOURCE_ID_DECAY_CORRECTION, |
478 |
parentElement.getContentType(), parentElement.getHandleIdentifier(), |
| 465 |
parentOffset)); |
479 |
SOURCE_ID_DECAY_CORRECTION, parentOffset)); |
| 466 |
} |
480 |
} |
| 467 |
if (previous != null |
481 |
|
| 468 |
&& isInterestDelta(previousInterest, previous.getInterest().isPredicted(), previous.getInterest() |
482 |
if (parentElement != null |
| 469 |
.isPropagated(), parentNode)) { |
483 |
&& isInterestDelta(parentPreviousInterest, parentElement.getInterest().isPredicted(), |
| 470 |
interestDelta.add(0, parentNode); |
484 |
parentElement.getInterest().isPropagated(), parentElement)) { |
| 471 |
} |
485 |
interestDelta.add(0, parentElement); |
| 472 |
propegateInterestToParents(interactionContext, kind, parentNode, previousInterest, decayOffset, level, |
486 |
} |
| 473 |
interestDelta);// adapter.getResourceExtension(), |
487 |
propegateInterestToParents(interactionContext, kind, parentElement, parentPreviousInterest, decayOffset, level, |
|
|
488 |
interestDelta); |
| 474 |
} |
489 |
} |
| 475 |
} |
490 |
} |
| 476 |
|
491 |
|
| 477 |
// public List<IInteractionElement> |
|
|
| 478 |
// findCompositesForNodes(List<InteractionContextElement> nodes) { |
| 479 |
// List<IInteractionElement> composites = new ArrayList<IInteractionElement>(); |
| 480 |
// for (InteractionContextElement node : nodes) { |
| 481 |
// composites.add(aaactiveContext.get(node.getHandleIdentifier())); |
| 482 |
// } |
| 483 |
// return composites; |
| 484 |
// } |
| 485 |
|
| 486 |
public void addListener(IInteractionContextListener listener) { |
492 |
public void addListener(IInteractionContextListener listener) { |
| 487 |
if (listener != null) { |
493 |
if (listener != null) { |
| 488 |
if (suppressListenerNotification && !waitingListeners.contains(listener)) { |
494 |
if (suppressListenerNotification && !waitingListeners.contains(listener)) { |
|
Lines 527-533
Link Here
|
| 527 |
ACTIVITY_STRUCTUREKIND_ACTIVATION, context.getHandleIdentifier(), ACTIVITY_ORIGINID_WORKBENCH, |
533 |
ACTIVITY_STRUCTUREKIND_ACTIVATION, context.getHandleIdentifier(), ACTIVITY_ORIGINID_WORKBENCH, |
| 528 |
null, ACTIVITY_DELTA_ACTIVATED, 1f)); |
534 |
null, ACTIVITY_DELTA_ACTIVATED, 1f)); |
| 529 |
} |
535 |
} |
| 530 |
|
536 |
|
| 531 |
for (IInteractionContextListener listener : listeners) { |
537 |
for (IInteractionContextListener listener : listeners) { |
| 532 |
try { |
538 |
try { |
| 533 |
listener.contextActivated(context); |
539 |
listener.contextActivated(context); |
|
Lines 1000-1006
Link Here
|
| 1000 |
} else { |
1006 |
} else { |
| 1001 |
// make uninteresting |
1007 |
// make uninteresting |
| 1002 |
if (originalValue >= 0) { |
1008 |
if (originalValue >= 0) { |
| 1003 |
changeValue = (-1 * originalValue) - 1; |
1009 |
changeValue = ((-1) * originalValue) - 1; |
| 1004 |
} |
1010 |
} |
| 1005 |
|
1011 |
|
| 1006 |
// reduce interest of children |
1012 |
// reduce interest of children |