public String getId() { return get().getID(); }
@SuppressWarnings("unchecked") public void addChild(final SVGPrimitive<?> child) { final IPrimitive<?> primitive = child.get(); primChildren.add(child); if (child.isScalable() && view instanceof DecoratedShapeView) { ((DecoratedShapeView) view).addScalableChild(primitive); } else if (null != child.getLayout()) { view.addChild(primitive, child.getLayout()); } else { view.addChild(primitive); } }
@Before public void setup() throws Exception { when(primitive1.getPrimitiveId()).thenReturn("p1"); when(primitive2.getPrimitiveId()).thenReturn("p2"); when(primitive1.get()).thenReturn(p1); when(primitive2.get()).thenReturn(p2); when(svgShape.getChildren()).thenReturn(Arrays.asList(primitive1, primitive2)); }
@Before @SuppressWarnings("unchecked") public void init() throws Exception { this.task = new ServiceTask(); task.getDimensionsSet().getWidth().setValue(WIDTH); task.getDimensionsSet().getHeight().setValue(HEIGHT); this.task.setName(WID_ID); when(node.getDefinition()).thenReturn(task); when(node.getBounds()).thenReturn(BOUNDS); when(registry.items()).thenReturn(Collections.singleton(DEF)); when(registry.get(eq(WID_ID))).thenReturn(DEF); when(view.getChildren()).thenReturn(Collections.singletonList(imageSvgPrimitive)); when(imageSvgPrimitive.getId()).thenReturn(ServiceTaskShapeViewHandler.WID_ICON_ID); when(imageSvgPrimitive.get()).thenReturn(imagePrimitive); when(imageSvgPrimitive.getPrimitiveId()).thenReturn(ServiceTaskShapeViewHandler.WID_ICON_ID); when(imagePrimitive.getID()).thenReturn(ServiceTaskShapeViewHandler.WID_ICON_ID); when(imagePrimitive.getImageProxy()).thenReturn(imageProxy); this.tested = new ServiceTaskShapeDef(() -> registry, iconDataGlyphGenerator); }
@Test public void testGetters() { assertEquals("rect1", tested.getId()); assertEquals(LayoutContainer.Layout.BOTTOM, tested.getLayout()); assertEquals(rectangle, tested.get()); assertTrue(tested.isScalable()); } }
public void init() { when(view.getChildren()).thenReturn(Arrays.asList(child1, child2)); when(child1.getId()).thenReturn("child1"); when(child1.get()).thenReturn(prim1); when(child2.getId()).thenReturn("child2"); when(child2.get()).thenReturn(prim2); when(prim1.setAlpha(anyDouble())).thenReturn(prim1); when(prim1.setStrokeAlpha(anyDouble())).thenReturn(prim1); when(prim1.setFillAlpha(anyDouble())).thenReturn(prim1); when(prim2.setAlpha(anyDouble())).thenReturn(prim2); when(prim2.setStrokeAlpha(anyDouble())).thenReturn(prim2); when(prim2.setFillAlpha(anyDouble())).thenReturn(prim2); } }
@Before @SuppressWarnings("unchecked") public void init() { task = new ServiceTask(); task.setName(WID_ID); task.setDimensionsSet(new RectangleDimensionsSet()); width = spy(new Width(0d)); height = spy(new Height(0d)); task.getDimensionsSet().setWidth(width); task.getDimensionsSet().setHeight(height); when(registry.items()).thenReturn(Collections.singleton(DEF)); when(registry.get(eq(WID_ID))).thenReturn(DEF); when(view.getChildren()).thenReturn(Collections.singletonList(iconSVGPrimiite)); when(iconSVGPrimiite.getId()).thenReturn(ServiceTaskShapeViewHandler.WID_ICON_ID); when(iconSVGPrimiite.get()).thenReturn(icon); when(iconSVGPrimiite.getPrimitiveId()).thenReturn(ServiceTaskShapeViewHandler.WID_ICON_ID); when(icon.getID()).thenReturn(ServiceTaskShapeViewHandler.WID_ICON_ID); when(icon.getImageProxy()).thenReturn(imageProxy); when(view.getPrimitive()).thenReturn(iconSVGPrimiite); when(icon.getAttributes()).thenReturn(svgAttr); when(svgAttr.getHeight()).thenReturn(HEIGHT); when(svgAttr.getWidth()).thenReturn(WIDTH); this.tested = new ServiceTaskShapeViewHandler(() -> registry); }
@Test public void testGetPrimitive() { Optional<SVGPrimitive> r1 = SVGViewUtils.getPrimitive(svgShape, "p1"); assertTrue(r1.isPresent()); assertEquals(primitive1, r1.get()); assertEquals(p1, r1.get().get()); Optional<SVGPrimitive> r2 = SVGViewUtils.getPrimitive(svgShape, "p2"); assertTrue(r2.isPresent()); assertEquals(primitive2, r2.get()); assertEquals(p2, r2.get().get()); }
@Override public void handle(final ServiceTask bean, final SVGShapeView<?> view) { // Obtain the work item's icon data url. final String itemIconData = workItemDefinitionRegistry .get() .get(bean.getName()) .getIconDefinition() .getIconData(); final String iconData = null != itemIconData ? itemIconData : WorkItemDefinitionClientUtils.getDefaultIconData(); // Obtain the image element from the svg shape view. final SVGPrimitive svgPrimitive = SVGViewUtils.getPrimitive(view, WID_ICON_ID).get(); // Load the icon data. final Picture icon = (Picture) svgPrimitive.get(); if (hasDataChanged(iconData, icon.getURL())) { forceLoad(icon, iconData, () -> scaleViewIcon(view, icon)); } if (Objects.equals(bean.getDimensionsSet().getHeight().getValue(), 0d) && Objects.equals(bean.getDimensionsSet().getWidth().getValue(), 0d)) { bean.getDimensionsSet().getHeight().setValue(view.getPrimitive().get().getAttributes().getHeight()); bean.getDimensionsSet().getWidth().setValue(view.getPrimitive().get().getAttributes().getWidth()); } }
@Override public void handle(final BaseCatchingIntermediateEvent bean, final SVGShapeView<?> view) { Boolean isCancelActivity = null; if (bean instanceof IntermediateSignalEventCatching) { isCancelActivity = ((IntermediateSignalEventCatching) bean).getExecutionSet().getCancelActivity().getValue(); } else if (bean instanceof IntermediateTimerEvent) { isCancelActivity = ((IntermediateTimerEvent) bean).getExecutionSet().getCancelActivity().getValue(); } else if (bean instanceof IntermediateMessageEventCatching) { isCancelActivity = ((IntermediateMessageEventCatching) bean).getExecutionSet().getCancelActivity().getValue(); } else if (bean instanceof IntermediateConditionalEvent) { isCancelActivity = ((IntermediateConditionalEvent) bean).getExecutionSet().getCancelActivity().getValue(); } else if (bean instanceof IntermediateEscalationEvent) { isCancelActivity = ((IntermediateEscalationEvent) bean).getExecutionSet().getCancelActivity().getValue(); } if (null != isCancelActivity) { // Cancel -> Normal // NO Cancel -> dash final double fillAlpha = isCancelActivity ? 1 : 0; final double strokeAlpha = isCancelActivity ? 0 : 1; SVGViewUtils.getPrimitive(view, ID_INTERMEDIATE) .ifPresent(p -> p.get().setFillAlpha(fillAlpha).setStrokeAlpha(strokeAlpha)); } } }
@Override public void handle(final BaseStartEvent bean, final SVGShapeView<?> view) { Boolean isInterrupting = null; if (bean instanceof StartMessageEvent) { isInterrupting = ((StartMessageEvent) bean).getExecutionSet().getIsInterrupting().getValue(); } else if (bean instanceof StartTimerEvent) { isInterrupting = ((StartTimerEvent) bean).getExecutionSet().getIsInterrupting().getValue(); } else if (bean instanceof StartSignalEvent) { isInterrupting = ((StartSignalEvent) bean).getExecutionSet().getIsInterrupting().getValue(); } else if (bean instanceof StartConditionalEvent) { isInterrupting = ((StartConditionalEvent) bean).getExecutionSet().getIsInterrupting().getValue(); } else if (bean instanceof StartEscalationEvent) { isInterrupting = ((StartEscalationEvent) bean).getExecutionSet().getIsInterrupting().getValue(); } if (null != isInterrupting) { // Interrupting -> Normal // NO Interrupting -> dash final double fillAlpha = isInterrupting ? 1 : 0; final double strokeAlpha = isInterrupting ? 0 : 1; SVGViewUtils.getPrimitive(view, ID_START) .ifPresent(p -> p.get().setFillAlpha(fillAlpha).setStrokeAlpha(strokeAlpha)); } } }