Commit d6cee3f5 authored by Nico Mack's avatar Nico Mack

Cloning of tethers is now handled by TetherManager

parent d1d1ae23
......@@ -553,7 +553,7 @@ public class TetherManager {
this.currentlyTethered.add(candidate);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("{} now tethered with {}!", this.tetherable, candidate);
LOGGER.debug("{} now tethered with {}!", this.tetherable, candidate); //$NON-NLS-1$
}
this.tetherListeners.notifyTetherListener(new TetherEvent(this.tetherable, candidate, TetherEvent.TetherState.ESTABLISHED));
......@@ -584,7 +584,7 @@ public class TetherManager {
if (this.currentlyTethered.contains(tethered)) {
this.currentlyTethered.remove(tethered);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("{} no longer tethered with {}!", this.tetherable, tethered);
LOGGER.debug("{} no longer tethered with {}!", this.tetherable, tethered); //$NON-NLS-1$
}
this.tetherListeners.notifyTetherListener(new TetherEvent(this.tetherable, tethered, TetherEvent.TetherState.TORNDOWN));
if (propagate && tethered.isTetheredWith(this.tetherable)) {
......@@ -708,12 +708,17 @@ public class TetherManager {
Point tetherEnding = potential.getTetherOrigin().toScreenCoordinates();
double distance = this.distance(tetherOrigin, tetherEnding);
// Case 1: Figure out whether potential tether is closer than current tether (if any).
// Case 1: Figure out whether potential tetherable object is closer than currently tethered one (if
// any).
if (!alreadyTetheredWith) {
if ((distance <= tetheringDistance - HYSTERESIS) && (distance < shortestTether)) {
this.tetherable.tetherWith(potential, DO_PROPAGATE);
isTethered = true;
// Make sure to clone the Tether object so that multiple instances can coexist.
entry.setValue(entry.getValue().clone());
}
} else if (distance >= tetheringDistance + HYSTERESIS) {
if (!potential.isDraggable()) {
......@@ -756,21 +761,6 @@ public class TetherManager {
// ---------------------------------------------------------------------------
public void lift() {
// List<Tetherable> previouslyTethered;
//
// if (isTethered()) {
// previouslyTethered = new ArrayList<>(this.currentlyTethered);
// this.currentlyTethered.clear();
//
// for (Tetherable tethered : previouslyTethered) {
// tethered.separateFrom(this.tetherable);
//
// Tether tether = this.potentialTethers.get(tethered);
// tether.setOrigin(null);
// tether.setEnding(null);
// }
// }
this.separateFromAll(DO_PROPAGATE);
this.tetherable.setTetherOrigin(null);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment