本文整理了Java中org.kie.workbench.common.stunner.core.graph.Graph
类的一些代码示例,展示了Graph
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph
类的具体详情如下:
包路径:org.kie.workbench.common.stunner.core.graph.Graph
类名称:Graph
暂无
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
protected double getLayoutInformationThreshold(final Graph<?, ?> graph) {
final List<Node> list = new ArrayList<>();
graph.nodes().iterator().forEachRemaining(list::add);
return list.size() / 4.0D;
}
代码示例来源: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.stunner/kie-wb-common-stunner-forms-client
private Optional<String> getGraphUUID() {
if (Objects.isNull(getGraph())) {
return Optional.empty();
}
return Optional.of(getGraph().getUUID());
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Override
public void startGraphTraversal(final Graph<DefinitionSet, Node<View, Edge>> graph) {
if (graph == null) {
error("Graph is null!");
} else {
final DefinitionSet view = graph.getContent();
log(indent + "Graph UUID: " + graph.getUUID());
log(indent + " Graph Starting nodes");
log(indent + " ====================");
}
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Test
public void testBuild() {
final Graph<DefinitionSet, Node> graph = tested.build(UUID,
ID);
assertNotNull(graph);
assertEquals(UUID,
graph.getUUID());
assertEquals(1,
graph.getLabels().size());
assertTrue(graph.getLabels().contains(ID));
}
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Override
@SuppressWarnings("unchecked")
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
final CommandResult<RuleViolation> results = allow(context);
if (!results.getType().equals(CommandResult.Type.ERROR)) {
final Graph<?, Node> graph = getGraph(context);
if (hasRootUUID()) {
Iterator<Node> nodes = graph.nodes().iterator();
if (null != nodes) {
nodes.forEachRemaining(node -> {
if (!node.getUUID().equals(rootUUID)) {
getMutableIndex(context).removeNode(node);
nodes.remove();
} else {
// Clear outgoing edges for canvas root element.
node.getOutEdges().stream().forEach(edge -> getMutableIndex(context).removeEdge((Edge) edge));
node.getOutEdges().clear();
}
});
}
} else {
graph.clear();
getMutableIndex(context).clear();
}
}
return results;
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@SuppressWarnings("unchecked")
public void init() {
MockitoAnnotations.initMocks(this);
when(graph.getUUID()).thenReturn(GRAPH_UUID);
when(graph.getContent()).thenReturn(graphContent);
when(graph.nodes()).thenReturn(graphNodes);
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.registry()).thenReturn(adapterRegistry);
when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
when(adapterManager.forProperty()).thenReturn(propertyAdapter);
when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter);
when(adapterRegistry.getPropertyAdapter(any(Class.class))).thenReturn(propertyAdapter);
when(graphCommandExecutionContext.getDefinitionManager()).thenReturn(definitionManager);
when(graphCommandExecutionContext.getFactoryManager()).thenReturn(factoryManager);
when(graphCommandExecutionContext.getRuleManager()).thenReturn(ruleManager);
when(graphCommandExecutionContext.getGraphIndex()).thenReturn(graphIndex);
when(graphCommandExecutionContext.getRuleSet()).thenReturn(ruleSet);
when(graphIndex.getGraph()).thenReturn(graph);
when(ruleManager.evaluate(any(RuleSet.class),
any(RuleEvaluationContext.class))).thenReturn(EMPTY_VIOLATIONS);
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Test
@SuppressWarnings("unchecked")
public void testExecute() {
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.INFO,
result.getType());
verify(graph,
times(1)).addNode(eq(node));
verify(graphIndex,
times(1)).addNode(eq(node));
verify(graphIndex,
times(0)).addEdge(any(Edge.class));
verify(graph,
times(0)).removeNode(eq(UUID));
verify(graphIndex,
times(0)).removeNode(eq(node));
verify(graphIndex,
times(0)).removeEdge(any(Edge.class));
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-case-mgmt-backend
graph.getLabels().add("org.kie.workbench.common.stunner.cm.CaseManagementDefinitionSet");
graph.setContent(definitionSet);
graph.addNode(rootNode);
graph.addNode(stage1Node);
graph.addNode(stage2Node);
graph.addNode(task1Node);
graph.addNode(case1Node);
graph.addNode(case2Node);
graph.addNode(process2Node);
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-case-mgmt-backend
@SuppressWarnings("unchecked")
private void preMarshallProcess(final Diagram<Graph, Metadata> diagram) {
Iterable<Node<View<?>, Edge>> nodes = diagram.getGraph().nodes();
diagram.getGraph().addNode(startNoneEvent);
createChild(UUID.uuid(), rootNode, startNoneEvent, 0);
diagram.getGraph().addNode(endNoneEvent);
createChild(UUID.uuid(), rootNode, endNoneEvent, -1);
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Test
@SuppressWarnings("unchecked")
public void testExecuteCheckFailed() {
final RuleViolations FAILED_VIOLATIONS = new DefaultRuleViolations()
.addViolation(new ContainmentRuleViolation(graph.getUUID(),
UUID));
when(ruleManager.evaluate(any(RuleSet.class),
any(RuleEvaluationContext.class))).thenReturn(FAILED_VIOLATIONS);
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.ERROR,
result.getType());
verify(graph,
times(0)).addNode(eq(node));
verify(graphIndex,
times(0)).addNode(eq(node));
verify(graphIndex,
times(0)).addEdge(any(Edge.class));
verify(graph,
times(0)).removeNode(eq(UUID));
verify(graphIndex,
times(0)).removeNode(eq(node));
verify(graphIndex,
times(0)).removeEdge(any(Edge.class));
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-case-mgmt-backend
@SuppressWarnings("unchecked")
private void postUnmarshallProcess(final Graph<DefinitionSet, Node> graph) {
List<Node<View<?>, Edge>> nodes = StreamSupport.stream(graph.nodes().spliterator(), false)
.map(n -> (Node<View<?>, Edge>) n).collect(Collectors.toList());
if (StartNoneEvent.class.isInstance(startNode.getContent().getDefinition())) {
deleteChild(root, startNode);
graph.removeNode(startNode.getUUID());
if (EndNoneEvent.class.isInstance(endNode.getContent().getDefinition())) {
deleteChild(root, endNode);
graph.removeNode(endNode.getUUID());
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@SuppressWarnings("unchecked")
protected void doStartGraphTraversal(final Graph graph,
final K callback) {
if (graph.getContent() instanceof View) {
callback.startGraphTraversal(graph);
}
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Override
@SuppressWarnings("unchecked")
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
final CommandResult<RuleViolation> results = allow(context);
if (!results.getType().equals(CommandResult.Type.ERROR)) {
final Graph graph = getGraph(context);
graph.addNode(candidate);
getMutableIndex(context).addNode(candidate);
}
return results;
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-backend-common
when(graph.getContent()).thenReturn(graphContent);
when(graphContent.getDefinition()).thenReturn(DEFINITION_SET);
when(graph.getNode(DIAGRAM_UUID)).thenReturn(graphNode);
when(graphNode.getContent()).thenReturn(graphContent);
when(metadata.getCanvasRootUUID()).thenReturn(DIAGRAM_UUID);
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
CommandResult<RuleViolation> results = allow(context);
if (!results.getType().equals(CommandResult.Type.ERROR)) {
LOGGER.log(Level.FINE,
"Executing...");
final org.kie.workbench.common.stunner.core.graph.Graph graph = getGraph(context);
final Node<?, Edge> candidate = getCandidate(context);
this.removed = candidate;
graph.removeNode(candidate.getUUID());
getMutableIndex(context).removeNode(candidate);
LOGGER.log(Level.FINE,
"Node [" + uuid + " removed from strcture and index.");
}
return results;
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-client-common
protected void destroyGraph(final Command callback) {
destroyGraphIndex(() -> {
if (null != diagram && null != diagram.getGraph()) {
diagram.getGraph().clear();
}
callback.execute();
});
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Test
@SuppressWarnings("unchecked")
public void testUndo() {
tested.removed = node;
CommandResult<RuleViolation> result = tested.undo(graphCommandExecutionContext);
assertEquals(CommandResult.Type.INFO,
result.getType());
verify(graph,
times(1)).addNode(any(Node.class));
verify(graphIndex,
times(1)).addNode(any(Node.class));
verify(graph,
times(0)).removeNode(eq(UUID));
verify(graphIndex,
times(0)).removeNode(eq(node));
verify(graphIndex,
times(0)).removeEdge(any(Edge.class));
verify(graphIndex,
times(0)).addEdge(any(Edge.class));
}
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-case-mgmt-backend
graph.getLabels().add("org.kie.workbench.common.stunner.cm.CaseManagementDefinitionSet");
graph.setContent(definitionSet);
graph.addNode(rootNode);
graph.addNode(stageNode);
graph.addNode(subprocessNode);
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
@Override
public void startGraphTraversal(final Graph graph) {
if (graph.getContent() instanceof DefinitionSet) {
callback.startGraphTraversal(graph);
}
}
内容来源于网络,如有侵权,请联系作者删除!