/**
   * callback method for onTouch events
   *
   * @param pointinfo info about the touch event
   * @return
   *     <p><b>true</b> if the touch event is handled by this event<br>
   *     <b>false</b> if this touch event is not for this element
   *     <p>This is intended, that a subobject can check, if it should handle a click or so, or if
   *     the event should be sent to the underlying object.
   */
  public boolean onTouch(PointInfo pointinfo) {
    boolean handleEvent = false;

    // first ask our subobjects to handle it, otherwise let us handle it

    for (int i = subDrawables.size() - 1; i >= 0 && !handleEvent; i--) {

      MultiTouchDrawable sub = subDrawables.get(i);

      if (sub.containsPoint(pointinfo.getX(), pointinfo.getY())) {
        handleEvent = sub.onTouch(pointinfo);
      }
    }

    // Logger.d("touch action: "+this.getClass().getSimpleName()+" " +
    // pointinfo.getAction()+
    // " 0x"+Integer.toHexString(pointinfo.getAction()));

    // it's hard to find MOTION_UP events, because if the finger does not
    // stay exactly on the correct position,
    // this will change to dragging and we wont't get the drag end as
    // MOTION_UP

    if (!handleEvent
        && pointinfo.isMultiTouch() == false
        && pointinfo.getNumTouchPoints() == 1
        && pointinfo.getAction() == MotionEvent.ACTION_DOWN) {
      handleEvent = this.onSingleTouch(pointinfo);
    }

    return handleEvent;
  }
  public MultiTouchDrawable getDraggableObjectAtPoint(PointInfo pt) {
    float x = pt.getX(), y = pt.getY();
    int n = subDrawables.size();
    for (int i = n - 1; i >= 0; i--) {
      MultiTouchDrawable im = subDrawables.get(i);

      if (im.isDragable() && im.containsPoint(x, y)) {
        return im.getDraggableObjectAtPoint(pt);
      }
    }

    if (this.containsPoint(pt.getX(), pt.getY())) {
      return this;
    }

    return null;
  }
  /** Return whether or not the given screen coords are inside this image */
  public boolean containsPoint(float scrnX, float scrnY) {
    // If this is a subdrawable, then don't let the controller think this is
    // the item to be dragged. Otherwise non-draggable subdrawables will not
    // allow to drag the superdrawable when the user's finger is exactly on
    // them. FIXME: Is this the right place to do this?
    // if (this.hasSuperDrawable())
    // return false;
    // else
    // FIXME: need to correctly account for image rotation
    boolean inside = (scrnX >= minX && scrnX <= maxX && scrnY >= minY && scrnY <= maxY);

    if (inside) return true;

    Iterator<MultiTouchDrawable> it = this.subDrawables.iterator();
    while (it.hasNext()) {
      MultiTouchDrawable sub = it.next();
      if (sub.containsPoint(scrnX, scrnY)) {
        return true;
      }
    }

    return false;
  }