Search in sources :

Example 26 with BoundImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.

the class UpdateElementPositionCommandTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    super.setUp();
    when(candidate.getUUID()).thenReturn("uuid1");
    when(candidate.getContent()).thenReturn(content);
    when(content.getBounds()).thenReturn(new BoundsImpl(new BoundImpl(3d, 27d), new BoundImpl(50d, 50d)));
    this.tested = new UpdateElementPositionCommand(candidate, new Point2D(100d, 200d));
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Before(org.junit.Before)

Example 27 with BoundImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.

the class TestingGraphMockHandler method newViewNode.

public Node newViewNode(String uuid, Optional<Object> def, final double x, final double y, final double w, final double h) {
    final Object definition = def.isPresent() ? def.get() : newDef("def-" + uuid, Optional.empty());
    when(definitionUtils.buildBounds(eq(definition), anyDouble(), anyDouble())).thenReturn(new BoundsImpl(new BoundImpl(x, y), new BoundImpl(x + w, y + h)));
    final Node<Definition<Object>, Edge> result = nodeFactory.build(uuid, definition);
    execute(commandFactory.addNode(result));
    when(graphIndex.getNode(eq(uuid))).thenReturn(result);
    when(graphIndex.get(eq(uuid))).thenReturn(result);
    return result;
}
Also used : BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 28 with BoundImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testBuildToolboxForDecisionType.

@Test
@SuppressWarnings("unchecked")
public void testBuildToolboxForDecisionType() {
    final Node<View<Decision>, Edge> decisionNode = new NodeImpl<>("decisionNode1");
    final Decision decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    final Optional<Toolbox<?>> _toolbox = tested.build(canvasHandler, decisionNode);
    assertTrue(_toolbox.isPresent());
    Toolbox<?> toolbox = _toolbox.get();
    assertTrue(toolbox instanceof ActionsToolbox);
    final ActionsToolbox actionsToolbox = (ActionsToolbox) toolbox;
    assertEquals("decisionNode1", actionsToolbox.getElementUUID());
    assertEquals(2, actionsToolbox.size());
    final Iterator<ToolboxAction> actionsIt = actionsToolbox.iterator();
    assertEquals(deleteNodeAction, actionsIt.next());
    assertEquals(editDecisionToolboxAction, actionsIt.next());
    assertFalse(actionsIt.hasNext());
    verify(view, times(1)).init(eq(actionsToolbox));
    verify(view, times(2)).addButton(any(Glyph.class), anyString(), any(Consumer.class));
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ActionsToolboxView(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolboxView) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Consumer(java.util.function.Consumer) ToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ToolboxAction) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Toolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.Toolbox) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 29 with BoundImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.

the class DMNEditDecisionToolboxActionTest method setup.

@Before
public void setup() throws Exception {
    decisionNode = new NodeImpl<>(E_UUID);
    decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(graphIndex.get(eq(E_UUID))).thenReturn(decisionNode);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    this.tested = new DMNEditDecisionToolboxAction(sessionManager, translationService, editExpressionEvent);
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Before(org.junit.Before)

Example 30 with BoundImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.

the class DMNMarshaller method internalAugment.

private void internalAugment(Stream<DMNShape> drgShapeStream, Id id, Bound ul, RectangleDimensionsSet dimensionsSet, Bound lr, BackgroundSet bgset, Consumer<FontSet> fontSetSetter) {
    Optional<DMNShape> drgShapeOpt = drgShapeStream.filter(shape -> shape.getDmnElementRef().equals(id.getValue())).findFirst();
    if (!drgShapeOpt.isPresent()) {
        return;
    }
    DMNShape drgShape = drgShapeOpt.get();
    ((BoundImpl) ul).setX(drgShape.getBounds().getX());
    ((BoundImpl) ul).setY(drgShape.getBounds().getY());
    dimensionsSet.setWidth(new Width(drgShape.getBounds().getWidth()));
    dimensionsSet.setHeight(new Height(drgShape.getBounds().getHeight()));
    ((BoundImpl) lr).setX(drgShape.getBounds().getX() + drgShape.getBounds().getWidth());
    ((BoundImpl) lr).setY(drgShape.getBounds().getY() + drgShape.getBounds().getHeight());
    if (null != drgShape.getBgColor()) {
        bgset.setBgColour(new BgColour(ColorUtils.wbFromDMN(drgShape.getBgColor())));
    }
    if (null != drgShape.getBorderColor()) {
        bgset.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(drgShape.getBorderColor())));
    }
    if (null != drgShape.getBorderSize()) {
        bgset.setBorderSize(new BorderSize(drgShape.getBorderSize().getValue()));
    }
    if (null != drgShape.getFontStyle()) {
        fontSetSetter.accept(FontSetPropertyConverter.wbFromDMN(drgShape.getFontStyle()));
    }
}
Also used : DMNShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNShape) Arrays(java.util.Arrays) DecisionConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionConverter) Edge(org.kie.workbench.common.stunner.core.graph.Edge) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.v1_1.KnowledgeSource) UUID(org.kie.workbench.common.stunner.core.util.UUID) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Definitions(org.kie.workbench.common.dmn.api.definition.v1_1.Definitions) TextAnnotationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.TextAnnotationConverter) Bounds(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.org.omg.spec.CMMN_20151109_DC.Bounds) Map(java.util.Map) DMNDiagram(org.kie.workbench.common.dmn.api.definition.v1_1.DMNDiagram) ServerMarshalling(org.jboss.errai.marshalling.server.ServerMarshalling) BgColour(org.kie.workbench.common.dmn.api.property.background.BgColour) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) InputData(org.kie.workbench.common.dmn.api.definition.v1_1.InputData) DiagramMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMarshaller) BusinessKnowledgeModelConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.BusinessKnowledgeModelConverter) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) FontSet(org.kie.workbench.common.dmn.api.property.font.FontSet) Collectors(java.util.stream.Collectors) BorderColour(org.kie.workbench.common.dmn.api.property.background.BorderColour) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel) List(java.util.List) Stream(java.util.stream.Stream) DDExtensionsRegister(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DDExtensionsRegister) Entry(java.util.Map.Entry) DMNMarshallerFactory(org.kie.dmn.backend.marshalling.v1_1.DMNMarshallerFactory) Optional(java.util.Optional) DMNShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNShape) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Node(org.kie.workbench.common.stunner.core.graph.Node) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) DMNDefinitionSet(org.kie.workbench.common.dmn.api.DMNDefinitionSet) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) DefinitionsConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DefinitionsConverter) HashMap(java.util.HashMap) DiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMetadataMarshaller) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ColorUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ColorUtils) Inject(javax.inject.Inject) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Bound(org.kie.workbench.common.stunner.core.graph.content.Bounds.Bound) DRGElement(org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) StreamSupport(java.util.stream.StreamSupport) SimpleEntry(java.util.AbstractMap.SimpleEntry) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) TextAnnotation(org.kie.workbench.common.dmn.api.definition.v1_1.TextAnnotation) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) BorderSize(org.kie.workbench.common.dmn.api.property.background.BorderSize) AssociationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.AssociationConverter) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Association(org.kie.workbench.common.dmn.api.definition.v1_1.Association) BackgroundSet(org.kie.workbench.common.dmn.api.property.background.BackgroundSet) FontSetPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.FontSetPropertyConverter) InputDataConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.InputDataConverter) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Consumer(java.util.function.Consumer) KnowledgeSourceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.KnowledgeSourceConverter) Graph(org.kie.workbench.common.stunner.core.graph.Graph) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) DMNElement(org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement) InputStream(java.io.InputStream) BgColour(org.kie.workbench.common.dmn.api.property.background.BgColour) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) BorderSize(org.kie.workbench.common.dmn.api.property.background.BorderSize) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) BorderColour(org.kie.workbench.common.dmn.api.property.background.BorderColour)

Aggregations

BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)30 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)28 Edge (org.kie.workbench.common.stunner.core.graph.Edge)13 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)12 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 Node (org.kie.workbench.common.stunner.core.graph.Node)11 Test (org.junit.Test)10 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)9 Before (org.junit.Before)8 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)6 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)6 Ignore (org.junit.Ignore)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)4 Consumer (java.util.function.Consumer)3 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel)3 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)3 Command (org.kie.workbench.common.stunner.core.command.Command)3 HashMap (java.util.HashMap)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)2 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)2