io.github.leheyue.magicapi.nebula.model.NebulaModel Maven / Gradle / Ivy
package io.github.leheyue.magicapi.nebula.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.ssssssss.script.annotation.Comment;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 经过加工后的nebula数据结构, 用于前端数据展示
* 目前很多前端组件库支持这种数据, 并可视化展示, 如ntV G6等
* @see AntV G6
*/
public class NebulaModel {
@JsonIgnore
private List nodeIds = new ArrayList<>();
/**
* 包含的节点集合
*/
@Comment("包含的节点集合")
private List nodes = new ArrayList<>();
/**
* 包含的边集合
*/
@Comment("包含的边集合")
private List edges = new ArrayList<>();
public List getNodeIds() {
return nodeIds;
}
public void setNodeIds(List nodeIds) {
this.nodeIds = nodeIds;
}
public List getNodes() {
return nodes;
}
public void setNodes(List nodes) {
this.nodes = nodes;
}
public List getEdges() {
return edges;
}
public void setEdges(List edges) {
this.edges = edges;
}
/**
* 添加节点, 根据id去重
* @param node
*/
@Comment("添加节点, 根据id去重")
public void addNode(Node node) {
String nodeId = Objects.toString(node.getId(), null);
if (nodeIds.contains(nodeId)) {
return;
}
nodeIds.add(nodeId);
nodes.add(node);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy