Search in sources :

Example 1 with SVGPrimitive

use of org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive in project kie-wb-common by kiegroup.

the class CustomTaskShapeViewHandler method handle.

@Override
public void handle(final CustomTask bean, final SVGShapeView<?> view) {
    // Obtain the work item's icon data url.
    final WorkItemDefinition wid = workItemDefinitionRegistry.get().get(bean.getName());
    final String iconData;
    if (null != wid && null != wid.getIconDefinition() && null != wid.getIconDefinition().getIconData()) {
        iconData = wid.getIconDefinition().getIconData();
    } else {
        iconData = 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());
    }
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) SVGPrimitive(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive) Picture(com.ait.lienzo.client.core.shape.Picture)

Example 2 with SVGPrimitive

use of org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive in project kie-wb-common by kiegroup.

the class ServiceTaskShapeViewHandler method handle.

@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()).getIconData();
    final String iconData = null != itemIconData ? itemIconData : WorkItemDefinitionClientRegistry.DEFAULT_ICON_DATA;
    // Obtain the image element from the svg shape view.
    final SVGPrimitive svgPrimitive = SVGViewUtils.getPrimitive(view, WID_ICON_ID).get();
    // Load the image data.
    final Picture picture = (Picture) svgPrimitive.get();
    if (hasDataChanged(iconData, picture.getURL())) {
        LienzoPictureUtils.forceLoad(picture, iconData, view::refresh);
    }
}
Also used : SVGPrimitive(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive) Picture(com.ait.lienzo.client.core.shape.Picture)

Example 3 with SVGPrimitive

use of org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive in project kie-wb-common by kiegroup.

the class AbstractBaseViewHandlerTest method mockSVGPrimitive.

protected static SVGPrimitive mockSVGPrimitive(String id) {
    SVGPrimitive primitive = mock(SVGPrimitive.class);
    IPrimitive iPrimitive = mock(IPrimitive.class);
    when(primitive.getPrimitiveId()).thenReturn(id);
    when(primitive.get()).thenReturn(iPrimitive);
    when(iPrimitive.setFillAlpha(anyDouble())).thenReturn(iPrimitive);
    when(iPrimitive.setStrokeAlpha(anyDouble())).thenReturn(iPrimitive);
    return primitive;
}
Also used : SVGPrimitive(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive)

Aggregations

SVGPrimitive (org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive)3 Picture (com.ait.lienzo.client.core.shape.Picture)2 IPrimitive (com.ait.lienzo.client.core.shape.IPrimitive)1 WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)1