@Test @SuppressWarnings("unchecked") public void testGetElementAt_root() throws Exception { when(canvas.getShapeAt(eq(X), eq(Y))).thenReturn(Optional.empty()); final Node<View<BPMNViewDefinition>, Edge> root = mockCanvasDiagramNode("uuid", shape -> when(canvas.getShapes()).thenReturn(Collections.<Shape>singletonList(shape))); final Optional<Element> node = handler.getElementAt(X, Y); verify(transform, times(1)).transform(eq(X), eq(Y)); verify(canvas, times(1)).getShapeAt(eq(X), eq(Y)); verify(canvas, times(1)).getShapes(); assertTrue(node.isPresent()); assertEquals(root, node.get()); }
@Override public Optional<Element> getElementAt(double x, double y) { if (Double.compare(x, 0d) <= 0 || Double.compare(y, 0d) <= 0) { return Optional.empty(); } final Point2D transform = this.getAbstractCanvas().getTransform().transform(x, y); final Optional<Element> parent = super.getElementAt(transform.getX(), transform.getY()); return parent.isPresent() ? parent : this.getDiagramNode(); }
CaseManagementCanvasHandler extends CanvasHandlerImpl<D, C> { @Override public Optional<Element> getElementAt(double x, double y) { if (Double.compare(x, 0d) <= 0 || Double.compare(y, 0d) <= 0) { return Optional.empty(); } final Point2D transform = this.getAbstractCanvas().getTransform().transform(x, y); final Optional<Element> parent = super.getElementAt(transform.getX(), transform.getY()); return parent.isPresent() ? parent : this.getDiagramNode(); } }
CaseManagementCanvasHandler extends CanvasHandlerImpl<D, C> { @Override public Optional<Element> getElementAt(double x, double y) { if (Double.compare(x, 0d) <= 0 || Double.compare(y, 0d) <= 0) { return Optional.empty(); } final Point2D transform = this.getAbstractCanvas().getTransform().transform(x, y); final Optional<Element> parent = super.getElementAt(transform.getX(), transform.getY()); return parent.isPresent() ? parent : this.getDiagramNode(); } @Inject  CaseManagementCanvasHandler(final ClientDefinitionManager clientDefinitionManager,
                                       final RuleManager ruleManager,
                                       final GraphUtils graphUtils,
                                       final GraphIndexBuilder<? extends MutableIndex<Node, Edge>> indexBuilder,
                                       final ShapeManager shapeManager,
                                       final TextPropertyProviderFactory textPropertyProviderFactory,
                                       final Event<CanvasElementAddedEvent> canvasElementAddedEvent,
                                       final Event<CanvasElementRemovedEvent> canvasElementRemovedEvent,
                                       final Event<CanvasElementUpdatedEvent> canvasElementUpdatedEvent,
                                       final Event<CanvasElementsClearEvent> canvasElementsClearEvent,
                                       final @CaseManagementEditor CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory); }
CaseManagementCanvasHandler extends CanvasHandlerImpl<D, C> { @Override public Optional<Element> getElementAt(double x, double y) { if (Double.compare(x, 0d) <= 0 || Double.compare(y, 0d) <= 0) { return Optional.empty(); } final Point2D transform = this.getAbstractCanvas().getTransform().transform(x, y); final Optional<Element> parent = super.getElementAt(transform.getX(), transform.getY()); return parent.isPresent() ? parent : this.getDiagramNode(); } @Inject  CaseManagementCanvasHandler(final ClientDefinitionManager clientDefinitionManager,
                                       final RuleManager ruleManager,
                                       final GraphUtils graphUtils,
                                       final GraphIndexBuilder<? extends MutableIndex<Node, Edge>> indexBuilder,
                                       final ShapeManager shapeManager,
                                       final TextPropertyProviderFactory textPropertyProviderFactory,
                                       final Event<CanvasElementAddedEvent> canvasElementAddedEvent,
                                       final Event<CanvasElementRemovedEvent> canvasElementRemovedEvent,
                                       final Event<CanvasElementUpdatedEvent> canvasElementUpdatedEvent,
                                       final Event<CanvasElementsClearEvent> canvasElementsClearEvent,
                                       final @CaseManagementEditor CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory); @Override boolean isCanvasRoot(final Element parent); @Override void register(final Shape shape,
                         final Element<View<?>> candidate,
                         final boolean fireEvents); @Override void deregister(final Shape shape,
                           final Element element,
                           final boolean fireEvents); @Override void addShape(final Shape shape); @Override void addChild(final Element parent,
                         final Element child); @SuppressWarnings("unchecked") void addChild(final Element parent,
                         final Element child,
                         final int index); @Override void removeShape(final Shape shape); @Override void removeChild(final Element parent,
                            final Element child); @Override void applyElementMutation(final Shape shape,
                                     final Element candidate,
                                     final boolean applyPosition,
                                     final boolean applyProperties,
                                     final MutationContext mutationContext); @Override void applyElementMutation(final Element candidate,
                                     final boolean applyPosition,
                                     final boolean applyProperties,
                                     final MutationContext mutationContext); Optional<Element> getDiagramNode(); @Override Optional<Element> getElementAt(double x, double y); }
CaseManagementCanvasHandler extends CanvasHandlerImpl<D, C> { @Override public Optional<Element> getElementAt(double x, double y) { if (Double.compare(x, 0d) <= 0 || Double.compare(y, 0d) <= 0) { return Optional.empty(); } final Point2D transform = this.getAbstractCanvas().getTransform().transform(x, y); final Optional<Element> parent = super.getElementAt(transform.getX(), transform.getY()); return parent.isPresent() ? parent : this.getDiagramNode(); } @Inject  CaseManagementCanvasHandler(final ClientDefinitionManager clientDefinitionManager,
                                       final RuleManager ruleManager,
                                       final GraphUtils graphUtils,
                                       final GraphIndexBuilder<? extends MutableIndex<Node, Edge>> indexBuilder,
                                       final ShapeManager shapeManager,
                                       final TextPropertyProviderFactory textPropertyProviderFactory,
                                       final Event<CanvasElementAddedEvent> canvasElementAddedEvent,
                                       final Event<CanvasElementRemovedEvent> canvasElementRemovedEvent,
                                       final Event<CanvasElementUpdatedEvent> canvasElementUpdatedEvent,
                                       final Event<CanvasElementsClearEvent> canvasElementsClearEvent,
                                       final @CaseManagementEditor CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory); @Override boolean isCanvasRoot(final Element parent); @Override void register(final Shape shape,
                         final Element<View<?>> candidate,
                         final boolean fireEvents); @Override void deregister(final Shape shape,
                           final Element element,
                           final boolean fireEvents); @Override void addShape(final Shape shape); @Override void addChild(final Element parent,
                         final Element child); @SuppressWarnings("unchecked") void addChild(final Element parent,
                         final Element child,
                         final int index); @Override void removeShape(final Shape shape); @Override void removeChild(final Element parent,
                            final Element child); @Override void applyElementMutation(final Shape shape,
                                     final Element candidate,
                                     final boolean applyPosition,
                                     final boolean applyProperties,
                                     final MutationContext mutationContext); @Override void applyElementMutation(final Element candidate,
                                     final boolean applyPosition,
                                     final boolean applyProperties,
                                     final MutationContext mutationContext); Optional<Element> getDiagramNode(); @Override Optional<Element> getElementAt(double x, double y);  }