@Override protected void addChild(final Shape shape) { getView().addRoot(shape.getShapeView()); }
@Override protected void deleteChild(final Shape shape) { getView().deleteRoot(shape.getShapeView()); }
@Override protected LienzoCanvasView<WiresLayer> doInitialize(CanvasSettings canvasSettings) { final LienzoCanvasView<WiresLayer> canvasView = super.doInitialize(canvasSettings); boundsPanel = Optional.ofNullable(canvasView.getLienzoPanel().getView()); return canvasView; }
@Override public DragProxy<AbstractCanvas, ShapeView<?>, DragProxyCallback> proxyFor(final AbstractCanvas context) { this.layer = ((WiresCanvas) context).getView().getLayer(); return this; }
@Override public AbstractCanvas<WiresCanvasView> initialize(final CanvasPanel panel, final CanvasSettings settings) { super.initialize(panel, settings); final WiresLayer layer = getView().getLayer(); wiresManager = wiresManagerFactory.newWiresManager(layer.getLienzoLayer()); wiresManager.setSpliceEnabled(false); // Set the default NONE acceptors for wires capabilities. // Each of these ones is being handled by each of the canvas controls associated wiresManager.setLocationAcceptor(ILocationAcceptor.NONE); wiresManager.setContainmentAcceptor(IContainmentAcceptor.NONE); wiresManager.setDockingAcceptor(IDockingAcceptor.NONE); wiresManager.setConnectionAcceptor(IConnectionAcceptor.NONE); wiresManager.setControlPointsAcceptor(IControlPointsAcceptor.NONE); view.use(wiresManager); return this; }
protected void onMouseEnter() { if (null != canvas) { canvas.getView().setCursor(AbstractCanvas.Cursors.POINTER); } }
@SuppressWarnings("unchecked") @Override protected void onAfterCanvasInitialized() { super.onAfterCanvasInitialized(); canvas.getView().setDecoratorFactory(LienzoCanvasDecoratorFactory.PREVIEW); }
@Override public WiresCanvasView add(final ShapeView<?> shapeView) { if (WiresUtils.isWiresShape(shapeView)) { WiresShape wiresShape = (WiresShape) shapeView; getLayer().getWiresManager().register(wiresShape, false); WiresUtils.assertShapeGroup(wiresShape.getGroup(), WiresCanvas.WIRES_CANVAS_GROUP_ID); } else if (WiresUtils.isWiresConnector(shapeView)) { //Don't render connectors } else { super.add(shapeView); } return this; }
@Test @SuppressWarnings("unchecked") public void testScale() { when(canvas.getWidthPx()).thenReturn(100); when(canvas.getHeightPx()).thenReturn(100); tested.open(diagram, callback); tested.scale(50, 50); assertEquals(diagram, tested.getInstance()); verify(zoomControlInstance, times(1)).scale(eq(0.5d), eq(0.5d)); verify(canvasView, times(1)).setPixelSize(50, 50); }
when(canvas.getView()).thenReturn(canvasView); when(getCanvasPanel().asWidget()).thenReturn(canvasViewWidget); when(canvasView.asWidget()).thenReturn(canvasViewWidget); when(canvasHandler.getCanvas()).thenReturn(canvas); when(canvasHandler.getAbstractCanvas()).thenReturn(canvas);
@Before @SuppressWarnings("unchecked") public void setup() throws Exception { super.init(); when(canvasView.getLienzoPanel()).thenReturn(canvasPanel); canvases = spy(new ManagedInstanceStub<>(canvas)); canvasPanels = spy(new ManagedInstanceStub<>(canvasPanel)); canvasHandlers = spy(new ManagedInstanceStub<>(canvasHandler)); zoomControl = spy(new ManagedInstanceStub<>(zoomControlInstance)); selectionControl = spy(new ManagedInstanceStub<>(selectionControlInstance)); when(metadata.getDefinitionSetId()).thenReturn(DEFINITION_SET_ID); when(preferencesRegistries.get(DEFINITION_SET_ID, StunnerPreferences.class)).thenReturn(stunnerPreferences); this.tested = new DefaultDiagramViewer(definitionUtils, canvases, canvasPanels, canvasHandlers, zoomControl, selectionControl, view, preferencesRegistries); }
protected LienzoLayer getLayer() { final WiresCanvas wiresCanvas = (WiresCanvas) canvas; final WiresCanvasView view = wiresCanvas.getView(); final WiresLayer layer = view.getLayer(); return layer; }
protected void onMouseExit() { if (null != canvas) { canvas.getView().setCursor(AbstractCanvas.Cursors.AUTO); } }
private static LienzoLayer getLayer(final AbstractCanvasHandler canvasHandler) { return ((WiresCanvas) canvasHandler.getCanvas()).getView().getLayer(); } }
@Override @SuppressWarnings("unchecked") public Node<View<?>, Edge> getAt(final double x, final double y) { final WiresCanvas canvas = (WiresCanvas) canvasHandler.getAbstractCanvas(); final LienzoLayer lienzoLayer = canvas.getView().getLayer(); final String viewUUID = LienzoLayerUtils.getUUID_At(lienzoLayer, x, y); if (null != viewUUID && viewUUID.trim().length() > 0) { final Shape<?> shape = canvas.getShape(viewUUID); if (null != shape) { return canvasHandler.getGraphIndex().getNode(shape.getUUID()); } } return null; }
protected V init(final ActionsToolbox toolbox, final WiresCanvas canvas, final WiresShape shape) { this.canvas = canvas; final Layer topLayer = canvas.getView().getLayer().getTopLayer(); this.toolboxView = toolboxFactory .forWiresShape(shape) .attachTo(topLayer); configure(toolbox); tooltip = createTooltip(toolbox); return cast(); }
final Element parentNode) { final WiresCanvas canvas = (WiresCanvas) canvasHandler.getAbstractCanvas(); final LienzoLayer lienzoLayer = canvas.getView().getLayer(); Node node;