@Override public void showControlPoints() { final Layer layer = getLayer(); if ( !controlPoints.isEmpty() && !showingControlPoints ) { for ( ControlPoint cp : controlPoints ) { cp.setOffset( getLocation() ); layer.add( cp ); } showingControlPoints = true; getLayer().draw(); } }
@Override public void showMagnetsPoints() { final Layer layer = getLayer(); if ( !magnets.isEmpty() && !showingMagnets ) { for ( Magnet m : magnets ) { m.setOffset( getLocation() ); layer.add( m ); } showingMagnets = true; getLayer().draw(); } }
@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.setOffset( WiresBaseShape.this.getLocation() ); ctrl.setLocation( origin ); ctrl.setAlpha( 0.0 ); } }
ctrl.setAlpha( 0.0 ); ctrl.setOffset( WiresBaseShape.this.getLocation() ); WiresBaseShape.this.getLayer().add( ctrl );
/** * Add a TreeNode as a child to this TreeNode. A connector is automatically created and maintained for the child. * Connectors are "outgoing" from the parent to a child. * @param child */ public void addChildNode( final WiresBaseTreeNode child ) { final WiresTreeNodeConnector connector = new WiresTreeNodeConnector(); connector.getPoints().getPoint( 0 ).set( getLocation() ); connector.getPoints().getPoint( 1 ).set( child.getLocation() ); getLayer().add( connector ); connector.moveToBottom(); final int index = getChildIndex( connector ); children.add( index, child ); connectors.add( index, connector ); child.setParentNode( this ); //Update connectors when child Node moves child.addNodeDragMoveHandler( new NodeDragMoveHandler() { @Override public void onNodeDragMove( final NodeDragMoveEvent nodeDragMoveEvent ) { connector.getPoints().getPoint( 1 ).set( child.getLocation() ); } } ); }
protected void onMouseMove(NodeMouseMoveEvent event) { m_end.setX(event.getX()).setY(event.getY()); m_inverseTransform.transform(m_end, m_end); double x = m_start.getX(); double y = m_start.getY(); double dx = m_end.getX() - x; double dy = m_end.getY() - y; if (dx < 0) { x += dx; dx = -dx; } if (dy < 0) { y += dy; dy = -dy; } m_rectangle.setX(x).setY(y).setWidth(dx).setHeight(dy); if (!m_addedRectangle) { m_addedRectangle = true; m_dragLayer.add(m_rectangle); } m_dragLayer.draw(); }
public void onDragPreviewHandler( @Observes ShapeDragPreviewEvent shapeDragPreviewEvent ) { //We can only connect WiresTreeNodes to each other if ( !( shapeDragPreviewEvent.getShape() instanceof WiresBaseTreeNode ) ) { dropContext.setContext( null ); return; } //Find a Parent Node to attach the Shape to final double cx = getX( shapeDragPreviewEvent.getX() ); final double cy = getY( shapeDragPreviewEvent.getY() ); final WiresBaseTreeNode child = (WiresBaseTreeNode) shapeDragPreviewEvent.getShape(); final WiresBaseTreeNode prospectiveParent = getParentNode( child, cx, cy ); //If there is a prospective parent show the line between child and parent if ( prospectiveParent != null ) { if ( connector == null ) { connector = new WiresTreeNodeConnector(); canvasLayer.add( connector ); connector.moveToBottom(); } connector.getPoints().getPoint( 0 ).set( prospectiveParent.getLocation() ); connector.getPoints().getPoint( 1 ).set( new Point2D( cx, cy ) ); } else if ( connector != null ) { canvasLayer.remove( connector ); connector = null; } dropContext.setContext( prospectiveParent ); canvasLayer.draw(); }