org.kie.workbench.common.stunner.core.diagram.Diagram.getGraph()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.kie.workbench.common.stunner.core.diagram.Diagram.getGraph()方法的一些代码示例,展示了Diagram.getGraph()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Diagram.getGraph()方法的具体详情如下:
包路径:org.kie.workbench.common.stunner.core.diagram.Diagram
类名称:Diagram
方法名:getGraph

Diagram.getGraph介绍

暂无

代码示例

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-backend-common

@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
  String result = ServerMarshalling.toJSON(diagram.getGraph());
  return result;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-client

private Node getSourceNode(Diagram diagram, String edgeUuid) {
  final Iterator<Node> nodes = diagram.getGraph().nodes().iterator();
  Node<?, ? extends Edge> sourceNode;
  while (nodes.hasNext()) {
    sourceNode = nodes.next();
    if (sourceNode.getOutEdges().stream()
        .anyMatch(edge -> edge.getUUID().equals(edgeUuid))) {
      return sourceNode;
    }
  }
  return null;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-client

protected void onFormFieldChanged(@Observes FormFieldChanged formFieldChanged) {
  Optional.ofNullable(isSelected)
      .map(Supplier::get)
      .filter(Boolean.TRUE::equals)
      .map(focus -> getDiagram()
          .map(d -> d.getGraph().getNode(formFieldChanged.getUuid()))
      ).ifPresent(focus -> refresh());
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client

@SuppressWarnings("unchecked")
String diagramUUID() {
  final Diagram diagram = decisionNavigatorPresenter.getDiagram();
  final Graph<?, Node> graph = diagram.getGraph();
  return StreamSupport.stream(graph.nodes().spliterator(), false)
      .filter(n -> n.getContent() instanceof Definition)
      .filter(n -> ((Definition) n.getContent()).getDefinition() instanceof DMNDiagram)
      .findFirst()
      .map(Node::getUUID)
      .orElse("");
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-client-common

public static Node getSelectedNode(Diagram diagram, ClientSession clientSession) {
    String uuid = getSelectedElementUUID(clientSession);
    return uuid != null ? diagram.getGraph().getNode(uuid) : null;
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-forms-client

@Override
public void deregister(final Element element) {
  if (null != renderer) {
    renderer.clear(getDiagram().getGraph().getUUID(), element);
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

private Node<? extends Definition, ?> getNodebyId(Diagram<Graph, Metadata> diagram, String id) {
  Node<? extends Definition, ?> node = diagram.getGraph().getNode(id);
  assertThat(node).isNotNull();
  return node;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-forms-client

@Override
public void clear() {
  if (null != renderer) {
    renderer.clearAll(getDiagram().getGraph().getUUID());
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-backend-common

private void domainValidation(Diagram diagram, Consumer<DiagramElementViolation<RuleViolation>> callback) {
    StreamSupport.stream(validators.spliterator(), false)
        .filter(validator -> Objects.equals(validator.getDefinitionSetId(), diagram.getMetadata().getDefinitionSetId()))
        .findFirst()
        .ifPresent(validator -> validator.validate(diagram, domainViolations ->
            callback.accept(new ElementViolationImpl.Builder()
                        .setUuid(diagram.getGraph().getUUID())
                        .setDomainViolations(domainViolations)
                        .build())));
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

private List<Node> getNodes(Diagram<Graph, Metadata> diagram) {
  Graph graph = diagram.getGraph();
  assertNotNull(graph);
  Iterator<Node> nodesIterable = graph.nodes().iterator();
  List<Node> nodes = new ArrayList<>();
  nodesIterable.forEachRemaining(nodes::add);
  return nodes;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

public static List<Node> getNodes(Diagram<Graph, Metadata> diagram) {
  Graph graph = diagram.getGraph();
  assertNotNull(graph);
  Iterator<Node> nodesIterable = graph.nodes().iterator();
  List<Node> nodes = new ArrayList<>();
  nodesIterable.forEachRemaining(nodes::add);
  return nodes;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@SuppressWarnings("unchecked")
T getGatewayNodeById(Diagram<Graph, Metadata> diagram, String id, Class<T> type) {
  Node<? extends Definition, ?> node = diagram.getGraph().getNode(id);
  assertThat(node).isNotNull();
  return type.cast(node.getContent().getDefinition());
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-backend-common

@Before
public void setUp() {
  when(validators.spliterator()).thenReturn(Arrays.asList(domainValidator).spliterator());
  when(domainValidator.getDefinitionSetId()).thenReturn(DEF_SET_ID);
  when(diagram.getMetadata()).thenReturn(metadata);
  when(metadata.getDefinitionSetId()).thenReturn(DEF_SET_ID);
  when(diagram.getGraph()).thenReturn(graph);
  when(graph.getUUID()).thenReturn(GRAPH_UUID);
  when(domainViolation.getViolationType()).thenReturn(Violation.Type.ERROR);
  validationService = new ValidationServiceImpl(validators);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-client-common

@SuppressWarnings("unchecked")
public Node<View<?>, Edge> getParent(final double _x,
                   final double _y) {
  if (_x > -1 && _y > -1) {
    final String rootUUID = canvasHandler.getDiagram().getMetadata().getCanvasRootUUID();
    graphBoundsIndexer.setRootUUID(rootUUID).build(canvasHandler.getDiagram().getGraph());
    final Node<View<?>, Edge> r = graphBoundsIndexer.getAt(_x,
                                _y);
    return r;
  }
  return null;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@SuppressWarnings("unchecked")
T getStartNodeById(Diagram<Graph, Metadata> diagram, String id, Class<T> type) {
  Node<? extends Definition, ?> node = diagram.getGraph().getNode(id);
  assertNotNull(node);
  assertEquals(1, node.getOutEdges().size());
  return type.cast(node.getContent().getDefinition());
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-client

@Override
protected FormGroup getFormGroup(RenderMode renderMode) {
  DefaultFormGroup formGroup = formGroupsInstance.get();
  view.init(this);
  final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram();
  path = diagram.getMetadata().getPath();
  graph = diagram.getGraph();
  formGroup.render(view.asWidget(), field);
  return formGroup;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@SuppressWarnings("unchecked")
T getTaskNodeById(Diagram<Graph, Metadata> diagram, String id, int amountOfIncomeEdges, boolean hasOutcomeEdge) {
  Node<? extends Definition, ?> node = diagram.getGraph().getNode(id);
  assertNotNull(node);
  assertEquals(amountOfIncomeEdges + 1, node.getInEdges().size());
  int outcomeEdges = hasOutcomeEdge ? 1 : 0;
  assertEquals(outcomeEdges, node.getOutEdges().size());
  return getTaskType().cast(node.getContent().getDefinition());
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-case-mgmt-backend

@Test
public void testUpdateTitle() throws Exception {
  final String name = "mockName";
  final Diagram mockDiagram = mockDiagram(name, null);
  final Metadata metadata = new MetadataImpl();
  marshaller.updateTitle(metadata, mockDiagram.getGraph());
  assertEquals(metadata.getTitle(), name);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallBasic() throws Exception {
  Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BASIC);
  assertDiagram(diagram,
         4);
  assertEquals("Basic process",
         diagram.getMetadata().getTitle());
  Node<? extends Definition, ?> task1 = diagram.getGraph().getNode("810797AB-7D09-4E1F-8A5B-96C424E4B031");
  assertTrue(task1.getContent().getDefinition() instanceof NoneTask);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@Test
  public void testBasicBidi() throws Exception {
    Diagram<Graph, Metadata> d = unmarshall(newMarshaller, BPMN_SERVICE_TASK_PROPERTIES_FILE_PATH);
    String marshall = newMarshaller.marshall(d);
    Diagram<Graph, Metadata> d2 = Unmarshalling.unmarshall(newMarshaller, new StringInputStream(marshall));

    Node<View<ServiceTask>, ?> node = d2.getGraph().getNode(SERVICE_TASK_ID);
    ServiceTask definition = node.getContent().getDefinition();
    assertEquals("Custom Email", definition.getGeneral().getName().getValue());
    assertEquals("This is an email task", definition.getGeneral().getDocumentation().getValue());
  }
}

相关文章