/** * Constructor. Creates an instance of a group. */ public Group() { super(NodeType.GROUP); setX(0).setY(0).setAlpha(1).setDraggable(false); }
/** * Removes all primitives from the collection. Override to ensure all primitives are removed from Layers Color Map * <p> * It should be noted that this operation will not have an apparent effect for an already rendered (drawn) Container. * In other words, if the Container has already been drawn and a new primitive is added, you'll need to invoke draw() on the * Container. This is done to enhance performance, otherwise, for every add we would have draws impacting performance. */ @Override public void removeAll() { detachFromLayerColorMap(); super.removeAll(); }
@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(); }
controlsToAdd.removeAll( controls ); for ( Group ctrl : controlsToAdd ) { ctrl.setLocation( new Point2D( 0, 0 ) ); ctrl.setAlpha( 0.0 ); ctrl.setOffset( WiresBaseShape.this.getLocation() ); WiresBaseShape.this.getLayer().add( ctrl ); final Point2D origin = ctrl.getLocation(); final Point2D target = new Point2D( 0, 0 ); final Point2D origin = ctrl.getLocation(); final Point2D target = getControlTarget( ctrl ); transformations.put( ctrl,
/** * Gets the Y coordinate for this group. * * @return double */ @Override public double getY() { return getAttributes().getY(); }
@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 ); } }
object.put("type", new JSONString(getNodeType().getValue())); object.put("attributes", new JSONObject(getAttributes())); FastArrayList<IPrimitive<?>> list = getChildNodes();
/** * Attaches all primitives to the Layers Color Map */ @Override public void attachToLayerColorMap() { Layer layer = getLayer(); if (null != layer) { FastArrayList<IPrimitive<?>> list = getChildNodes(); if (null != list) { int size = list.length(); for (int i = 0; i < size; i++) { list.get(i).attachToLayerColorMap(); } } } }
@Override public Group setX( final double x ) { final Group g = super.setX( x ); updateControlLocations(); return g; }
@Override public Group setY( final double y ) { final Group g = super.setY( y ); updateControlLocations(); return g; }
int size = length(); IPrimitive<?> prim = getChildNodes().get(i);
@Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof WiresBaseShape ) ) { return false; } if ( !super.equals( o ) ) { return false; } WiresBaseShape that = (WiresBaseShape) o; if ( !id.equals( that.id ) ) { return false; } return true; }
@Override public Group create(JSONObject node, ValidationContext ctx) throws ValidationException { Group g = new Group(node); JSONDeserializer.getInstance().deserializeChildren(g, node, this, ctx); return g; }
@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(); }
/** * Sets the alpha value (transparency) on this group. * * @param alpha between 0 and 1 * @return Group this Group */ @Override public Group setAlpha(double alpha) { getAttributes().setAlpha(alpha); return this; }
/** * Detaches all primitives from the Layers Color Map */ @Override public void detachFromLayerColorMap() { Layer layer = getLayer(); if (null != layer) { FastArrayList<IPrimitive<?>> list = getChildNodes(); if (null != list) { int size = list.length(); for (int i = 0; i < size; i++) { list.get(i).detachFromLayerColorMap(); } } } }
/** * Constructor. Creates an instance of a group. */ protected Group(JSONObject node) { super(NodeType.GROUP, node); final Attributes attr = getAttributes(); if (NativeInternalType.NUMBER != attr.typeOf(Attribute.X)) { setX(0); } if (NativeInternalType.NUMBER != attr.typeOf(Attribute.Y)) { setY(0); } if (NativeInternalType.NUMBER != attr.typeOf(Attribute.ALPHA)) { setAlpha(1); } else { attr.setAlpha(attr.getAlpha()); // normalizes alpha if out of range } if (NativeInternalType.BOOLEAN != attr.typeOf(Attribute.DRAGGABLE)) { setDraggable(false); } }
@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(); }
/** * Sets if this group can be dragged. * * @param draggable true if the group can be dragged; false otherwise * @return Group this Group */ @Override public Group setDraggable(boolean draggable) { getAttributes().setDraggable(draggable); return this; }