/** * Returns the parent. * * @return Node */ @Override public Node<?> getParent() { return super.getParent(); }
/** * Returns the Viewport that this Node is on. */ public Viewport getViewport() { Node<?> parent = getParent(); // change, no iteration, no testing, no casting, recurses upwards to a Viewport, and Viewport returns itself, CYCLES!!! if (null != parent) { return parent.getViewport(); } return null; }
/** * Returns the Layer that this Node is on. * * @return {@link Layer} */ public Layer getLayer() { Node<?> parent = getParent(); // change, no iteration, no testing, no casting, recurses upwards to a Layer, and Layer returns itself, CYCLES!!! if (null != parent) { return parent.getLayer(); } return null; }
/** * Returns the Scena that this Node is on. * * @return Scene */ @Override public Scene getScene() { Node<?> parent = getParent(); // change, no iteration, no testing, no casting, recurses upwards to a Scene, and Scene returns itself, CYCLES!!! if (null != parent) { return parent.getScene(); } return null; }
/** * Returns the absolute transform by concatenating the transforms * of all its ancestors from the Viewport down to this node's parent. * * @return {@link Transform} */ public Transform getAbsoluteTransform() { Transform xfrm = new Transform(); ArrayList<Node<?>> list = new ArrayList<Node<?>>(); list.add(this); Node<?> parent = this.getParent(); while (parent != null) { list.add(parent); parent = parent.getParent(); } int size = list.size(); // TODO no need to use a list for (int i = size - 1; i >= 0; i--) { xfrm.multiply(list.get(i).getCombinedTransform()); } return xfrm; }
/** * Returns global alpha value. * * @return double */ public final double getGlobalAlpha() { double alpha = 1; Node<?> node = this; while (null != node) { Attributes attr = node.getAttributes(); if (attr.isDefined(Attribute.ALPHA)) { alpha = alpha * attr.getAlpha(); } node = node.getParent(); } return alpha; }
private final IPrimitive<?> findPrimitiveForEvent(INodeXYEvent event, Type<?> type) { IPrimitive<?> find = null; Node<?> node = findShapeAtPoint(event.getX(), event.getY()); while ((null != node) && (node.getNodeType() != NodeType.LAYER)) { IPrimitive<?> prim = node.asPrimitive(); if ((null != prim) && (prim.isListening()) && (prim.isVisible()) && (prim.isEventHandled(type))) { find = prim; // find the topmost event matching node, not necessarily the first ancestor } node = node.getParent(); } return find; }
private final void doPrepareDragging(INodeXYEvent event) { IPrimitive<?> find = null; Node<?> node = findShapeAtPoint(event.getX(), event.getY()); while ((null != node) && (node.getNodeType() != NodeType.LAYER)) { IPrimitive<?> prim = node.asPrimitive(); if ((null != prim) && (prim.isDraggable()) && (prim.isListening()) && (prim.isVisible())) { find = prim; // find the topmost draggable node, not necessarily the first ancestor } node = node.getParent(); } if (null != find) { doDragStart(find, event); } }