public HandlerRegistration addNodeMouseClickHandler(NodeMouseClickHandler handler) { return addEnsureHandler(NodeMouseClickEvent.getType(), handler); }
public T setTransform(Transform transform) { getAttributes().setTransform(transform); return cast(); }
/** * Used internally. Applies the node's transform-related attributes * to the current context, draws the node (and it's children, if any) * and restores the context. */ public void drawWithTransforms(Context2D context) { if (context.isDrag() || isVisible()) { context.save(); Transform xfrm = getCombinedTransform(); context.transform(xfrm); drawWithoutTransforms(context); context.restore(); } }
@Override public boolean init(Node<?> node) { if ((node != null) && (m_attribute != null) && (node.getAttributeSheet().contains(m_attribute))) { m_origin = node.getAttributes().getDouble(m_attribute.getProperty()); return true; } return false; }
@Override public T copy() { Node<?> node = copyUnchecked(); if (null == node) { return null; } if (getNodeType() != node.getNodeType()) { return null; } return node.cast(); }
private final void onNodeMouseOver(INodeXYEvent event) { Node<?> node = doCheckEnterExitShape(event); if ((null != node) && (node.isListening()) && (node.isVisible()) && (node.isEventHandled(NodeMouseOverEvent.getType()))) { node.fireEvent(event.getNodeEvent()); } fireEvent(event.getNodeEvent()); }
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; }
/** * Moves this layer one level up. * * @return Layer */ @SuppressWarnings("unchecked") @Override public Layer moveUp() { Node<?> parent = getParent(); if (null != parent) { IContainer<Layer> container = (IContainer<Layer>) parent.asContainer(); if (null != container) { container.moveUp(this); } } return this; }
@Override protected String getColorString(Node<?> node) { return node.getAttributes().getFillColor(); }
/** * 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; }
Attributes attr = getAttributes(); Transform t2 = getTransform();
/** * Sets whether the node is visible. * * @param visible * @return this Node */ public T setVisible(boolean visible) { m_attr.setVisible(visible); return cast(); }
@Override public boolean init(Node<?> node) { if ((node != null) && (m_attribute != null) && (node.getAttributeSheet().contains(m_attribute))) { return true; } return false; }
/** * Starts a drag operation for the specified node. * * @param event the first drag event * @param node the node that is being dragged */ public DragContext(INodeXYEvent event, IPrimitive<?> node) { m_node = node; m_nodeX = node.getX(); m_nodeY = node.getY(); m_eventX = m_dragStartX = event.getX(); m_eventY = m_dragStartY = event.getY(); m_localToGlobal = m_node.getParent().getAbsoluteTransform(); m_globalToLocal = m_localToGlobal.getInverse(); // Convert one point from global to local coordinates // We need it when calculating (dx,dy) in local coordinates m_globalToLocal.transform(new Point2D(0, 0), m_p1); // Initialize the DragConstraintsEnforcer m_dragConstraints = node.getDragConstraints(); if (m_dragConstraints != null) m_dragConstraints.startDrag(this); }
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); } }
@Override public boolean init(Node<?> node) { if ((node != null) && (m_attribute != null) && (node.getAttributeSheet().contains(m_attribute))) { m_origin = node.getAttributes().getPoint2D(m_attribute.getProperty()); if (null == m_origin) { m_origin = new Point2D(1, 1); } return true; } return false; }
/** * Moves this group's {@link Layer} one level up * * @return Group this Group */ @SuppressWarnings("unchecked") @Override public Group moveUp() { Node<?> parent = getParent(); if (null != parent) { IContainer<IPrimitive<?>> container = (IContainer<IPrimitive<?>>) parent.asContainer(); if (null != container) { container.moveUp(this); } } return this; }
@Override protected String getColorString(Node<?> node) { return node.getAttributes().getStrokeColor(); }
/** * Sets whether this node is listening for events. * * @param listening * @return this Node */ public T setListening(boolean listening) { m_attr.setListening(listening); return cast(); }