Search in sources :

Example 1 with GraphImpl

use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl in project kie-wb-common by kiegroup.

the class ProjectDiagramImplTest method testProjectDiagramEquals.

@Test
public void testProjectDiagramEquals() {
    ProjectDiagramImpl a = new ProjectDiagramImpl("Diagram", new GraphImpl("Graph", new GraphNodeStoreImpl()), new ProjectMetadataImpl());
    ProjectDiagramImpl b = new ProjectDiagramImpl("AnotherDiagram", new GraphImpl("Graph", new GraphNodeStoreImpl()), new ProjectMetadataImpl());
    assertNotEquals(a, b);
    b = new ProjectDiagramImpl("Diagram", new GraphImpl("Graph", new GraphNodeStoreImpl()), new ProjectMetadataImpl());
    assertEquals(a, b);
    a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    assertEquals(a, b);
    a.getGraph().addNode(new NodeImpl("Node1"));
    b.getGraph().addNode(new NodeImpl("Node2"));
    assertNotEquals(a, b);
    b.getGraph().removeNode("Node2");
    b.getGraph().addNode(new NodeImpl("Node1"));
    assertEquals(a, b);
    assertEquals(a, a);
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Test(org.junit.Test)

Example 2 with GraphImpl

use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl in project kie-wb-common by kiegroup.

the class DiagramImplTest method testDiagramEquals.

@Test
public void testDiagramEquals() {
    DiagramImpl a = new DiagramImpl("Diagram", new MetadataImpl());
    DiagramImpl b = new DiagramImpl("AnotherDiagram", new MetadataImpl());
    assertNotEquals(a, b);
    b = new DiagramImpl("Diagram", new MetadataImpl());
    assertEquals(a, b);
    a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    assertNotEquals(a, b);
    b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    assertEquals(a, b);
    a.getGraph().addNode(new NodeImpl("Node1"));
    b.getGraph().addNode(new NodeImpl("Node2"));
    assertNotEquals(a, b);
    b.getGraph().removeNode("Node2");
    b.getGraph().addNode(new NodeImpl("Node1"));
    assertEquals(a, b);
    assertEquals(a, a);
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Test(org.junit.Test)

Example 3 with GraphImpl

use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl in project kie-wb-common by kiegroup.

the class AbstractGraphFactory method build.

@Override
@SuppressWarnings("unchecked   ")
public Graph<DefinitionSet, Node> build(final String uuid, final String definitionSetId) {
    final GraphImpl graph = new GraphImpl<>(uuid, new GraphNodeStoreImpl());
    final DefinitionSet content = new DefinitionSetImpl(definitionSetId);
    graph.setContent(content);
    graph.getLabels().add(definitionSetId);
    content.setBounds(new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(getWidth(), getHeight())));
    return graph;
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) DefinitionSetImpl(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSetImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)

Example 4 with GraphImpl

use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl in project kie-wb-common by kiegroup.

the class SessionPreviewImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.preview = new SessionPreviewImpl(definitionManager, shapeManager, textPropertyProviderFactory, canvasCommandManager, definitionUtils, graphUtils, canvasHandlerFactories, canvasCommandFactories, selectionControl, view);
    final DiagramImpl diagram = new DiagramImpl("diagram", new MetadataImpl());
    final GraphImpl graph = new GraphImpl("graph", new GraphNodeStoreImpl());
    final DefinitionSetImpl definitionSet = new DefinitionSetImpl("id");
    diagram.setGraph(graph);
    graph.setContent(definitionSet);
    definitionSet.setBounds(new BoundsImpl(new BoundImpl(0.0, 0.0), new BoundImpl(100.0, 100.0)));
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(session.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(shapeManager.getCanvasFactory(any(Diagram.class))).thenReturn(canvasFactory);
    when(canvasFactory.newCanvas()).thenReturn(canvas);
    when(canvasFactory.newControl(eq(ZoomControl.class))).thenReturn(zoomControl);
    when(canvasHandlerFactories.select(any(Annotation.class))).thenReturn(canvasHandlerFactories);
    when(canvasHandlerFactories.get()).thenReturn(canvasHandler);
    when(canvas.getView()).thenReturn(canvasView);
    preview.open(session, callback);
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) ZoomControl(org.kie.workbench.common.stunner.core.client.canvas.controls.zoom.ZoomControl) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) DefinitionSetImpl(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSetImpl) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Annotation(java.lang.annotation.Annotation) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Before(org.junit.Before)

Example 5 with GraphImpl

use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl in project kie-wb-common by kiegroup.

the class CaseManagementUtilsTest method checkGetFirstDiagramNodeWithEmptyGraph.

@Test
public void checkGetFirstDiagramNodeWithEmptyGraph() {
    final Graph graph = new GraphImpl<>("uuid", new GraphNodeStoreImpl());
    final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementUtils.getFirstDiagramNode(graph);
    assertNull(fNode);
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) Graph(org.kie.workbench.common.stunner.core.graph.Graph) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Aggregations

GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)10 GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)10 Test (org.junit.Test)8 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)7 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)2 DefinitionSetImpl (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSetImpl)2 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)2 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)2 Annotation (java.lang.annotation.Annotation)1 Before (org.junit.Before)1 CaseManagementDiagram (org.kie.workbench.common.stunner.cm.definition.CaseManagementDiagram)1 ZoomControl (org.kie.workbench.common.stunner.core.client.canvas.controls.zoom.ZoomControl)1 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 DiagramImpl (org.kie.workbench.common.stunner.core.diagram.DiagramImpl)1 MetadataImpl (org.kie.workbench.common.stunner.core.diagram.MetadataImpl)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)1