- PipelineComponent prev = comp.getPrevious();
- PipelineComponent next = comp.getNext();
- if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed())
- prev = prev.getPrevious();
- if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed()) {
- next = next.getNext();
+ PipelineComponent prev = comp.getPrevious();
+ PipelineComponent next = comp.getNext();
+ if (prev == null || next == null) {
+ // TODO : we should support open ended translation (when translated component is the first or last of the run).
+ setEnabled(false);
+ return;
+ }
+ if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed())
+ prev = prev.getPrevious();
+ if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed()) {
+ next = next.getNext();
+ }
+ Point3d ns = new Point3d();
+ Point3d ne = new Point3d();
+ Point3d ps = new Point3d();
+ Point3d pe = new Point3d();
+ next.getControlPointEnds(ns, ne);
+ prev.getControlPointEnds(ps, pe);
+ dir = comp.getControlPoint().getPathLegDirection(Direction.NEXT);
+ dir.normalize();
+ // We may have offsets in the path leg, hence we have to project the coordinates.
+ Vector3d wp = node.getWorldPosition();
+ s = MathTools.closestPointOnStraight(pe, wp, dir);
+ e = MathTools.closestPointOnStraight(ns, wp, dir);
+ // Remove component's own space from end points to get actual movement range
+ double l = comp.getControlPoint().getInlineLength();
+ Vector3d ld = new Vector3d(dir);
+ ld.scale(l);
+ s.add(ld);
+ e.sub(ld);