Skip to content

Commit 765c724

Browse files
committed
Fix selection rendering
1 parent 80a486f commit 765c724

File tree

10 files changed

+84
-84
lines changed

10 files changed

+84
-84
lines changed

modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelection.java

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ enum GraphSelectionMode {
1616
SIMPLE_MOUSE_SELECTION,
1717
RECTANGLE_SELECTION
1818
}
19+
20+
boolean someNodesOrEdgesSelection();
21+
1922
boolean isNodeSelected(Node node);
2023

2124
int getSelectedNodesCount();

modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelectionImpl.java

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public GraphSelectionImpl() {
2020
this.selectionMode = GraphSelectionMode.SIMPLE_MOUSE_SELECTION;
2121
}
2222

23+
@Override
24+
public boolean someNodesOrEdgesSelection() {
25+
return !nodes.isEmpty() || !edges.isEmpty();
26+
}
27+
2328
@Override
2429
public boolean isNodeSelected(Node node) {
2530
return nodes.contains(node);

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt
221221
graphIndex.indexEdges();
222222

223223
//Selection:
224-
final boolean someEdgesSelection = graphSelection.getSelectedEdgesCount() > 0;
225-
final boolean someNodesSelection = graphSelection.getSelectedNodesCount() > 0;
224+
final boolean someSelection = graphSelection.someNodesOrEdgesSelection();
226225
final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor();
227-
final boolean hideNonSelected = someEdgesSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1);
226+
final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1);
228227
final boolean edgeSelectionColor = renderingOptions.isEdgeSelectionColor();
229228
final float edgeBothSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeBothSelectionColor().getRGB());
230229
final float edgeInSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeInSelectionColor().getRGB());
@@ -246,13 +245,13 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt
246245
int attribsIndex = 0;
247246
attribsIndex = updateUndirectedData(
248247
graph,
249-
someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray,
250-
graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
248+
someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray,
249+
graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
251250
attribs, attribsIndex
252251
);
253252
updateDirectedData(
254-
graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray,
255-
graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
253+
graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray,
254+
graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
256255
attribs, attribsIndex
257256
);
258257
}

modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractEdgeData.java

+26-26
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected int setupShaderProgramForRenderingLayerUndirected(final GL2ES2 gl,
8585
final RenderingLayer layer,
8686
final VizEngine engine,
8787
final float[] mvpFloats) {
88-
final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedEdgesCount() > 0;
88+
final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection();
8989
final boolean renderingUnselectedEdges = layer.isBack();
9090
if (!someSelection && renderingUnselectedEdges) {
9191
return 0;
@@ -133,7 +133,7 @@ protected int setupShaderProgramForRenderingLayerUndirected(final GL2ES2 gl,
133133
);
134134

135135
if (someSelection) {
136-
if (someNodesSelection && edgeSelectionColor) {
136+
if (someSelection && edgeSelectionColor) {
137137
lineModelUndirected.useProgram(
138138
gl,
139139
mvpFloats,
@@ -175,7 +175,7 @@ protected int setupShaderProgramForRenderingLayerDirected(final GL2ES2 gl,
175175
final RenderingLayer layer,
176176
final VizEngine engine,
177177
final float[] mvpFloats) {
178-
final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedEdgesCount() > 0;
178+
final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection();
179179
final boolean renderingUnselectedEdges = layer.isBack();
180180
if (!someSelection && renderingUnselectedEdges) {
181181
return 0;
@@ -222,7 +222,7 @@ protected int setupShaderProgramForRenderingLayerDirected(final GL2ES2 gl,
222222
);
223223

224224
if (someSelection) {
225-
if (someNodesSelection && edgeSelectionColor) {
225+
if (someSelection && edgeSelectionColor) {
226226
lineModelDirected.useProgram(
227227
gl,
228228
mvpFloats,
@@ -262,15 +262,15 @@ protected int setupShaderProgramForRenderingLayerDirected(final GL2ES2 gl,
262262

263263
protected int updateDirectedData(
264264
final Graph graph,
265-
final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
265+
final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
266266
final float[] attribs, int index
267267
) {
268-
return updateDirectedData(graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null);
268+
return updateDirectedData(graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null);
269269
}
270270

271271
protected int updateDirectedData(
272272
final Graph graph,
273-
final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
273+
final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
274274
final float[] attribs, int index, final FloatBuffer directBuffer
275275
) {
276276
checkBufferIndexing(directBuffer, attribs, index);
@@ -281,11 +281,11 @@ protected int updateDirectedData(
281281
return index;
282282
}
283283

284-
saveSelectionState(someNodesSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor);
284+
saveSelectionState(this.someSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor);
285285

286286
int newEdgesCountUnselected = 0;
287287
int newEdgesCountSelected = 0;
288-
if (someEdgesSelection) {
288+
if (someSelection) {
289289
if (hideNonSelected) {
290290
for (int j = 0; j < visibleEdgesCount; j++) {
291291
final Edge edge = visibleEdgesArray[j];
@@ -387,15 +387,15 @@ protected int updateDirectedData(
387387

388388
protected int updateUndirectedData(
389389
final Graph graph,
390-
final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
390+
final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
391391
final float[] attribs, int index
392392
) {
393-
return updateUndirectedData(graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null);
393+
return updateUndirectedData(graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null);
394394
}
395395

396396
protected int updateUndirectedData(
397397
final Graph graph,
398-
final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
398+
final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor,
399399
final float[] attribs, int index, final FloatBuffer directBuffer
400400
) {
401401
checkBufferIndexing(directBuffer, attribs, index);
@@ -406,12 +406,12 @@ protected int updateUndirectedData(
406406
return index;
407407
}
408408

409-
saveSelectionState(someNodesSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor);
409+
saveSelectionState(someSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor);
410410

411411
int newEdgesCountUnselected = 0;
412412
int newEdgesCountSelected = 0;
413413
//Undirected edges:
414-
if (someEdgesSelection) {
414+
if (someSelection) {
415415
if (hideNonSelected) {
416416
for (int j = 0; j < visibleEdgesCount; j++) {
417417
final Edge edge = visibleEdgesArray[j];
@@ -522,20 +522,20 @@ private void checkBufferIndexing(final FloatBuffer directBuffer, final float[] a
522522
}
523523
}
524524

525-
private boolean someNodesSelection;
525+
private boolean someSelection;
526526
private boolean edgeSelectionColor;
527527
private GraphSelection graphSelection;
528528
private float edgeBothSelectionColor;
529529
private float edgeOutSelectionColor;
530530
private float edgeInSelectionColor;
531531

532-
private void saveSelectionState(final boolean someNodesSelection1, final boolean edgeSelectionColor1, final GraphSelection graphSelection1, final float edgeBothSelectionColor1, final float edgeOutSelectionColor1, final float edgeInSelectionColor1) {
533-
this.someNodesSelection = someNodesSelection1;
534-
this.edgeSelectionColor = edgeSelectionColor1;
535-
this.graphSelection = graphSelection1;
536-
this.edgeBothSelectionColor = edgeBothSelectionColor1;
537-
this.edgeOutSelectionColor = edgeOutSelectionColor1;
538-
this.edgeInSelectionColor = edgeInSelectionColor1;
532+
private void saveSelectionState(final boolean someSelection, final boolean edgeSelectionColor, final GraphSelection graphSelection, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor) {
533+
this.someSelection = someSelection;
534+
this.edgeSelectionColor = edgeSelectionColor;
535+
this.graphSelection = graphSelection;
536+
this.edgeBothSelectionColor = edgeBothSelectionColor;
537+
this.edgeOutSelectionColor = edgeOutSelectionColor;
538+
this.edgeInSelectionColor = edgeInSelectionColor;
539539
}
540540

541541
protected void fillUndirectedEdgeAttributesDataBase(final float[] buffer, final Edge edge, final int index) {
@@ -579,7 +579,7 @@ protected void fillUndirectedEdgeAttributesDataWithSelection(final float[] buffe
579579

580580
//Color:
581581
if (selected) {
582-
if (someNodesSelection && edgeSelectionColor) {
582+
if (someSelection && edgeSelectionColor) {
583583
boolean sourceSelected = graphSelection.isNodeSelected(source);
584584
boolean targetSelected = graphSelection.isNodeSelected(target);
585585

@@ -593,7 +593,7 @@ protected void fillUndirectedEdgeAttributesDataWithSelection(final float[] buffe
593593
buffer[index + 7] = Float.intBitsToFloat(edge.getRGBA());//Color
594594
}
595595
} else {
596-
if (someNodesSelection && edge.alpha() <= 0) {
596+
if (someSelection && edge.alpha() <= 0) {
597597
if (graphSelection.isNodeSelected(source)) {
598598
buffer[index + 7] = Float.intBitsToFloat(target.getRGBA());//Color
599599
} else {
@@ -650,7 +650,7 @@ protected void fillDirectedEdgeAttributesDataWithSelection(final float[] buffer,
650650

651651
//Color:
652652
if (selected) {
653-
if (someNodesSelection && edgeSelectionColor) {
653+
if (someSelection && edgeSelectionColor) {
654654
boolean sourceSelected = graphSelection.isNodeSelected(source);
655655
boolean targetSelected = graphSelection.isNodeSelected(target);
656656

@@ -664,7 +664,7 @@ protected void fillDirectedEdgeAttributesDataWithSelection(final float[] buffer,
664664
buffer[index + 6] = Float.intBitsToFloat(edge.getRGBA());//Color
665665
}
666666
} else {
667-
if (someNodesSelection && edge.alpha() <= 0) {
667+
if (someSelection && edge.alpha() <= 0) {
668668
if (graphSelection.isNodeSelected(source)) {
669669
buffer[index + 6] = Float.intBitsToFloat(target.getRGBA());//Color
670670
} else {

modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractNodeData.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected int setupShaderProgramForRenderingLayer(final GL2ES2 gl,
161161
final VizEngine engine,
162162
final float[] mvpFloats,
163163
final boolean isRenderingOutsideCircle) {
164-
final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedNodesCount() > 0;
164+
final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection();
165165
final boolean renderingUnselectedNodes = layer.isBack();
166166
if (!someSelection && renderingUnselectedNodes) {
167167
return 0;
@@ -222,7 +222,7 @@ protected void updateData(final float zoom,
222222
spatialIndex.indexNodes();
223223

224224
//Selection:
225-
final boolean someSelection = selection.getSelectedNodesCount() > 0;
225+
final boolean someSelection = selection.someNodesOrEdgesSelection();
226226
final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor();
227227
final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1);
228228

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,9 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt
160160
graphIndex.indexEdges();
161161

162162
//Selection:
163-
final boolean someEdgesSelection = graphSelection.getSelectedEdgesCount() > 0;
164-
final boolean someNodesSelection = graphSelection.getSelectedNodesCount() > 0;
163+
final boolean someSelection = graphSelection.someNodesOrEdgesSelection();
165164
final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor();
166-
final boolean hideNonSelected = someEdgesSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1);
165+
final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1);
167166
final boolean edgeSelectionColor = renderingOptions.isEdgeSelectionColor();
168167
final float edgeBothSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeBothSelectionColor().getRGB());
169168
final float edgeInSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeInSelectionColor().getRGB());
@@ -184,12 +183,12 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt
184183

185184
updateUndirectedData(
186185
graph,
187-
someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
186+
someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
188187
attributesBufferBatch, 0, attribsDirectBuffer
189188
);
190189
updateDirectedData(
191190
graph,
192-
someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
191+
someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor,
193192
attributesBufferBatch, 0, attribsDirectBuffer
194193
);
195194
}

0 commit comments

Comments
 (0)