use of org.gephi.visualization.model.edge.EdgeModel in project gephi by gephi.
the class CompatibilityEngine method display.
@Override
public void display(GL2 gl, GLU glu) {
markTime++;
VizModel vizModel = VizController.getInstance().getVizModel();
//Edges
if (edgeModeler.isEnabled()) {
edgeModeler.beforeDisplay(gl, glu);
for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
EdgeModel obj = itr.next();
if (obj.markTime != markTime) {
obj.display(gl, glu, vizModel);
obj.markTime = markTime;
}
}
edgeModeler.afterDisplay(gl, glu);
}
markTime++;
//Arrows
if (edgeModeler.isEnabled() && vizConfig.isShowArrows() && dataBridge.isDirected()) {
gl.glBegin(GL2.GL_TRIANGLES);
for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
EdgeModel obj = itr.next();
if (obj.getEdge().isDirected() && obj.markTime != markTime) {
obj.displayArrow(gl, glu, vizModel);
obj.markTime = markTime;
}
}
gl.glEnd();
}
//Nodes
if (nodeModeler.isEnabled()) {
nodeModeler.beforeDisplay(gl, glu);
for (Iterator<NodeModel> itr = octree.getNodeIterator(); itr.hasNext(); ) {
NodeModel obj = itr.next();
if (obj.markTime != markTime) {
obj.display(gl, glu, vizModel);
obj.markTime = markTime;
}
}
nodeModeler.afterDisplay(gl, glu);
}
//Labels
if (vizModel.getTextModel().isShowNodeLabels() || vizModel.getTextModel().isShowEdgeLabels()) {
markTime++;
if (nodeModeler.isEnabled() && vizModel.getTextModel().isShowNodeLabels()) {
textManager.getNodeRenderer().beginRendering();
textManager.defaultNodeColor();
if (textManager.isSelectedOnly()) {
for (Iterator<NodeModel> itr = octree.getNodeIterator(); itr.hasNext(); ) {
NodeModel obj = itr.next();
if (obj.markTime != markTime) {
if (obj.isSelected() && obj.isTextVisible()) {
textManager.getNodeRenderer().drawTextNode(obj);
}
obj.markTime = markTime;
}
}
} else {
for (Iterator<NodeModel> itr = octree.getNodeIterator(); itr.hasNext(); ) {
NodeModel obj = itr.next();
if (obj.markTime != markTime) {
if (obj.isTextVisible()) {
textManager.getNodeRenderer().drawTextNode(obj);
}
obj.markTime = markTime;
}
}
}
textManager.getNodeRenderer().endRendering();
}
// }
if (edgeModeler.isEnabled() && vizModel.getTextModel().isShowEdgeLabels()) {
markTime++;
textManager.getEdgeRenderer().beginRendering();
textManager.defaultEdgeColor();
if (textManager.isSelectedOnly()) {
for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
EdgeModel obj = itr.next();
if (obj.markTime != markTime) {
if ((obj.isSelected() || obj.isAutoSelected()) && obj.isTextVisible()) {
textManager.getEdgeRenderer().drawTextEdge(obj);
}
obj.markTime = markTime;
}
}
} else {
for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
EdgeModel obj = itr.next();
if (obj.markTime != markTime) {
if (obj.isTextVisible()) {
textManager.getEdgeRenderer().drawTextEdge(obj);
}
obj.markTime = markTime;
}
}
}
textManager.getEdgeRenderer().endRendering();
}
}
// octree.displayOctree(gl, glu);
}
use of org.gephi.visualization.model.edge.EdgeModel in project gephi by gephi.
the class DataBridge method updateWorld.
public synchronized boolean updateWorld() {
boolean force = false;
if (graphModel != null) {
graphModel.getGraph().writeLock();
}
try {
if ((observer != null && observer.isDestroyed()) || (graphModel != null && graph.getView() != graphModel.getVisibleView())) {
if (observer != null && !observer.isDestroyed()) {
observer.destroy();
}
observer = null;
if (graphModel != null) {
graph = graphModel.getGraphVisible();
observer = graphModel.createGraphObserver(graph, false);
force = true;
}
}
} finally {
if (graphModel != null) {
graphModel.getGraph().readUnlockAll();
graphModel.getGraph().writeUnlock();
}
}
if (force || (observer != null && (observer.isNew() || observer.hasGraphChanged())) || hasColumnsChanged()) {
if (observer.isNew()) {
observer.hasGraphChanged();
}
NodeModeler nodeModeler = engine.getNodeModeler();
EdgeModeler edgeModeler = engine.getEdgeModeler();
Octree octree = engine.getOctree();
//Stats
int removedNodes = 0;
int addedNodes = 0;
int removedEdges = 0;
int addedEdges = 0;
graph.readLock();
try {
boolean isView = !graph.getView().isMainView();
for (int i = 0; i < nodes.length; i++) {
NodeModel node = nodes[i];
if (node != null && (node.getNode().getStoreId() == -1 || (isView && !graph.contains(node.getNode())))) {
//Removed
octree.removeNode(node);
nodes[i] = null;
removedNodes++;
}
}
for (Node node : graph.getNodes()) {
int id = node.getStoreId();
NodeModel model;
if (id >= nodes.length || nodes[id] == null) {
growNodes(id);
model = nodeModeler.initModel(node);
octree.addNode(model);
nodes[id] = model;
addedNodes++;
} else {
model = nodes[id];
}
textManager.refreshNode(graph, model, textModel);
}
for (int i = 0; i < edges.length; i++) {
EdgeModel edge = edges[i];
if (edge != null && (edge.getEdge().getStoreId() == -1 || (isView && !graph.contains(edge.getEdge())))) {
//Removed
int sourceId = edge.getEdge().getSource().getStoreId();
int targetId = edge.getEdge().getTarget().getStoreId();
NodeModel sourceModel = sourceId == -1 ? null : nodes[sourceId];
NodeModel targetModel = targetId == -1 ? null : nodes[targetId];
if (sourceModel != null) {
sourceModel.removeEdge(edge);
}
if (targetModel != null && sourceModel != targetModel) {
targetModel.removeEdge(edge);
}
edges[i] = null;
removedEdges++;
}
}
float minWeight = Float.MAX_VALUE;
float maxWeight = Float.MIN_VALUE;
for (Edge edge : graph.getEdges()) {
int id = edge.getStoreId();
EdgeModel model;
if (id >= edges.length || edges[id] == null) {
growEdges(id);
NodeModel sourceModel = nodes[edge.getSource().getStoreId()];
NodeModel targetModel = nodes[edge.getTarget().getStoreId()];
model = edgeModeler.initModel(edge, sourceModel, targetModel);
sourceModel.addEdge(model);
if (targetModel != sourceModel) {
targetModel.addEdge(model);
}
edges[id] = model;
addedEdges++;
} else {
model = edges[id];
}
float w = (float) edge.getWeight(graph.getView());
model.setWeight(w);
minWeight = Math.min(w, minWeight);
maxWeight = Math.max(w, maxWeight);
textManager.refreshEdge(graph, model, textModel);
}
if (!isView) {
limits.setMaxWeight(maxWeight);
limits.setMinWeight(minWeight);
}
} finally {
graph.readUnlockAll();
}
return true;
} else if (observer == null) {
Octree octree = engine.getOctree();
if (!octree.isEmpty()) {
octree.clear();
}
}
return false;
}
Aggregations