summaryrefslogtreecommitdiffstats
path: root/src/graphui
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-19 08:06:01 +0100
committerSven Gothel <[email protected]>2023-03-19 08:06:01 +0100
commit32f7a476770d0a4ef853eab8f3c78a7ea801a180 (patch)
tree577b07fe2abe26b1bab31fb2f89ec568880ff5ed /src/graphui
parenta81fff28e9380ebce877d974d402ef613b5ea850 (diff)
Graph Shape: Add onMove(Shape.Listener), allowing user to track Shape movement
Diffstat (limited to 'src/graphui')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
index 56ba928d7..626e25beb 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
@@ -69,6 +69,9 @@ import com.jogamp.opengl.util.PMVMatrix;
* @see Scene
*/
public abstract class Shape {
+ public static interface Listener {
+ void run(final Shape shape);
+ }
public static final boolean DRAW_DEBUG_BOX = false;
private static final boolean DEBUG = false;
@@ -114,6 +117,8 @@ public abstract class Shape {
private boolean enabled = true;
private ArrayList<MouseGestureListener> mouseListeners = new ArrayList<MouseGestureListener>();
+ private Listener onMoveListener = null;
+
public Shape(final Factory<? extends Vertex> factory, final int renderModes) {
this.vertexFactory = factory;
this.renderModes = renderModes;
@@ -174,17 +179,25 @@ public abstract class Shape {
markShapeDirty();
}
+ public final void onMove(final Listener l) { onMoveListener = l; }
+
public final void moveTo(final float tx, final float ty, final float tz) {
position[0] = tx;
position[1] = ty;
position[2] = tz;
- // System.err.println("UIShape.setTranslate: "+tx+"/"+ty+"/"+tz+": "+toString());
+ if( null != onMoveListener ) {
+ onMoveListener.run(this);
+ }
+ // System.err.println("Shape.setTranslate: "+tx+"/"+ty+"/"+tz+": "+toString());
}
public final void move(final float tx, final float ty, final float tz) {
position[0] += tx;
position[1] += ty;
position[2] += tz;
- // System.err.println("UIShape.translate: "+tx+"/"+ty+"/"+tz+": "+toString());
+ if( null != onMoveListener ) {
+ onMoveListener.run(this);
+ }
+ // System.err.println("Shape.translate: "+tx+"/"+ty+"/"+tz+": "+toString());
}
/** Returns float[3] position, i.e. translation. */