Search in sources :

Example 16 with NodeImpl

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

the class ProjectDiagramImplTest method testProjectDiagramHashCode.

@Test
public void testProjectDiagramHashCode() {
    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.hashCode(), b.hashCode());
    b = new ProjectDiagramImpl("Diagram", new GraphImpl("Graph", new GraphNodeStoreImpl()), new ProjectMetadataImpl());
    assertEquals(a.hashCode(), b.hashCode());
    a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    assertEquals(a.hashCode(), b.hashCode());
    a.getGraph().addNode(new NodeImpl("Node1"));
    b.getGraph().addNode(new NodeImpl("Node2"));
    assertNotEquals(a.hashCode(), b.hashCode());
    b.getGraph().removeNode("Node2");
    b.getGraph().addNode(new NodeImpl("Node1"));
    assertEquals(a.hashCode(), b.hashCode());
    assertEquals(a.hashCode(), a.hashCode());
}
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 17 with NodeImpl

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

the class NodeFactoryImpl method build.

@Override
@SuppressWarnings("unchecked")
public Node<Definition<Object>, Edge> build(final String uuid, final Object definition) {
    final NodeImpl node = new NodeImpl<>(uuid);
    final Bounds bounds = definitionUtils.buildBounds(definition, 0d, 0d);
    View<Object> content = new ViewImpl<>(definition, bounds);
    node.setContent(content);
    addLabels(node.getLabels(), definition);
    return node;
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)

Example 18 with NodeImpl

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

the class DiagramImplTest method testDiagramHashCode.

@Test
public void testDiagramHashCode() {
    DiagramImpl a = new DiagramImpl("Diagram", new MetadataImpl());
    DiagramImpl b = new DiagramImpl("AnotherDiagram", new MetadataImpl());
    assertNotEquals(a.hashCode(), b.hashCode());
    b = new DiagramImpl("Diagram", new MetadataImpl());
    assertEquals(a.hashCode(), b.hashCode());
    a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    assertEquals(a.hashCode(), b.hashCode());
    a.getGraph().addNode(new NodeImpl("Node1"));
    b.getGraph().addNode(new NodeImpl("Node2"));
    assertNotEquals(a.hashCode(), b.hashCode());
    b.getGraph().removeNode("Node2");
    b.getGraph().addNode(new NodeImpl("Node1"));
    assertEquals(a.hashCode(), b.hashCode());
    assertEquals(a.hashCode(), a.hashCode());
}
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 19 with NodeImpl

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

the class HashCodeAndEqualityTest method testGraphEquals.

@Test
public void testGraphEquals() {
    GraphImpl<String> a = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
    GraphImpl<String> b = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
    assertEquals(a, b);
    NodeImpl<String> node = new NodeImpl<>("Node");
    a.addNode(node);
    assertNotEquals(a, b);
    b.addNode(node);
    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 20 with NodeImpl

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

the class HashCodeAndEqualityTest method testGraphHashCode.

@Test
public void testGraphHashCode() {
    GraphImpl<String> a = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
    GraphImpl<String> b = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
    assertEquals(a.hashCode(), b.hashCode());
    NodeImpl<String> node = new NodeImpl<>("Node");
    a.addNode(node);
    assertNotEquals(a.hashCode(), b.hashCode());
    b.addNode(node);
    assertEquals(a.hashCode(), b.hashCode());
    assertEquals(a.hashCode(), a.hashCode());
}
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)

Aggregations

NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)22 Test (org.junit.Test)18 Edge (org.kie.workbench.common.stunner.core.graph.Edge)9 GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)7 GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)7 Node (org.kie.workbench.common.stunner.core.graph.Node)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)4 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)4 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)4 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)4 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)4 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 RuleViolations (org.kie.workbench.common.stunner.core.rule.RuleViolations)3 Consumer (java.util.function.Consumer)2 FlowElement (org.eclipse.bpmn2.FlowElement)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 RootElement (org.eclipse.bpmn2.RootElement)2 ExclusiveGateway (org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway)2 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)2