Skip to content

Commit e70e3a9

Browse files
committed
Correction to only show the visible graph
1 parent dafa574 commit e70e3a9

File tree

5 files changed

+39
-38
lines changed

5 files changed

+39
-38
lines changed

modules/engine-core/src/main/java/org/gephi/viz/engine/structure/GraphIndex.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* @author Eduardo Ramos
1010
*/
1111
public interface GraphIndex {
12-
13-
Graph getGraph();
12+
13+
Graph getVisibleGraph();
1414

1515
int getNodeCount();
1616

modules/engine-core/src/main/java/org/gephi/viz/engine/structure/GraphIndexImpl.java

+34-33
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,22 @@ public GraphIndexImpl(VizEngine engine) {
2626

2727
//Graph
2828
private GraphModel graphModel;
29-
private Graph graph;
3029
private float edgesMinWeight = 1;
3130
private float edgesMaxWeight = 1;
3231

3332
private void init() {
3433
graphModel = engine.getGraphModel();
35-
graph = graphModel.getGraphVisible();
3634
}
3735

3836
private void ensureInitialized() {
39-
if (graph == null) {
37+
if (graphModel == null) {
4038
init();
4139
}
4240
}
4341

44-
@Override
45-
public Graph getGraph() {
42+
public Graph getVisibleGraph() {
4643
ensureInitialized();
47-
return graph;
44+
return graphModel.getGraphVisible();
4845
}
4946

5047
public void indexNodes() {
@@ -54,28 +51,29 @@ public void indexNodes() {
5451
public void indexEdges() {
5552
ensureInitialized();
5653

57-
if (graph.getEdgeCount() > 0) {
58-
final Column weightColumn = graph.getModel().getEdgeTable().getColumn(GraphStoreConfiguration.EDGE_WEIGHT_INDEX);
54+
final Graph visibleGraph = getVisibleGraph();
55+
if (visibleGraph.getEdgeCount() > 0) {
56+
final Column weightColumn = visibleGraph.getModel().getEdgeTable().getColumn(GraphStoreConfiguration.EDGE_WEIGHT_INDEX);
5957

6058
if (weightColumn.isIndexed() && AttributeUtils.isSimpleType(weightColumn.getTypeClass())) {
61-
graph.readLock();
59+
visibleGraph.readLock();
6260
try {
63-
edgesMinWeight = graph.getModel().getEdgeIndex().getMinValue(weightColumn).floatValue();
64-
edgesMaxWeight = graph.getModel().getEdgeIndex().getMaxValue(weightColumn).floatValue();
61+
edgesMinWeight = visibleGraph.getModel().getEdgeIndex().getMinValue(weightColumn).floatValue();
62+
edgesMaxWeight = visibleGraph.getModel().getEdgeIndex().getMaxValue(weightColumn).floatValue();
6563
} finally {
66-
graph.readUnlockAll();
64+
visibleGraph.readUnlockAll();
6765
}
6866
} else {
69-
graph.readLock();
67+
visibleGraph.readLock();
7068
try {
71-
final GraphView graphView = graph.getView();
69+
final GraphView graphView = visibleGraph.getView();
7270
final boolean isView = !graphView.isMainView();
7371

7472
if (!isView) {
7573
float minWeight = Float.MAX_VALUE;
7674
float maxWeight = Float.MIN_VALUE;
7775

78-
for (Edge edge : graph.getEdges()) {
76+
for (Edge edge : visibleGraph.getEdges()) {
7977
float weight = (float) edge.getWeight(graphView);
8078
minWeight = weight <= minWeight ? weight : minWeight;
8179
maxWeight = weight >= maxWeight ? weight : maxWeight;
@@ -85,7 +83,7 @@ public void indexEdges() {
8583
edgesMaxWeight = maxWeight;
8684
}
8785
} finally {
88-
graph.readUnlockAll();
86+
visibleGraph.readUnlockAll();
8987
}
9088
}
9189
} else {
@@ -97,14 +95,14 @@ public void indexEdges() {
9795
public int getNodeCount() {
9896
ensureInitialized();
9997

100-
return graph.getNodeCount();
98+
return getVisibleGraph().getNodeCount();
10199
}
102100

103101
@Override
104102
public int getEdgeCount() {
105103
ensureInitialized();
106104

107-
return graph.getEdgeCount();
105+
return getVisibleGraph().getEdgeCount();
108106
}
109107

110108
@Override
@@ -121,16 +119,17 @@ public float getEdgesMaxWeight() {
121119
public NodeIterable getVisibleNodes() {
122120
ensureInitialized();
123121

124-
return graphModel.getSpatialIndex().getNodesInArea(engine.getViewBoundaries());
122+
return getVisibleGraph().getSpatialIndex().getNodesInArea(engine.getViewBoundaries());
125123
}
126124

127125
@Override
128126
public void getVisibleNodes(ElementsCallback<Node> callback) {
129127
ensureInitialized();
130128

131-
callback.start(graph);
129+
final Graph visibleGraph = getVisibleGraph();
130+
callback.start(visibleGraph);
132131

133-
final NodeIterable nodeIterable = graphModel.getSpatialIndex().getNodesInArea(engine.getViewBoundaries());
132+
final NodeIterable nodeIterable = visibleGraph.getSpatialIndex().getNodesInArea(engine.getViewBoundaries());
134133
try {
135134
for (Node node : nodeIterable) {
136135
callback.accept(node);
@@ -139,22 +138,23 @@ public void getVisibleNodes(ElementsCallback<Node> callback) {
139138
nodeIterable.doBreak();
140139
}
141140

142-
callback.end(graph);
141+
callback.end(visibleGraph);
143142
}
144143

145144
@Override
146145
public EdgeIterable getVisibleEdges() {
147146
ensureInitialized();
148147

149-
return graphModel.getSpatialIndex().getEdgesInArea(engine.getViewBoundaries());
148+
return getVisibleGraph().getSpatialIndex().getEdgesInArea(engine.getViewBoundaries());
150149
}
151150

152151
@Override
153152
public void getVisibleEdges(ElementsCallback<Edge> callback) {
154153
ensureInitialized();
155154

156-
callback.start(graph);
157-
final EdgeIterable edgeIterable = graphModel.getSpatialIndex().getEdgesInArea(engine.getViewBoundaries());
155+
final Graph visibleGraph = getVisibleGraph();
156+
callback.start(visibleGraph);
157+
final EdgeIterable edgeIterable = visibleGraph.getSpatialIndex().getEdgesInArea(engine.getViewBoundaries());
158158
try {
159159
for (Edge edge : edgeIterable) {
160160
callback.accept(edge);
@@ -163,14 +163,14 @@ public void getVisibleEdges(ElementsCallback<Edge> callback) {
163163
edgeIterable.doBreak();
164164
}
165165

166-
callback.end(graph);
166+
callback.end(visibleGraph);
167167
}
168168

169169
@Override
170170
public NodeIterable getNodesUnderPosition(float x, float y) {
171171
ensureInitialized();
172172

173-
return filterNodeIterable(graphModel.getSpatialIndex().getNodesInArea(getCircleRect2D(x, y, 0)), node -> {
173+
return filterNodeIterable(getVisibleGraph().getSpatialIndex().getNodesInArea(getCircleRect2D(x, y, 0)), node -> {
174174
final float size = node.size();
175175

176176
return Intersectionf.testPointCircle(x, y, node.x(), node.y(), size * size);
@@ -181,7 +181,7 @@ public NodeIterable getNodesUnderPosition(float x, float y) {
181181
public NodeIterable getNodesInsideCircle(float centerX, float centerY, float radius) {
182182
ensureInitialized();
183183

184-
return filterNodeIterable(graphModel.getSpatialIndex().getNodesInArea(getCircleRect2D(centerX, centerY, radius)), node -> {
184+
return filterNodeIterable(getVisibleGraph().getSpatialIndex().getNodesInArea(getCircleRect2D(centerX, centerY, radius)), node -> {
185185
return Intersectionf.testCircleCircle(centerX, centerY, radius, node.x(), node.y(), node.size());
186186
});
187187
}
@@ -190,7 +190,7 @@ public NodeIterable getNodesInsideCircle(float centerX, float centerY, float rad
190190
public NodeIterable getNodesInsideRectangle(Rect2D rect) {
191191
ensureInitialized();
192192

193-
return filterNodeIterable(graphModel.getSpatialIndex().getNodesInArea(rect), node -> {
193+
return filterNodeIterable(getVisibleGraph().getSpatialIndex().getNodesInArea(rect), node -> {
194194
final float size = node.size();
195195

196196
return Intersectionf.testAarCircle(rect.minX, rect.minY, rect.maxX, rect.maxY, node.x(), node.y(), size * size);
@@ -201,7 +201,7 @@ public NodeIterable getNodesInsideRectangle(Rect2D rect) {
201201
public EdgeIterable getEdgesInsideRectangle(Rect2D rect) {
202202
ensureInitialized();
203203

204-
return filterEdgeIterable(graphModel.getSpatialIndex().getEdgesInArea(rect), edge -> {
204+
return filterEdgeIterable(getVisibleGraph().getSpatialIndex().getEdgesInArea(rect), edge -> {
205205
final Node source = edge.getSource();
206206
final Node target = edge.getTarget();
207207

@@ -214,7 +214,7 @@ public EdgeIterable getEdgesInsideRectangle(Rect2D rect) {
214214
public EdgeIterable getEdgesInsideCircle(float centerX, float centerY, float radius) {
215215
ensureInitialized();
216216

217-
return filterEdgeIterable(graphModel.getSpatialIndex().getEdgesInArea(getCircleRect2D(centerX, centerY, radius)), edge -> {
217+
return filterEdgeIterable(getVisibleGraph().getSpatialIndex().getEdgesInArea(getCircleRect2D(centerX, centerY, radius)), edge -> {
218218
final Node source = edge.getSource();
219219
final Node target = edge.getTarget();
220220

@@ -232,13 +232,14 @@ public EdgeIterable getEdgesInsideCircle(float centerX, float centerY, float rad
232232
public Rect2D getGraphBoundaries() {
233233
ensureInitialized();
234234

235-
if (graph.getNodeCount() > 0) {
235+
final Graph visibleGraph = getVisibleGraph();
236+
if (visibleGraph.getNodeCount() > 0) {
236237
float minX = Float.MAX_VALUE;
237238
float maxX = Float.MIN_VALUE;
238239
float minY = Float.MAX_VALUE;
239240
float maxY = Float.MIN_VALUE;
240241

241-
for (Node node : graph.getNodes()) {
242+
for (Node node : visibleGraph.getNodes()) {
242243
final float x = node.x();
243244
final float y = node.y();
244245
final float size = node.size();

modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/arrays/ArrayDrawEdgeData.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt
240240
final Edge[] visibleEdgesArray = edgesCallback.getEdgesArray();
241241
final int visibleEdgesCount = edgesCallback.getCount();
242242

243-
final Graph graph = graphIndex.getGraph();
243+
final Graph graph = graphIndex.getVisibleGraph();
244244

245245
int attribsIndex = 0;
246246
attribsIndex = updateUndirectedData(

modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/instanced/InstancedEdgeData.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt
179179
final Edge[] visibleEdgesArray = edgesCallback.getEdgesArray();
180180
final int visibleEdgesCount = edgesCallback.getCount();
181181

182-
final Graph graph = graphIndex.getGraph();
182+
final Graph graph = graphIndex.getVisibleGraph();
183183

184184
updateUndirectedData(
185185
graph,

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<maven.compiler.target>1.8</maven.compiler.target>
1515
<jcp-maven-plugin.version>7.1.2</jcp-maven-plugin.version>
1616

17-
<gephi.graphstore.version>0.7.1</gephi.graphstore.version>
17+
<gephi.graphstore.version>0.7.2-SNAPSHOT</gephi.graphstore.version>
1818
<gephi.version>0.11.0-SNAPSHOT</gephi.version>
1919
<jogl.version>2.5.0</jogl.version>
2020

0 commit comments

Comments
 (0)