Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit e994395

Browse files
committed
Add single node selection support
1 parent c3b6c83 commit e994395

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
*/
1313
public interface GraphSelection {
1414

15-
enum GraphSelectionMode {
15+
enum GraphSelectionMode {
1616
SIMPLE_MOUSE_SELECTION,
17-
RECTANGLE_SELECTION, NO_SELECTION, CUSTOM_SELECTION
17+
SINGLE_NODE_SELECTION,
18+
RECTANGLE_SELECTION,
19+
NO_SELECTION,
20+
CUSTOM_SELECTION
1821
}
1922

2023
boolean someNodesOrEdgesSelection();

modules/opengl-commons/src/main/java/org/gephi/viz/engine/util/actions/InputActionsProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void clearSelection() {
4949

5050
public void selectNodes(final NodeIterable nodesIterable) {
5151
final GraphSelection selection = engine.getLookup().lookup(GraphSelection.class);
52+
GraphSelection.GraphSelectionMode mode = selection.getMode();
5253
final GraphRenderingOptions renderingOptions = engine.getLookup().lookup(GraphRenderingOptions.class);
5354
final Graph graph = engine.getGraphModel().getGraphVisible();
5455

@@ -57,7 +58,7 @@ public void selectNodes(final NodeIterable nodesIterable) {
5758
final Set<Node> selectionNeighbours = new HashSet<>();
5859
final Set<Edge> selectionEdges = new HashSet<>();
5960

60-
final boolean selectNeighbours = renderingOptions.isAutoSelectNeighbours();
61+
final boolean selectNeighbours = renderingOptions.isAutoSelectNeighbours() && mode != GraphSelection.GraphSelectionMode.SINGLE_NODE_SELECTION;
6162
try {
6263
while (iterator.hasNext()) {
6364
final Node node = iterator.next();

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void frameStart() {
4545
public void frameEnd() {
4646
if (lastMovedPosition != null) {
4747
//TODO: move to independent selection input listener
48-
if (graphSelection.getMode() == GraphSelection.GraphSelectionMode.SIMPLE_MOUSE_SELECTION) {
48+
if (graphSelection.getMode() == GraphSelection.GraphSelectionMode.SIMPLE_MOUSE_SELECTION || graphSelection.getMode() == GraphSelection.GraphSelectionMode.SINGLE_NODE_SELECTION) {
4949
final Vector2f worldCoords = engine.screenCoordinatesToWorldCoordinates(lastMovedPosition.getX(), lastMovedPosition.getY());
5050
inputActionsProcessor.selectNodesUnderPosition(worldCoords);
5151
}
@@ -105,6 +105,8 @@ public boolean mouseClicked(MouseEvent e) {
105105
} else if (graphSelection.getMode() == GraphSelection.GraphSelectionMode.SIMPLE_MOUSE_SELECTION && leftClick) {
106106
//TODO: move to independent selection input listener
107107
return true;
108+
} else if (graphSelection.getMode() == GraphSelection.GraphSelectionMode.SINGLE_NODE_SELECTION && leftClick) {
109+
return true;
108110
} else if (graphSelection.getMode() == GraphSelection.GraphSelectionMode.RECTANGLE_SELECTION) {
109111
inputActionsProcessor.clearSelection();
110112
return true;

0 commit comments

Comments
 (0)