@Override public void destroy() { hideControlPoints(); hideMagnetPoints(); super.destroy(); }
protected void updateChildrenLocations(final double deltaX, final double deltaY) { if (children == null) { return; } final Point2D delta = new Point2D(deltaX, deltaY); for (WiresBaseShape shape : children) { shape.setLocation(shape.getLocation().add(delta)); } }
@Override public void onFrame(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { //Lienzo's IAnimation.getPercent() passes values > 1.0 final double pct = iAnimation.getPercent() > 1.0 ? 1.0 : iAnimation.getPercent(); //Move each descendant along the line between its origin and the target destination for (Map.Entry<WiresBaseShape, Pair<Point2D, Point2D>> e : transformations.entrySet()) { final Point2D descendantOrigin = e.getValue().getK1(); final Point2D descendantTarget = e.getValue().getK2(); final double dx = (descendantTarget.getX() - descendantOrigin.getX()) * pct; final double dy = (descendantTarget.getY() - descendantOrigin.getY()) * pct; e.getKey().setX(descendantOrigin.getX() + dx); e.getKey().setY(descendantOrigin.getY() + dy); } //Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode root.getLayer().batch(); }
@Override public void onFrame(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { final double pct = tweener.apply(iAnimation.getPercent() > 1.0 ? 1.0 : iAnimation.getPercent()); //Move each Control along the line between its origin and the target destination for (Map.Entry<Group, Pair<Point2D, Point2D>> e : transformations.entrySet()) { final Point2D origin = e.getValue().getK1(); final Point2D target = e.getValue().getK2(); final double dx = (target.getX() - origin.getX()) * pct; final double dy = (target.getY() - origin.getY()) * pct; e.getKey().setLocation(new Point2D(origin.getX() + dx, origin.getY() + dy).add(WiresBaseShape.this.getLocation())); } for (Group ctrl : controls) { ctrl.setAlpha(1.0 - iAnimation.getPercent()); } //Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode WiresBaseShape.this.getLayer().batch(); }
@Override public void onStart(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { //Reposition nodes. First we store the WiresBaseTreeNode together with its current position and target position transformations.clear(); for (Map.Entry<WiresBaseShape, Point2D> e : layout.entrySet()) { final Point2D origin = e.getKey().getLocation(); final Point2D destination = e.getValue(); transformations.put(e.getKey(), new Pair<Point2D, Point2D>(origin, destination)); } WiresLayoutUtilities.resizeViewPort(canvasBounds, canvasLayer.getViewport()); }
0)); ctrl.setAlpha(0.0); WiresBaseShape.this.getLayer().add(ctrl); final Point2D origin = new Point2D(0, 0); final Point2D target = getControlTarget(ctrl); transformations.put(ctrl, new Pair<Point2D, Point2D>(origin, origin.minus(WiresBaseShape.this.getLocation()); final Point2D target = new Point2D(0, 0); origin.minus(WiresBaseShape.this.getLocation()); final Point2D target = getControlTarget(ctrl); transformations.put(ctrl, new Pair<Point2D, Point2D>(origin,
@Override public Group setX(final double x) { final Group g = super.setX(x); updateConnectorsEndPoints(); return g; }
@Override public Group setY(final double y) { final Group g = super.setY(y); updateConnectorsEndPoints(); return g; } }
private void updateControlLocations() { if (controls == null) { return; } if (!isControlsVisible) { return; } for (Group ctrl : controls) { final Point2D target = getControlTarget(ctrl).add(WiresBaseShape.this.getLocation()); ctrl.setLocation(target); } }
@Override public void onClose(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { for (Group ctrl : controls) { WiresBaseShape.this.getLayer().remove(ctrl); } } });
@Override public void onStart(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { //Store required transformations: Control, Current location, Target location transformations.clear(); for (int index = 0; index < controls.size(); index++) { final Group ctrl = controls.get(index); final Point2D origin = new Point2D(0, 0); final Point2D target = getControlTarget(ctrl); transformations.put(ctrl, new Pair<Point2D, Point2D>(origin, target)); WiresBaseShape.this.getLayer().add(ctrl); ctrl.setLocation(origin); ctrl.setAlpha(0.0); } }
e.getValue().getY()); e.getKey().setLocation(destination);
protected BaseGuidedDecisionTreeShape getParentNode(final BaseGuidedDecisionTreeShape uiChild, final double cx, final double cy) { BaseGuidedDecisionTreeShape uiProspectiveParent = null; double finalDistance = Double.MAX_VALUE; for (WiresBaseShape ws : getShapesInCanvas()) { if (ws.isVisible()) { if (ws instanceof BaseGuidedDecisionTreeShape) { final BaseGuidedDecisionTreeShape uiNode = (BaseGuidedDecisionTreeShape) ws; if (uiNode.acceptChildNode(uiChild) && !uiNode.hasCollapsedChildren()) { double deltaX = cx - uiNode.getX(); double deltaY = cy - uiNode.getY(); double distance = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); if (finalDistance > distance) { finalDistance = distance; uiProspectiveParent = uiNode; } } } } } //If we're too far away from a parent we might as well not have a parent if (finalDistance > MAX_PROXIMITY) { uiProspectiveParent = null; } return uiProspectiveParent; }
@Override public void onFrame(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { //Lienzo's IAnimation.getPercent() passes values > 1.0 final double pct = iAnimation.getPercent() > 1.0 ? 1.0 : iAnimation.getPercent(); //Move each descendant along the line between its origin and the target destination for (Map.Entry<WiresBaseShape, Pair<Point2D, Point2D>> e : transformations.entrySet()) { final Point2D descendantOrigin = e.getValue().getK1(); final Point2D descendantTarget = e.getValue().getK2(); final double dx = (descendantTarget.getX() - descendantOrigin.getX()) * pct; final double dy = (descendantTarget.getY() - descendantOrigin.getY()) * pct; e.getKey().setX(descendantOrigin.getX() + dx); e.getKey().setY(descendantOrigin.getY() + dy); } //Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode root.getLayer().batch(); }
@Override public void onFrame(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { final double pct = tweener.apply(iAnimation.getPercent() > 1.0 ? 1.0 : iAnimation.getPercent()); //Move each Control along the line between its origin and the target destination for (Map.Entry<Group, Pair<Point2D, Point2D>> e : transformations.entrySet()) { final Point2D origin = e.getValue().getK1(); final Point2D target = e.getValue().getK2(); final double dx = (target.getX() - origin.getX()) * pct; final double dy = (target.getY() - origin.getY()) * pct; e.getKey().setLocation(new Point2D(origin.getX() + dx, origin.getY() + dy).add(WiresBaseShape.this.getLocation())); } for (Group ctrl : controls) { ctrl.setAlpha(iAnimation.getPercent()); } //Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode WiresBaseShape.this.getLayer().batch(); }
@Override public void onStart(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { //Reposition nodes. First we store the WiresBaseTreeNode together with its current position and target position transformations.clear(); for (Map.Entry<WiresBaseShape, Point2D> e : layout.entrySet()) { final Point2D origin = e.getKey().getLocation(); final Point2D destination = e.getValue(); transformations.put(e.getKey(), new Pair<Point2D, Point2D>(origin, destination)); } WiresLayoutUtilities.resizeViewPort(canvasBounds, canvasLayer.getViewport()); }
0)); ctrl.setAlpha(0.0); WiresBaseShape.this.getLayer().add(ctrl); final Point2D origin = new Point2D(0, 0); final Point2D target = getControlTarget(ctrl); transformations.put(ctrl, new Pair<Point2D, Point2D>(origin, origin.minus(WiresBaseShape.this.getLocation()); final Point2D target = new Point2D(0, 0); origin.minus(WiresBaseShape.this.getLocation()); final Point2D target = getControlTarget(ctrl); transformations.put(ctrl, new Pair<Point2D, Point2D>(origin,
@Override public Group setX(final double x) { final Group g = super.setX(x); updateConnectorsEndPoints(); return g; }