[Arakhnę-Dev] [428] * Add intersection functions for PointEvent classes.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 428
Author:   galland
Date:     2013-04-27 14:57:42 +0200 (Sat, 27 Apr 2013)
Log Message:
-----------
* Add intersection functions for PointEvent classes.

Modified Paths:
--------------
    trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/event/PointerEventAndroid.java
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/event/PointerEvent.java
    trunk/ui/ui-swing/src/main/java/org/arakhne/afc/ui/swing/event/PointerEventSwing.java

Modified: trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/event/PointerEventAndroid.java
===================================================================
--- trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/event/PointerEventAndroid.java	2013-04-27 12:56:49 UTC (rev 427)
+++ trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/event/PointerEventAndroid.java	2013-04-27 12:57:42 UTC (rev 428)
@@ -222,4 +222,14 @@
 		return true;
 	}
 	
+	@Override
+	public boolean intersects(Shape2f s) {
+		for(int i=0; i<getPointerCount(); ++i) {
+			if (s.intersects(getToolArea(i).getPathIterator())) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
 }

Modified: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/event/PointerEvent.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/event/PointerEvent.java	2013-04-27 12:56:49 UTC (rev 427)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/event/PointerEvent.java	2013-04-27 12:57:42 UTC (rev 428)
@@ -151,6 +151,16 @@
 	 */
 	public ToolType getToolType(int pointerIndex);
 
+	/** Replies if the pointer tool area is intersecting
+	 * the given shape.
+	 * 
+	 * @param s is the shape to test
+	 * @return <code>true</code> if the pointer area intersect
+	 * the given shape; <code>false</code> otherwise.
+	 * @see #getToolArea(int)
+	 * @see #inside(Shape2f)
+	 */
+	public boolean intersects(Shape2f s);
 	
 	/** Types of tools.
 	 *

Modified: trunk/ui/ui-swing/src/main/java/org/arakhne/afc/ui/swing/event/PointerEventSwing.java
===================================================================
--- trunk/ui/ui-swing/src/main/java/org/arakhne/afc/ui/swing/event/PointerEventSwing.java	2013-04-27 12:56:49 UTC (rev 427)
+++ trunk/ui/ui-swing/src/main/java/org/arakhne/afc/ui/swing/event/PointerEventSwing.java	2013-04-27 12:57:42 UTC (rev 428)
@@ -3,7 +3,7 @@
  * 
  * Copyright (C) 2002 Stephane GALLAND, Madhi HANNOUN, Marc BAUMGARTNER.
  * Copyright (C) 2005-10 Stephane GALLAND.
- * Copyright (C) 2012 Stephane GALLAND.
+ * Copyright (C) 2012-13 Stephane GALLAND.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -142,7 +142,7 @@
 	}
 
 	@Override
-	public Shape2f getToolArea(int pointerIndex) {
+	public Circle2f getToolArea(int pointerIndex) {
 		// Replies a circle with 1 pixel of radius
 		return new Circle2f(
 				this.event.getX(),
@@ -160,4 +160,14 @@
 		return false;
 	}
 	
+	@Override
+	public boolean intersects(Shape2f s) {
+		for(int i=0; i<getPointerCount(); ++i) {
+			if (s.intersects(getToolArea(i))) {
+				return true;
+			}
+		}
+		return false;
+	}
+
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/