Search in sources :

Example 1 with NodeDragStartEvent

use of com.ait.lienzo.client.core.event.NodeDragStartEvent in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(svgPrimitive.get()).thenReturn(shape);
    when(shape.getAttributes()).thenReturn(attributes);
    when(shape.asNode()).thenReturn(shapeNode);
    when(attributes.getDouble(Attribute.WIDTH.getProperty())).thenReturn(WIDTH);
    when(attributes.getDouble(Attribute.HEIGHT.getProperty())).thenReturn(HEIGHT);
    this.nodeDragStartEvent = new NodeDragStartEvent(dragContext);
    this.nodeDragMoveEvent = new NodeDragMoveEvent(dragContext);
    this.nodeDragEndEvent = new NodeDragEndEvent(dragContext);
    this.view = new DecisionServiceSVGShapeView("name", svgPrimitive, WIDTH, HEIGHT, true);
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) Before(org.junit.Before)

Example 2 with NodeDragStartEvent

use of com.ait.lienzo.client.core.event.NodeDragStartEvent in project lienzo-core by ahome-it.

the class WiresContainer method ensureHandlers.

private void ensureHandlers() {
    if (!m_drag_initialized && (null != m_container)) {
        m_registrationManager.register(m_container.addNodeDragStartHandler(new NodeDragStartHandler() {

            @Override
            public void onNodeDragStart(final NodeDragStartEvent event) {
                WiresContainer.this.m_dragging = true;
                m_events.fireEvent(new WiresDragStartEvent(WiresContainer.this, event));
            }
        }));
        m_registrationManager.register(m_container.addNodeDragMoveHandler(new NodeDragMoveHandler() {

            @Override
            public void onNodeDragMove(final NodeDragMoveEvent event) {
                WiresContainer.this.m_dragging = true;
                m_events.fireEvent(new WiresDragMoveEvent(WiresContainer.this, event));
            }
        }));
        m_registrationManager.register(m_container.addNodeDragEndHandler(new NodeDragEndHandler() {

            @Override
            public void onNodeDragEnd(final NodeDragEndEvent event) {
                WiresContainer.this.m_dragging = false;
                m_events.fireEvent(new WiresDragEndEvent(WiresContainer.this, event));
            }
        }));
        m_container.setAttributesChangedBatcher(m_attributesChangedBatcher);
        final AttributesChangedHandler handler = new AttributesChangedHandler() {

            @Override
            public void onAttributesChanged(final AttributesChangedEvent event) {
                if (!WiresContainer.this.m_dragging && event.evaluate(XYWH_OP)) {
                    fireMove();
                }
            }
        };
        // Attribute change handlers.
        m_registrationManager.register(m_container.addAttributesChangedHandler(Attribute.X, handler));
        m_registrationManager.register(m_container.addAttributesChangedHandler(Attribute.Y, handler));
        m_drag_initialized = true;
    }
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) NodeDragStartHandler(com.ait.lienzo.client.core.event.NodeDragStartHandler) NodeDragMoveHandler(com.ait.lienzo.client.core.event.NodeDragMoveHandler) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) WiresDragEndEvent(com.ait.lienzo.client.core.shape.wires.event.WiresDragEndEvent) AttributesChangedHandler(com.ait.lienzo.client.core.event.AttributesChangedHandler) AttributesChangedEvent(com.ait.lienzo.client.core.event.AttributesChangedEvent) NodeDragEndHandler(com.ait.lienzo.client.core.event.NodeDragEndHandler) WiresDragStartEvent(com.ait.lienzo.client.core.shape.wires.event.WiresDragStartEvent) WiresDragMoveEvent(com.ait.lienzo.client.core.shape.wires.event.WiresDragMoveEvent)

Example 3 with NodeDragStartEvent

use of com.ait.lienzo.client.core.event.NodeDragStartEvent in project lienzo-core by ahome-it.

the class LienzoHandlerManager method doDragStart.

private final void doDragStart(final IPrimitive<?> node, final INodeXYEvent event) {
    if (m_dragging) {
        doDragCancel(event);
    }
    Cursor cursor = m_lienzo.getSelectCursor();
    if (null == cursor) {
        cursor = LienzoCore.get().getDefaultSelectCursor();
        if (null == cursor) {
            cursor = Cursor.CROSSHAIR;
        }
    }
    m_lienzo.setCursor(cursor);
    m_drag_node = node;
    m_drag_mode = node.getDragMode();
    m_dragContext = new DragContext(event, node, m_viewport.getTransform().getInverse());
    m_drag_node.setDragging(true);
    m_drag_node.fireEvent(new NodeDragStartEvent(m_dragContext));
    m_dragging = true;
    if (DragMode.DRAG_LAYER == m_drag_mode) {
        m_drag_node.setVisible(false);
        m_drag_node.getLayer().draw();
        m_dragContext.drawNodeWithTransforms(m_lienzo.getDragLayer().getContext());
    }
    m_dragging_dispatch_move = m_drag_node.isEventHandled(NodeDragMoveEvent.getType());
    m_dragging_using_touches = ((event.getNodeEvent().getAssociatedType() == NodeTouchMoveEvent.getType()) || (event.getNodeEvent().getAssociatedType() == NodeTouchStartEvent.getType()));
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) Cursor(com.google.gwt.dom.client.Style.Cursor)

Aggregations

NodeDragStartEvent (com.ait.lienzo.client.core.event.NodeDragStartEvent)3 NodeDragEndEvent (com.ait.lienzo.client.core.event.NodeDragEndEvent)2 NodeDragMoveEvent (com.ait.lienzo.client.core.event.NodeDragMoveEvent)2 AttributesChangedEvent (com.ait.lienzo.client.core.event.AttributesChangedEvent)1 AttributesChangedHandler (com.ait.lienzo.client.core.event.AttributesChangedHandler)1 NodeDragEndHandler (com.ait.lienzo.client.core.event.NodeDragEndHandler)1 NodeDragMoveHandler (com.ait.lienzo.client.core.event.NodeDragMoveHandler)1 NodeDragStartHandler (com.ait.lienzo.client.core.event.NodeDragStartHandler)1 WiresDragEndEvent (com.ait.lienzo.client.core.shape.wires.event.WiresDragEndEvent)1 WiresDragMoveEvent (com.ait.lienzo.client.core.shape.wires.event.WiresDragMoveEvent)1 WiresDragStartEvent (com.ait.lienzo.client.core.shape.wires.event.WiresDragStartEvent)1 Cursor (com.google.gwt.dom.client.Style.Cursor)1 Before (org.junit.Before)1