@Override public void cancel() { m_dragging = false; if (m_addedRectangle) { m_dragLayer.remove(m_rectangle); m_addedRectangle = false; m_dragLayer.draw(); } }
@Override public void hideControlPoints() { final Layer layer = getLayer(); if ( !controlPoints.isEmpty() && showingControlPoints ) { for ( ControlPoint cp : controlPoints ) { layer.remove( cp ); } showingControlPoints = false; getLayer().draw(); } }
@Override public void hideMagnetPoints() { final Layer layer = getLayer(); if ( !magnets.isEmpty() && showingMagnets ) { for ( Magnet m : magnets ) { layer.remove( m ); } showingMagnets = false; getLayer().draw(); } }
@Override public void execute(double time) { final FastArrayList<Layer> list = m_layers; m_layers = new FastArrayList<Layer>(); final int leng = list.length(); for (int i = 0; i < leng; i++) { list.get(i).draw(); } } };
@Override public void onNodeDragMove( final NodeDragMoveEvent nodeDragMoveEvent ) { updateMagnetOffsets(); updateControlPointOffsets(); getLayer().draw(); } } );
@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(); } }
/** * Iterates over the list of {@link Layer} and draws them all. */ public void draw() { FastArrayList<Layer> layers = getChildNodes(); if (null != layers) { int size = layers.length(); for (int i = 0; i < size; i++) { Layer layer = layers.get(i); if (null != layer) { layer.draw(); } } } }
@Override public void destroy() { if ( isControlsVisible ) { for ( Group ctrl : controls ) { getLayer().remove( ctrl ); } isControlsVisible = false; } Layer layer = getLayer(); layer.remove( this ); layer.draw(); }
@Override public void onNodeDragMove( final NodeDragMoveEvent nodeDragMoveEvent ) { for ( WiresTreeNodeConnector connector : connectors ) { connector.getPoints().getPoint( 0 ).set( getLocation() ); } getLayer().draw(); } } );
@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().draw(); }
@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 ); } for ( WiresBaseTreeNode descendant : descendants ) { descendant.setAlpha( 1.0 - pct ); } //Allow subclasses to change their appearance onCollapseProgress( pct ); //Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode WiresBaseTreeNode.this.getLayer().draw(); }
@Override public void onFrame( final IAnimation iAnimation, final IAnimationHandle iAnimationHandle ) { final double pct = tweener.tween( 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().setX( origin.getX() + dx ); e.getKey().setY( origin.getY() + dy ); } 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().draw(); }
@Override public void onFrame( final IAnimation iAnimation, final IAnimationHandle iAnimationHandle ) { final double pct = tweener.tween( 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().setX( origin.getX() + dx ); e.getKey().setY( origin.getY() + dy ); } 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().draw(); }
@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 ); } for ( WiresBaseTreeNode descendant : descendants ) { descendant.setAlpha( pct ); } //Allow subclasses to change their appearance onExpandProgress( pct ); //Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode WiresBaseTreeNode.this.getLayer().draw(); }
@Override public void onFrame( final IAnimation iAnimation, final IAnimationHandle iAnimationHandle ) { final double pct = tweener.tween( 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().setX( origin.getX() + dx ); e.getKey().setY( origin.getY() + dy ); } for ( Group ctrl : controlsToAdd ) { ctrl.setAlpha( pct ); } for ( Group ctrl : controlsToRemove ) { ctrl.setAlpha( 1.0 - pct ); } //Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode WiresBaseShape.this.getLayer().draw(); }
private final void doDragMove(INodeXYEvent event) { m_dragContext.dragUpdate(event); if (m_dragging_dispatch_move) { m_dragnode.fireEvent(new NodeDragMoveEvent(m_dragContext)); } // Draw after processing the drag move event // First the graphics on the drag layer m_lienzo.getDragLayer().draw(); // ... then the node that is being moved m_dragContext.drawNode(m_lienzo.getDragLayer().getContext()); }
@Override public void onNodeDragMove( final NodeDragMoveEvent nodeDragMoveEvent ) { final double deltaX = nodeDragMoveEvent.getDragContext().getDx(); final double deltaY = nodeDragMoveEvent.getDragContext().getDy(); final Point2D delta = new Point2D( deltaX, deltaY ); for ( Pair<WiresBaseShape, Point2D> dragStartLocation : dragStartLocations ) { dragStartLocation.getK1().setLocation( dragStartLocation.getK2().plus( delta ) ); } getLayer().draw(); } } );
private final void doDragCancel(INodeXYEvent event) { if (m_dragging) { doDragMove(event); m_lienzo.setCursor(Cursor.DEFAULT); m_dragnode.setVisible(true); m_dragContext.dragDone(); m_dragnode.getLayer().draw(); m_lienzo.getDragLayer().clear(); m_dragnode.fireEvent(new NodeDragEndEvent(m_dragContext)); m_dragnode = null; m_dragging = false; m_dragging_dispatch_move = false; m_dragging_using_touches = false; } }
/** * Adds a {@link Layer} to the Scene. * A draw will be invoked after the layer is added. */ @Override public void add(Layer layer) { if ((null != layer) && (LienzoGlobals.getInstance().isCanvasSupported())) { CanvasElement element = layer.getCanvasElement(); layer.setPixelSize(m_wide, m_high); element.getStyle().setPosition(Position.ABSOLUTE); element.getStyle().setDisplay(Display.INLINE_BLOCK); getElement().appendChild(element); super.add(layer); layer.draw(); } }