[Arakhnę-Dev] [421] * Fixing bugs in the behavior of the graphical components, based on the real deployment on an Android device.

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


Revision: 421
Author:   galland
Date:     2013-04-09 15:32:56 +0200 (Tue, 09 Apr 2013)
Log Message:
-----------
* Fixing bugs in the behavior of the graphical components, based on the real deployment on an Android device.

Modified Paths:
--------------
    trunk/ui/ui-awt/src/main/java/org/arakhne/afc/ui/awt/ZoomableAwtContextUtil.java
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/CenteringTransform.java
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/ZoomableContextUtil.java
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionMode.java
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManager.java
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManagerOwner.java
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/SelectableInteractionEvent.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
    trunk/ui/ui-vector-awt/src/main/java/org/arakhne/afc/ui/vector/awt/AwtVectorToolkit.java

Added Paths:
-----------
    trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionPointerEvent.java

Modified: trunk/ui/ui-awt/src/main/java/org/arakhne/afc/ui/awt/ZoomableAwtContextUtil.java
===================================================================
--- trunk/ui/ui-awt/src/main/java/org/arakhne/afc/ui/awt/ZoomableAwtContextUtil.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-awt/src/main/java/org/arakhne/afc/ui/awt/ZoomableAwtContextUtil.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -44,7 +44,7 @@
 /** Utilities for ZoomableContext with additional functions
  * dedicated to AWT objects.
  *
- * @author $Author: sgalland$
+ * @author $Author: galland$
  * @version $FullVersion$
  * @mavengroupid $GroupId$
  * @mavenartifactid $ArtifactId$

Modified: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/CenteringTransform.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/CenteringTransform.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/CenteringTransform.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -27,7 +27,7 @@
 /** This feature describes all the parameters that must
  * be used to center logical points on the screen view. 
  *
- * @author $Author: sgalland$
+ * @author $Author: galland$
  * @version $FullVersion$
  * @mavengroupid $GroupId$
  * @mavenartifactid $ArtifactId$

Modified: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/ZoomableContextUtil.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/ZoomableContextUtil.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/ZoomableContextUtil.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -36,7 +36,7 @@
 
 /** Utilities for ZoomableContext.
 *
-* @author $Author: sgalland$
+* @author $Author: galland$
 * @version $FullVersion$
 * @mavengroupid $GroupId$
 * @mavenartifactid $ArtifactId$
@@ -531,7 +531,7 @@
 	
 	/** Pixel-to-logical translator for path iterator.
 	*
-	* @author $Author: sgalland$
+	* @author $Author: galland$
 	* @version $FullVersion$
 	* @mavengroupid $GroupId$
 	* @mavenartifactid $ArtifactId$
@@ -585,7 +585,7 @@
 	
 	/** Logical-to-pixel translator for path iterator.
 	*
-	* @author $Author: sgalland$
+	* @author $Author: galland$
 	* @version $FullVersion$
 	* @mavengroupid $GroupId$
 	* @mavenartifactid $ArtifactId$

Modified: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionMode.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionMode.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionMode.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -26,8 +26,8 @@
 
 import org.arakhne.afc.math.continous.object2d.Rectangle2f;
 import org.arakhne.afc.ui.MouseCursor;
+import org.arakhne.afc.ui.ZoomableContext;
 import org.arakhne.afc.ui.event.KeyEvent;
-import org.arakhne.afc.ui.event.PointerEvent;
 import org.arakhne.afc.ui.selection.Selectable;
 import org.arakhne.vmutil.locale.Locale;
 
@@ -287,6 +287,22 @@
 		return getModeManager().isPointerInFigureShape();
 	}
 	
+	/** Replies the precision of a click in the logical coordinate space.
+	 * <p>
+	 * This function is an helper to access to the click precision
+	 * of the action mode owner, and to translate it to the logical
+	 * coordinate space.
+	 * @return the click precision.
+	 */
+	protected float getClickPrecision() {
+		float prec = getModeManagerOwner().getClickPrecision();
+		ZoomableContext zc = getModeManagerOwner().getZoomableContext();
+		if (zc!=null) {
+			prec = zc.pixel2logical_size(prec);
+		}
+		return prec;
+	}
+	
 	/** Delegate the execution to the specified mode.
 	 * 
 	 * @param delegation is the type of the mode to create and delegate to.
@@ -330,7 +346,7 @@
 	 * 
 	 * @param event
 	 */
-	protected void forcePointerEvent(PointerEvent event) {
+	protected void forcePointerEvent(ActionPointerEvent event) {
 		getModeManager().updatePointerInfo(event, true);
 	}
 	
@@ -388,9 +404,9 @@
      * is applied to be sure that the POINTER_CLICKED event is handled.
      * 
      * @param e
-     * @see #pointerLongClicked(PointerEvent)
+     * @see #pointerLongClicked(ActionPointerEvent)
      */
-    public void pointerClicked(PointerEvent e) {
+    public void pointerClicked(ActionPointerEvent e) {
     	//
     }
 
@@ -405,7 +421,7 @@
      * @param e
      * @see #pointerClicked(PointerEvent)
      */
-    public void pointerLongClicked(PointerEvent e) {
+    public void pointerLongClicked(ActionPointerEvent e) {
     	//
     }
 
@@ -418,7 +434,7 @@
      * 
      * @param e
      */
-    public void pointerPressed(PointerEvent e) {
+    public void pointerPressed(ActionPointerEvent e) {
     	//
     }
 
@@ -431,7 +447,7 @@
      * 
      * @param e
      */
-    public void pointerReleased(PointerEvent e) {
+    public void pointerReleased(ActionPointerEvent e) {
     	//
     }
 
@@ -444,7 +460,7 @@
      * 
      * @param e
      */
-    public void pointerDragged(PointerEvent e) {
+    public void pointerDragged(ActionPointerEvent e) {
     	//
     }
 
@@ -457,7 +473,7 @@
      * 
      * @param e
      */
-    public void pointerMoved(PointerEvent e) {
+    public void pointerMoved(ActionPointerEvent e) {
     	//
     }
 

Modified: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManager.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManager.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManager.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -31,9 +31,6 @@
 import java.util.List;
 import java.util.UUID;
 
-import org.arakhne.afc.math.continous.object2d.Point2f;
-import org.arakhne.afc.math.continous.object2d.Shape2f;
-import org.arakhne.afc.math.generic.Point2D;
 import org.arakhne.afc.ui.ZoomableContext;
 import org.arakhne.afc.ui.event.KeyEvent;
 import org.arakhne.afc.ui.event.PointerEvent;
@@ -73,13 +70,11 @@
 	private boolean isFigureUnderTheMouseComputed = false;
 	private WeakReference<DRAW> figureUnderTheMouse = null;
 	
-	private boolean isForceHitResetWhenRelease = false;
+	private boolean isForceHitResetWhenRelease = true;
 	
-	private float mouseX = Float.NaN;
-	private float mouseY = Float.NaN;
-	private Shape2f mouseArea = null;
-	
 	private final ListenerCollection<EventListener> listeners = new ListenerCollection<EventListener>();
+	
+	private ActionPointerEvent lastPointerEvent = null;
 
 	/**  Construct a ModeManager with no modes.
 	 *
@@ -207,8 +202,8 @@
 	 * @param figure is the figure on which the action was performed.
 	 * @param pointerEvent is the event causing the action performing.
 	 */
-	public void fireActionPerformed(Collection<? extends DRAW> figure, PointerEvent pointerEvent) {
-		SelectableInteractionEvent event = new SelectableInteractionEvent(this, figure, pointerEvent, getMousePosition(),
+	public void fireActionPerformed(Collection<? extends DRAW> figure, ActionPointerEvent pointerEvent) {
+		SelectableInteractionEvent event = new SelectableInteractionEvent(this, figure, pointerEvent,
 				getModeManagerOwner().isEditable());
 		if (figure instanceof SelectableInteractionListener)
 			((SelectableInteractionListener)figure).actionPerformed(event);
@@ -239,9 +234,9 @@
 	 * @param figure is the figure on which the action was performed. It may be
 	 * <code>null</code> if the popup action was performed on the background.
 	 */
-	public void firePopupPerformed(PointerEvent pointerEvent, DRAW figure) {
+	public void firePopupPerformed(ActionPointerEvent pointerEvent, DRAW figure) {
 		SelectableInteractionEvent event = new SelectableInteractionEvent(this,
-				Collections.singleton(figure), pointerEvent, getMousePosition(),
+				Collections.singleton(figure), pointerEvent,
 				getModeManagerOwner().isEditable());
 		if (figure instanceof SelectableInteractionListener)
 			((SelectableInteractionListener)figure).popupPerformed(event);
@@ -432,6 +427,7 @@
      * @param e
      */
     public void keyTyped(KeyEvent e) {
+    	this.lastPointerEvent = null;
 		if (this.exclusiveMode!=null) {
 			this.exclusiveMode.keyTyped(e);
 		}
@@ -453,6 +449,7 @@
      * @param e
      */
     public void keyPressed(KeyEvent e) {
+    	this.lastPointerEvent = null;
 		if (this.exclusiveMode!=null) {
 			this.exclusiveMode.keyPressed(e);
 		}
@@ -474,6 +471,7 @@
      * @param e
      */
     public void keyReleased(KeyEvent e) {
+    	this.lastPointerEvent = null;
 		if (this.exclusiveMode!=null) {
 			this.exclusiveMode.keyReleased(e);
 		}
@@ -497,13 +495,13 @@
     public void pointerClicked(PointerEvent e) {
 		updatePointerInfo(e, false);
 		if (this.exclusiveMode!=null) {
-			this.exclusiveMode.pointerClicked(e);
+			this.exclusiveMode.pointerClicked(this.lastPointerEvent);
 		}
 		else {
 			Iterator<ActionMode<? super DRAW,CANVAS,COLOR>> iterator = this.modeStack.descendingIterator();
 			while (iterator.hasNext()) {
 				ActionMode<? super DRAW,CANVAS,COLOR> m = iterator.next();
-				m.pointerClicked(e);
+				m.pointerClicked(this.lastPointerEvent);
 				if (e.isConsumed()) return;
 			}
 		}
@@ -519,13 +517,13 @@
     public void pointerLongClicked(PointerEvent e) {
     	updatePointerInfo(e, false);
 		if (this.exclusiveMode!=null) {
-			this.exclusiveMode.pointerLongClicked(e);
+			this.exclusiveMode.pointerLongClicked(this.lastPointerEvent);
 		}
 		else {
 			Iterator<ActionMode<? super DRAW,CANVAS,COLOR>> iterator = this.modeStack.descendingIterator();
 			while (iterator.hasNext()) {
 				ActionMode<? super DRAW,CANVAS,COLOR> m = iterator.next();
-				m.pointerLongClicked(e);
+				m.pointerLongClicked(this.lastPointerEvent);
 				if (e.isConsumed()) return;
 			}
 		}
@@ -543,13 +541,13 @@
     	}
 		updatePointerInfo(e, false);
 		if (this.exclusiveMode!=null) {
-			this.exclusiveMode.pointerPressed(e);
+			this.exclusiveMode.pointerPressed(this.lastPointerEvent);
 		}
 		else {
 			Iterator<ActionMode<? super DRAW,CANVAS,COLOR>> iterator = this.modeStack.descendingIterator();
 			while (iterator.hasNext()) {
 				ActionMode<? super DRAW,CANVAS,COLOR> m = iterator.next();
-				m.pointerPressed(e);
+				m.pointerPressed(this.lastPointerEvent);
 				if (e.isConsumed()) return;
 			}
 		}
@@ -563,13 +561,13 @@
     public void pointerReleased(PointerEvent e) {
 		updatePointerInfo(e, false);
 		if (this.exclusiveMode!=null) {
-			this.exclusiveMode.pointerReleased(e);
+			this.exclusiveMode.pointerReleased(this.lastPointerEvent);
 		}
 		else {
 			Iterator<ActionMode<? super DRAW,CANVAS,COLOR>> iterator = this.modeStack.descendingIterator();
 			while (iterator.hasNext()) {
 				ActionMode<? super DRAW,CANVAS,COLOR> m = iterator.next();
-				m.pointerReleased(e);
+				m.pointerReleased(this.lastPointerEvent);
 				if (e.isConsumed()) return;
 			}
 		}
@@ -615,13 +613,13 @@
     public void pointerDragged(PointerEvent e) {
 		updatePointerInfo(e, true);
 		if (this.exclusiveMode!=null) {
-			this.exclusiveMode.pointerDragged(e);
+			this.exclusiveMode.pointerDragged(this.lastPointerEvent);
 		}
 		else {
 			Iterator<ActionMode<? super DRAW,CANVAS,COLOR>> iterator = this.modeStack.descendingIterator();
 			while (iterator.hasNext()) {
 				ActionMode<? super DRAW,CANVAS,COLOR> m = iterator.next();
-				m.pointerDragged(e);
+				m.pointerDragged(this.lastPointerEvent);
 				if (e.isConsumed()) return;
 			}
 		}
@@ -635,13 +633,13 @@
     public void pointerMoved(PointerEvent e) {
 		updatePointerInfo(e, true);
 		if (this.exclusiveMode!=null) {
-			this.exclusiveMode.pointerMoved(e);
+			this.exclusiveMode.pointerMoved(this.lastPointerEvent);
 		}
 		else {
 			Iterator<ActionMode<? super DRAW,CANVAS,COLOR>> iterator = this.modeStack.descendingIterator();
 			while (iterator.hasNext()) {
 				ActionMode<? super DRAW,CANVAS,COLOR> m = iterator.next();
-				m.pointerMoved(e);
+				m.pointerMoved(this.lastPointerEvent);
 				if (e.isConsumed()) return;
 			}
 		}
@@ -649,12 +647,19 @@
 
 	private void updatePointedData() {
 		if (!this.isFigureUnderTheMouseComputed
-			&& !Float.isNaN(this.mouseX) && !Float.isNaN(this.mouseY)) {
+			&& this.lastPointerEvent!=null) {
 			DRAW fig = null;
 			this.figureUnderTheMouse = null;
 			ActionModeManagerOwner<DRAW,CANVAS,COLOR> container = getModeManagerOwner();
 			if (container!=null) {
-				fig = container.getFigureAt(this.mouseX, this.mouseY);
+				if (this.lastPointerEvent.isToolAreaSupported()) {
+					for(int i=0; fig==null && i<this.lastPointerEvent.getPointerCount(); ++i) {
+						fig = container.getFigureOn(this.lastPointerEvent.getToolArea(i));
+					}
+				}
+				else {
+					fig = container.getFigureAt(this.lastPointerEvent.getX(), this.lastPointerEvent.getY());
+				}
 				if (fig!=null) {
 					this.figureUnderTheMouse = new WeakReference<DRAW>(fig);
 				}
@@ -692,7 +697,8 @@
 		return getPointedFigure()!=null;
 	}
 	
-	/** Upfdate the internal data conerning the pointer.
+	/** Update the internal data conerning the pointer.
+	 * This function updates {@link #lastPointerEvent}.
 	 * 
 	 * @param e
 	 * @param invalidateHitFigure is <code>true</code> to force
@@ -703,60 +709,20 @@
 			this.isFigureUnderTheMouseComputed = false;
 			this.figureUnderTheMouse = null;
 		}
+		ZoomableContext zc = null;
 		ActionModeManagerOwner<DRAW,CANVAS,COLOR> container = getModeManagerOwner();
 		if (container!=null) {
-			ZoomableContext zc = container.getZoomableContext();
-			if (zc!=null) {
-				this.mouseX = zc.pixel2logical_x(e.getX());
-				this.mouseY = zc.pixel2logical_y(e.getY());
-				this.mouseArea = zc.pixel2logical(e.getToolArea(0));
-			}
-			else {
-				this.mouseX = e.getX();
-				this.mouseY = e.getY();
-				this.mouseArea = e.getToolArea(0);
-			}
+			zc = container.getZoomableContext();
 		}
-		else {
-			this.mouseX = e.getX();
-			this.mouseY = e.getY();
-			this.mouseArea = e.getToolArea(0);
-		}
+		this.lastPointerEvent = new ActionPointerEvent(e, zc);
 	}
 	
-	/** Replies the current position of the mouse in the document.
+	/** Replies the last pointer event encountered by the manager.
 	 * 
-	 * @return the position of the mouse in the document in a new point instance; not on
-	 * the screen.
+	 * @return the last pointer found.
 	 */
-	public Point2D getMousePosition() {
-		return new Point2f(this.mouseX, this.mouseY);
+	public ActionPointerEvent getLastPointerEvent() {
+		return this.lastPointerEvent;
 	}
-
-	/** Replies the current position of the mouse in the document.
-	 * 
-	 * @return the position of the mouse in the document; not on
-	 * the screen.
-	 */
-	public float getMouseX() {
-		return this.mouseX;
-	}
-
-	/** Replies the current position of the mouse in the document.
-	 * 
-	 * @return the position of the mouse in the document; not on
-	 * the screen.
-	 */
-	public float getMouseY() {
-		return this.mouseY;
-	}
-
-	/** Replies the area covered by the pointer.
-	 * 
-	 * @return the area covered by the pointer.
-	 */
-	public Shape2f getMouseArea() {
-		return this.mouseArea;
-	}
-
+	
 }

Modified: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManagerOwner.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManagerOwner.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionModeManagerOwner.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -25,6 +25,7 @@
 import java.util.Set;
 
 import org.arakhne.afc.math.continous.object2d.Rectangle2f;
+import org.arakhne.afc.math.continous.object2d.Shape2f;
 import org.arakhne.afc.ui.MouseCursor;
 import org.arakhne.afc.ui.ZoomableContext;
 import org.arakhne.afc.ui.selection.Selectable;
@@ -99,7 +100,7 @@
 	 */
 	public void repaint();
 	
-	/** Replies the precision of the clicks.
+	/** Replies the precision of the clicks (in pixels).
 	 * 
 	 * @return the precision of the clicks.
 	 */
@@ -180,9 +181,37 @@
 	 * @param y
 	 * @return the hit figure, or <code>null</code> if none.
 	 * @see #getFigureWithBoundsAt(float, float)
+	 * @see #getFigureOn(Shape2f)
+	 * @see #getFigureIn(Rectangle2f)
+	 * @see #getFiguresOn(Shape2f)
+	 * @see #getFiguresIn(Rectangle2f)
 	 */
 	public DRAW getFigureAt(float x, float y);
 
+	/** Replies the figure that is intersecting the specified
+	 * area.
+	 * 
+	 * @param area
+	 * @return the hit figure, or <code>null</code> if none.
+	 * @see #getFigureAt(float, float)
+	 * @see #getFigureIn(Rectangle2f)
+	 * @see #getFiguresOn(Shape2f)
+	 * @see #getFiguresIn(Rectangle2f)
+	 */
+	public DRAW getFigureOn(Shape2f area);
+
+	/** Replies the figure that is inside the specified
+	 * area.
+	 * 
+	 * @param area
+	 * @return the hit figure, or <code>null</code> if none.
+	 * @see #getFigureOn(Shape2f)
+	 * @see #getFigureAt(float, float)
+	 * @see #getFiguresOn(Shape2f)
+	 * @see #getFiguresIn(Rectangle2f)
+	 */
+	public DRAW getFigureIn(Rectangle2f area);
+
 	/** Replies the figure that has its bounds with the specified
 	 * point inside. If you want to test the point against
 	 * the shape of the figures, please use
@@ -198,15 +227,21 @@
 	 * 
 	 * @param bounds
 	 * @return the hit figures, never <code>null</code>.
+	 * @see #getFigureOn(Shape2f)
+	 * @see #getFigureIn(Rectangle2f)
+	 * @see #getFigureAt(float, float)
 	 * @see #getFiguresIn(Rectangle2f)
 	 */
-	public Set<DRAW> getFiguresOn(Rectangle2f bounds);
+	public Set<DRAW> getFiguresOn(Shape2f bounds);
 
 	/** Replies the figures that are inside the specified bounds.
 	 * 
 	 * @param bounds
 	 * @return the hit figures, never <code>null</code>.
-	 * @see #getFiguresOn(Rectangle2f)
+	 * @see #getFigureOn(Shape2f)
+	 * @see #getFigureIn(Rectangle2f)
+	 * @see #getFiguresOn(Shape2f)
+	 * @see #getFigureAt(float, float)
 	 */
 	public Set<DRAW> getFiguresIn(Rectangle2f bounds);
 

Added: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionPointerEvent.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionPointerEvent.java	                        (rev 0)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/ActionPointerEvent.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -0,0 +1,212 @@
+/* 
+ * $Id$
+ * 
+ * Copyright (C) 2002 Stephane GALLAND, Madhi HANNOUN, Marc BAUMGARTNER.
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * This program is free software; you can redistribute it and/or modify
+ */
+package org.arakhne.afc.ui.actionmode ;
+
+import org.arakhne.afc.math.continous.object2d.Point2f;
+import org.arakhne.afc.math.continous.object2d.Shape2f;
+import org.arakhne.afc.math.generic.Point2D;
+import org.arakhne.afc.ui.ZoomableContext;
+import org.arakhne.afc.ui.event.PointerEvent;
+
+/** Implementation of a pointer event for action modes.
+ *
+ * @author $Author: galland$
+ * @version $FullVersion$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+public class ActionPointerEvent implements PointerEvent {
+
+	private static final long serialVersionUID = -6024600428453074472L;
+	
+	private final PointerEvent originalEvent;
+	private final ZoomableContext zoomContext;
+	private float x = Float.NaN;
+	private float y = Float.NaN;
+	private float xPrecision = Float.NaN;
+	private float yPrecision = Float.NaN;
+	
+	/**
+	 * @param original
+	 * @param zoomContext
+	 */
+	public ActionPointerEvent(PointerEvent original, ZoomableContext zoomContext) {
+		this.originalEvent = original;
+		this.zoomContext = zoomContext;
+	}
+	
+	/** Replies the original event that is embedded in this action-mode event.
+	 * 
+	 * @return the original pointer event.
+	 */
+	public PointerEvent getOriginalPointerEvent() {
+		return this.originalEvent;
+	}
+	
+	/** Replies the zoomable context in which the event occurs.
+	 * 
+	 * @return the zoomable context, or <code>null</code> if none.
+	 */
+	public ZoomableContext getZoomableContext() {
+		return this.zoomContext;
+	}
+
+	@Override
+	public int getDeviceId() {
+		return this.originalEvent.getDeviceId();
+	}
+
+	@Override
+	public boolean isConsumed() {
+		return this.originalEvent.isConsumed();
+	}
+
+	@Override
+	public void consume() {
+		this.originalEvent.consume();
+	}
+
+	@Override
+	public boolean isShiftDown() {
+		return this.originalEvent.isShiftDown();
+	}
+
+	@Override
+	public boolean isControlDown() {
+		return this.originalEvent.isControlDown();
+	}
+
+	@Override
+	public boolean isMetaDown() {
+		return this.originalEvent.isMetaDown();
+	}
+
+	@Override
+	public boolean isAltDown() {
+		return this.originalEvent.isAltDown();
+	}
+
+	@Override
+	public boolean isAltGraphDown() {
+		return this.originalEvent.isAltGraphDown();
+	}
+
+	@Override
+	public boolean isContextualActionTriggered() {
+		return this.originalEvent.isContextualActionTriggered();
+	}
+
+	@Override
+	public long when() {
+		return this.originalEvent.when();
+	}
+
+	@Override
+	public float getX() {
+		if (Float.isNaN(this.x)) {
+			if (this.zoomContext==null)
+				this.x = this.originalEvent.getX();
+			else
+				this.x = this.zoomContext.pixel2logical_x(this.originalEvent.getX());
+		}
+		return this.x;
+	}
+	
+	/** Replies the position of the pointer.
+	 * 
+	 * @return the position of the pointer, never <code>null</code>.
+	 */
+	public Point2D getPosition() {
+		return new Point2f(getX(), getY());
+	}
+
+	@Override
+	public float getY() {
+		if (Float.isNaN(this.y)) {
+			if (this.zoomContext==null)
+				this.y = this.originalEvent.getX();
+			else
+				this.y = this.zoomContext.pixel2logical_y(this.originalEvent.getY());
+		}
+		return this.y;
+	}
+
+	@Override
+	public int getButton() {
+		return this.originalEvent.getButton();
+	}
+
+	@Override
+	public int getClickCount() {
+		return this.originalEvent.getClickCount();
+	}
+
+	@Override
+	public float getOrientation() {
+		return this.originalEvent.getOrientation();
+	}
+
+	@Override
+	public float getXPrecision() {
+		if (Float.isNaN(this.xPrecision)) {
+			if (this.zoomContext==null)
+				this.xPrecision = this.originalEvent.getXPrecision();
+			else
+				this.xPrecision = this.zoomContext.pixel2logical_size(this.originalEvent.getXPrecision());
+		}
+		return this.xPrecision;
+	}
+
+	@Override
+	public float getYPrecision() {
+		if (Float.isNaN(this.yPrecision)) {
+			if (this.zoomContext==null)
+				this.yPrecision = this.originalEvent.getYPrecision();
+			else
+				this.yPrecision = this.zoomContext.pixel2logical_size(this.originalEvent.getYPrecision());
+		}
+		return this.yPrecision;
+	}
+
+	@Override
+	public int getPointerCount() {
+		return this.originalEvent.getPointerCount();
+	}
+
+	@Override
+	public Shape2f getToolArea(int pointerIndex) {
+		if (this.zoomContext==null)
+			return this.originalEvent.getToolArea(pointerIndex);
+		return this.zoomContext.pixel2logical(this.originalEvent.getToolArea(pointerIndex));
+	}
+
+	@Override
+	public ToolType getToolType(int pointerIndex) {
+		return this.originalEvent.getToolType(pointerIndex);
+	}
+
+	@Override
+	public boolean isToolAreaSupported() {
+		return this.originalEvent.isToolAreaSupported();
+	}
+
+}

Modified: trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/SelectableInteractionEvent.java
===================================================================
--- trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/SelectableInteractionEvent.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/actionmode/SelectableInteractionEvent.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -25,9 +25,7 @@
 import java.util.Collections;
 import java.util.EventObject;
 
-import org.arakhne.afc.math.generic.Point2D;
 import org.arakhne.afc.ui.event.KeyEvent;
-import org.arakhne.afc.ui.event.PointerEvent;
 import org.arakhne.afc.ui.selection.Selectable;
 
 /** Describes the interaction event.
@@ -43,8 +41,7 @@
 
 	private final Collection<? extends Selectable> figures;
 	private boolean consumed = false;
-	private final PointerEvent pointerEvent;
-	private final Point2D position;
+	private final ActionPointerEvent pointerEvent;
 	private final KeyEvent keyEvent;
 	private final boolean isEditable;
 	
@@ -57,7 +54,6 @@
 		super(manager);
 		this.figures = figure==null ? Collections.<Selectable>emptyList() : figure;
 		this.pointerEvent = null;
-		this.position = null;
 		this.keyEvent = null;
 		this.isEditable = isEditable;
 	}
@@ -66,14 +62,12 @@
 	 * @param manager
 	 * @param figure
 	 * @param pointerEvent
-	 * @param position is the click position in the document.
 	 * @param isEditable
 	 */
-	public SelectableInteractionEvent(ActionModeManager<?,?,?> manager, Collection<? extends Selectable> figure, PointerEvent pointerEvent, Point2D position, boolean isEditable) {
+	public SelectableInteractionEvent(ActionModeManager<?,?,?> manager, Collection<? extends Selectable> figure, ActionPointerEvent pointerEvent, boolean isEditable) {
 		super(manager);
 		this.figures = figure==null ? Collections.<Selectable>emptyList() : figure;
 		this.pointerEvent = pointerEvent;
-		this.position = position;
 		this.keyEvent = null;
 		this.isEditable = isEditable;
 	}
@@ -88,7 +82,6 @@
 		super(manager);
 		this.figures = figure==null ? Collections.<Selectable>emptyList() : figure;
 		this.pointerEvent = null;
-		this.position = null;
 		this.keyEvent = keyEvent;
 		this.isEditable = isEditable;
 	}
@@ -131,7 +124,7 @@
 	 * @return the pointer event or <code>null</code> if
 	 * there is no pointer event causing this interaction event.
 	 */
-	public PointerEvent getPointerEvent() {
+	public ActionPointerEvent getPointerEvent() {
 		return this.pointerEvent;
 	}
 
@@ -166,16 +159,4 @@
         return this.consumed;
     }
     
-    /** Replies the position of the click in the document.
-     * The value replie by this function differs from the
-     * mouse position replied by {@link PointerEvent}.
-     * This function replies a point in the document coordinate space.
-     * {@link PointerEvent} replies a point on the screen.
-     * 
-     * @return position of the click
-     */
-    public Point2D getPointerPosition() {
-    	return this.position;
-    }
-
 }

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-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-base/src/main/java/org/arakhne/afc/ui/event/PointerEvent.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -32,6 +32,13 @@
  */
 public interface PointerEvent extends InputEvent {
 
+	/** Replies the minimal size (in pixels) of the touch area.
+	 * The implementation classes must use this
+	 * variable, when possible, to initiale the size
+	 * of the touch areas.
+	 */
+	public static final float MINIMAL_TOOL_SIZE = 8;
+	
 	/** Replies the timestamp of when this event occurred.
 	 * 
 	 * @return the timestamp of when this event occurred.
@@ -121,9 +128,21 @@
 	 * @param pointerIndex is the index of the pointer for which to retreive
 	 * the tool area.
 	 * @return the area covered by the tool.
+	 * @see #isToolAreaSupported()
 	 */
 	public Shape2f getToolArea(int pointerIndex);
 
+	/** Returns if the background API is able to reply the
+	 * area covered by the pointer mean (finger, pen...).
+	 * This function permits to determine if the value replied
+	 * by {@link #getToolArea(int)} has a valid meaning or
+	 * is only a work-around.
+	 * 
+	 * @return <code>true</code> if the background API could compute
+	 * the area covered by the pointer, <code>false</code> otherwise.
+	 */
+	public boolean isToolAreaSupported();
+
 	/** Returns the type of tool detected for the given pointer.
 	 * 
 	 * @param pointerIndex is the index of the pointer for which to retreive

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-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-swing/src/main/java/org/arakhne/afc/ui/swing/event/PointerEventSwing.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -143,12 +143,21 @@
 
 	@Override
 	public Shape2f getToolArea(int pointerIndex) {
-		return new Circle2f(this.event.getX(), this.event.getY(), 0);
+		// Replies a circle with 1 pixel of radius
+		return new Circle2f(
+				this.event.getX(),
+				this.event.getY(),
+				MINIMAL_TOOL_SIZE / 2f);
 	}
 
 	@Override
 	public ToolType getToolType(int pointerIndex) {
 		return ToolType.MOUSE;
 	}
+
+	@Override
+	public boolean isToolAreaSupported() {
+		return false;
+	}
 	
 }

Modified: trunk/ui/ui-vector-awt/src/main/java/org/arakhne/afc/ui/vector/awt/AwtVectorToolkit.java
===================================================================
--- trunk/ui/ui-vector-awt/src/main/java/org/arakhne/afc/ui/vector/awt/AwtVectorToolkit.java	2013-04-09 11:53:27 UTC (rev 420)
+++ trunk/ui/ui-vector-awt/src/main/java/org/arakhne/afc/ui/vector/awt/AwtVectorToolkit.java	2013-04-09 13:32:56 UTC (rev 421)
@@ -450,7 +450,7 @@
 
 	/** This class permits to filter the color of an icon.
 	 * 
-	 * @author $Author: sgalland$
+	 * @author $Author: galland$
 	 * @version $FullVersion$
 	 * @mavengroupid $GroupId$
 	 * @mavenartifactid $ArtifactId$


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