本文整理了Java中org.kie.workbench.common.stunner.core.graph.Graph.nodes()
方法的一些代码示例,展示了Graph.nodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.nodes()
方法的具体详情如下:
包路径:org.kie.workbench.common.stunner.core.graph.Graph
类名称:Graph
方法名:nodes
暂无
代码示例来源: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-core-common
@SuppressWarnings("unchecked")
private List<Node<?, Edge>> getStartingNodes() {
final Iterable<Node> nodes = graph.nodes();
final List<Node<?, Edge>> result = new LinkedList<>();
nodes.forEach(n -> {
if (isStartingNode(n)) {
result.add(n);
}
});
return result;
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
public static int countDefinitionsById(final DefinitionManager definitionManager,
final Graph<?, ? extends Node> target,
final String id) {
final int[] count = {0};
target.nodes().forEach(node -> {
if (getElementDefinitionId(definitionManager,
node).equals(id)) {
count[0]++;
}
});
return count[0];
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-client
@SuppressWarnings("unchecked")
public static Collection<VariableUsage> findVariableUsages(Graph graph, String variableName) {
if (StringUtils.isEmpty(variableName)) {
return Collections.EMPTY_LIST;
}
Iterable<Node> nodes = graph.nodes();
return StreamSupport.stream(nodes.spliterator(), false)
.filter(VariableUtils::isBPMNDefinition)
.map(node -> (Node<View<BPMNDefinition>, Edge>) node)
.map(node -> findVariableUsages(variableName, node))
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend
public DefinitionsContextHelper(Graph<DefinitionSet, NodeT> graph,
Class<?> nodeType) {
this.firstNode =
GraphUtils.getFirstNode((Graph) graph, nodeType);
this.nodes =
StreamSupport
.stream(graph.nodes().spliterator(), false)
.filter(n -> !firstNode.getUUID().equals(n.getUUID()))
.collect(Collectors.toMap(Node::getUUID, Function.identity()));
}
代码示例来源: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/kie-wb-common-dmn-client
@SuppressWarnings("unchecked")
private static <T extends DMNModelInstrumentedBase> List<String> getExistingNodeNames(final Graph<?, Node> graph,
final T dmnModel,
final Function<T, String> nameExtractor) {
return StreamSupport
.stream(graph.nodes().spliterator(), false)
.filter(node -> node.getContent() instanceof View)
.map(node -> (View) node.getContent())
.filter(view -> view.getDefinition() instanceof DMNModelInstrumentedBase)
.map(view -> (T) view.getDefinition())
.filter(dmn -> dmn.getClass().equals(dmnModel.getClass()))
.map(nameExtractor::apply)
.collect(Collectors.toList());
}
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-client
protected Collection<Pair<Object, String>> findElements(final Predicate<Node> filter,
final Function<Node, Pair<Object, String>> mapper) {
final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram();
@SuppressWarnings("unchecked")
Iterable<Node> it = diagram.getGraph().nodes();
return StreamSupport.stream(it.spliterator(),
false)
.filter(filter)
.map(mapper)
.filter(pair -> pair != null)
.collect(Collectors.toSet());
}
}
代码示例来源: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/kie-wb-common-dmn-client
@SuppressWarnings("unchecked")
private Optional<Node> findDomainObjectNodeByDomainObject(final DomainObject domainObject) {
return getCanvasHandler()
.map(canvasHandler -> {
final Graph<?, Node> graph = canvasHandler.getDiagram().getGraph();
return StreamSupport
.stream(graph.nodes().spliterator(), false)
.filter(node -> node.getContent() instanceof Definition)
.filter(node -> Objects.equals(domainObject, ((Definition) node.getContent()).getDefinition()))
.findFirst();
})
.orElse(Optional.empty());
}
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend
@SuppressWarnings("unchecked")
private Iterator<Element> nodesIterator(Diagram<Graph, Metadata> diagram) {
return (Iterator<Element>) diagram.getGraph().nodes().iterator();
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend
@SuppressWarnings("unchecked")
private Iterator<Element> nodesIterator(Diagram<Graph, Metadata> diagram) {
return (Iterator<Element>) diagram.getGraph().nodes().iterator();
}
代码示例来源: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
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
@SuppressWarnings("unchecked")
protected 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
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-widgets
@Test
@SuppressWarnings("unchecked")
public void testShowWithSingleNodeWithNoNameAndWithNoTitle() {
when(graph.nodes()).thenReturn(getMockNodes("node1"));
testedTree.show(canvasHandler);
verify(childrenTraverseProcessor,
times(1)).traverse(eq(graph),
any(AbstractChildrenTraverseCallback.class));
verify(view).addItem(eq("node1"),
eq(TreeExplorer.NO_NAME),
any(IsWidget.class),
anyBoolean(),
anyBoolean());
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-project
@Before
public void setup() throws Exception {
diagram = new BPMNDiagram.BPMNDiagramBuilder().build();
diagramNodeContent = new ViewImpl<BPMNDiagram>( diagram, bounds );
graphNodes.add( diagramNode );
when( diagramNode.getContent() ).thenReturn( diagramNodeContent );
when( graph.nodes() ).thenReturn( graphNodes );
tested = new BPMNProjectDiagramFactory();
}
代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-api
@Test
@SuppressWarnings("unchecked")
public void testModelName() {
final Diagram<Graph, Metadata> diagram = factory.build(NAME, metadata, graph);
//We can safely get the first object on the iterator as we know the graph only contains one node
final Node<View, Edge> root = (Node<View, Edge>) diagram.getGraph().nodes().iterator().next();
final DMNDiagram dmnDiagram = (DMNDiagram) root.getContent().getDefinition();
final Definitions dmnDefinitions = dmnDiagram.getDefinitions();
assertEquals(NAME, dmnDefinitions.getName().getValue());
}
代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-api
@Test
@SuppressWarnings("unchecked")
public void testModelNameWithNonEmptyExistingName() {
final Node<View, Edge> existingRoot = (Node<View, Edge>) graph.nodes().iterator().next();
final DMNDiagram existingDMNDiagram = (DMNDiagram) existingRoot.getContent().getDefinition();
final Definitions existingDMNDefinitions = existingDMNDiagram.getDefinitions();
existingDMNDefinitions.getName().setValue(EXISTING_NAME);
final Diagram<Graph, Metadata> newDiagram = factory.build(NAME, metadata, graph);
final Node<View, Edge> newRoot = (Node<View, Edge>) newDiagram.getGraph().nodes().iterator().next();
final DMNDiagram newDMNDiagram = (DMNDiagram) newRoot.getContent().getDefinition();
final Definitions newDMNDefinitions = newDMNDiagram.getDefinitions();
assertEquals(EXISTING_NAME, newDMNDefinitions.getName().getValue());
}
}
内容来源于网络,如有侵权,请联系作者删除!