Example usage for android.graphics RectF contains

List of usage examples for android.graphics RectF contains

Introduction

In this page you can find the example usage for android.graphics RectF contains.

Prototype

public boolean contains(float x, float y) 

Source Link

Document

Returns true if (x,y) is inside the rectangle.

Usage

From source file:com.lightstreamer.demo.android.DetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    pnEnabled = false;/*from   w  ww  . j a v a  2  s .  co  m*/

    // If activity recreated (such as from screen rotate), restore
    // the previous article selection set by onSaveInstanceState().
    // This is primarily necessary when in the two-pane layout.
    if (savedInstanceState != null) {
        currentItem = savedInstanceState.getInt(ARG_ITEM);
        pnEnabled = savedInstanceState.getBoolean(ARG_PN_CONTROLS);
    }

    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.details_view, container, false);

    toggle = (ToggleButton) view.findViewById(R.id.pn_switch);
    toggleContainer = view.findViewById(R.id.toggle_container);

    this.enablePN(pnEnabled);

    holder.put("stock_name", (TextView) view.findViewById(R.id.d_stock_name));
    holder.put("last_price", (TextView) view.findViewById(R.id.d_last_price));
    holder.put("time", (TextView) view.findViewById(R.id.d_time));
    holder.put("pct_change", (TextView) view.findViewById(R.id.d_pct_change));
    holder.put("bid_quantity", (TextView) view.findViewById(R.id.d_bid_quantity));
    holder.put("bid", (TextView) view.findViewById(R.id.d_bid));
    holder.put("ask", (TextView) view.findViewById(R.id.d_ask));
    holder.put("ask_quantity", (TextView) view.findViewById(R.id.d_ask_quantity));
    holder.put("min", (TextView) view.findViewById(R.id.d_min));
    holder.put("max", (TextView) view.findViewById(R.id.d_max));
    holder.put("open_price", (TextView) view.findViewById(R.id.d_open_price));

    final XYPlot plot = (XYPlot) view.findViewById(R.id.mySimpleXYPlot);
    chart.setPlot(plot);

    plot.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!pnEnabled) {
                //push notifications not enabled, ignore the touch
                return false;
            }

            v.performClick();

            int action = event.getActionMasked();

            float touchY = event.getY();
            float touchX = event.getX();

            XYGraphWidget widget = plot.getGraphWidget();
            RectF gridRect = widget.getGridRect();
            if (gridRect.contains(touchX, touchY)) {

                if (currentSubscription != null) {
                    double triggerVal = widget.getYVal(touchY);

                    chart.setMovingTriggerLine(triggerVal);
                    if (action == MotionEvent.ACTION_UP) {
                        triggerVal = Math.round(triggerVal * 100.0) / 100.0;
                        chart.endMovingTriggerLine(triggerVal);

                        Log.d(TAG, "Touch released @ " + triggerVal);
                        //go on the network only after the touch has been released
                        subscriptionHandling.activateMPN(getMpnInfo(triggerVal));
                    }
                } else {
                    Log.v(TAG, "touch ignored");
                }
            }

            return true;
        }
    });

    return view;
}

From source file:com.vincestyling.traversaless_testcase.TopTabIndicator.java

public boolean onTouchEvent(MotionEvent ev) {
    if (super.onTouchEvent(ev))
        return true;
    if (mViewPager == null)
        return false;

    final int count = getCount();
    if (count == 0)
        return false;

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
        mLastMotionX = ev.getX();/*from   www. j  a  v  a  2  s  .c  o m*/
        break;

    case MotionEvent.ACTION_MOVE: {
        final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
        final float x = MotionEventCompat.getX(ev, activePointerIndex);
        final float deltaX = x - mLastMotionX;

        if (!mIsDragging) {
            if (Math.abs(deltaX) > mTouchSlop) {
                mIsDragging = true;
            }
        }

        if (mIsDragging) {
            mLastMotionX = x;
            if (isFakeDragging() || beginFakeDrag()) {
                fakeDragBy(deltaX);
            }
        }

        break;
    }

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        if (!mIsDragging) {
            Rect areaRect = new Rect();
            areaRect.left = getPaddingLeft();
            areaRect.right = getWidth() - getPaddingRight();
            areaRect.top = getPaddingTop();
            areaRect.bottom = getHeight() - getPaddingBottom();

            int btnWidth = areaRect.width() / count;

            for (int pos = 0; pos < count; pos++) {
                RectF tabRect = new RectF(areaRect);
                tabRect.left += pos * btnWidth;
                tabRect.right = tabRect.left + btnWidth;

                if (tabRect.contains(ev.getX(), ev.getY())) {
                    setCurrentItem(pos);
                    return true;
                }
            }
        }

        mIsDragging = false;
        mActivePointerId = INVALID_POINTER;
        if (isFakeDragging())
            endFakeDrag();
        break;

    case MotionEventCompat.ACTION_POINTER_DOWN: {
        final int index = MotionEventCompat.getActionIndex(ev);
        mLastMotionX = MotionEventCompat.getX(ev, index);
        mActivePointerId = MotionEventCompat.getPointerId(ev, index);
        break;
    }

    case MotionEventCompat.ACTION_POINTER_UP:
        final int pointerIndex = MotionEventCompat.getActionIndex(ev);
        final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
        if (pointerId == mActivePointerId) {
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
        }
        mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
        break;
    }

    return true;
}

From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java

private ScaleGestureDetector getTwoFingerGestureDetector(final XYPlot plot) {
    ScaleGestureDetector.SimpleOnScaleGestureListener gestureListener = new ScaleGestureDetector.SimpleOnScaleGestureListener() {
        @Override/*from w w w . ja va2 s. c  o  m*/
        public boolean onScale(ScaleGestureDetector detector) {
            float factor = detector.getPreviousSpan() / detector.getCurrentSpan();
            float pixelX = detector.getFocusX();
            RectF gridRect = plot.getGraphWidget().getGridRect();
            // getXVal throws IAE if the X value is outside of the rectangle
            if (gridRect.contains(pixelX, gridRect.top)) {
                double pivot = plot.getGraphWidget().getXVal(pixelX);
                zoom(factor, pivot);
            }

            plot.setDomainBoundaries(minX, maxX, BoundaryMode.FIXED);
            redrawPlot(plot);
            return true;
        }
    };

    return new ScaleGestureDetector(getActivity(), gestureListener);
}

From source file:org.stockchart.StockChartView.java

private boolean handleTouchStickerEvent(MotionEvent ev) {
    int e = ev.getAction() & MotionEvent.ACTION_MASK;
    float x = ev.getX();
    float y = ev.getY();

    Plot stickerPlot = fStickerInfo.area.getPlot();

    switch (e) {//from  ww  w.  ja va  2 s .  c o m
    case MotionEvent.ACTION_DOWN: {
        if (stickerPlot.getAbsoluteBounds().contains(x, y)) {
            double vx = fStickerInfo.area.getValueByCoordinate(fStickerInfo.sticker.getHorizontalAxis(), x,
                    true);
            double vy = fStickerInfo.area.getValueByCoordinate(fStickerInfo.sticker.getVerticalAxis(), y, true);

            switch (fStickerInfo.stickerPoint) {
            case STICKER_FIRST_POINT:
                fStickerInfo.sticker.setFirstPoint(vx, vy);
                break;
            case STICKER_SECOND_POINT:
                fStickerInfo.sticker.setSecondPoint(vx, vy);
                break;
            case STICKER_MID_POINT: {
                this.fStickerMidPoint.set(vx, vy);
                this.fStickerFirstPoint.set(fStickerInfo.sticker.getX1(), fStickerInfo.sticker.getY1());
                this.fStickerSecondPoint.set(fStickerInfo.sticker.getX2(), fStickerInfo.sticker.getY2());
            }
                break;
            default: {
                fStickerInfo.sticker.setFirstPoint(vx, vy);
                this.fCustomObjects.put(CustomObjects.STICKER, fStickerInfo);
            }
            }

            this.invalidate();
        }
    }
        break;
    case MotionEvent.ACTION_UP: {
        if (fStickerInfo.sticker.isValid() && fStickerInfo.stickerPoint == STICKER_AUTO_POINT)
            fStickerInfo.area.getStickers().add(fStickerInfo.sticker);

        this.fCustomObjects.remove(CustomObjects.STICKER);
        fStickerInfo = null;
        this.invalidate();

    }
        break;
    case MotionEvent.ACTION_MOVE: {
        RectF absoluteBounds = stickerPlot.getAbsoluteBounds();

        if (!absoluteBounds.contains(x, y)) {
            if (x < absoluteBounds.left)
                x = absoluteBounds.left;
            else if (x > absoluteBounds.right)
                x = absoluteBounds.right;

            if (y < absoluteBounds.top)
                y = absoluteBounds.top;
            else if (y > absoluteBounds.bottom)
                y = absoluteBounds.bottom;
        }

        double vx = fStickerInfo.area.getValueByCoordinate(fStickerInfo.sticker.getHorizontalAxis(), x, true);
        double vy = fStickerInfo.area.getValueByCoordinate(fStickerInfo.sticker.getVerticalAxis(), y, true);

        if (fStickerInfo.stickerPoint == STICKER_FIRST_POINT)
            fStickerInfo.sticker.setFirstPoint(vx, vy);
        else if (fStickerInfo.stickerPoint == STICKER_MID_POINT) {
            double dx = vx - this.fStickerMidPoint.x;
            double dy = vy - this.fStickerMidPoint.y;

            fStickerInfo.sticker.setFirstPoint(fStickerFirstPoint.x + dx, fStickerFirstPoint.y + dy);
            fStickerInfo.sticker.setSecondPoint(fStickerSecondPoint.x + dx, fStickerSecondPoint.y + dy);
        } else
            fStickerInfo.sticker.setSecondPoint(vx, vy);

        this.invalidate();
    }
        break;

    }

    return true;
}

From source file:com.tjw.selectimage.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;/*from  ww w . ja  v a  2s  . c o m*/
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            if (displayRect != null) {
                final float x = e.getX(), y = e.getY();

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java

public final boolean onSingleTapConfirmed(MotionEvent e) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (null != mPhotoTapListener) {
            final RectF displayRect = getDisplayRect();

            if (null != displayRect) {
                final float x = e.getX(), y = e.getY();

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    mPhotoTapListener.onPhotoTap(imageView, xResult, yResult);
                    return true;
                }//from w  w  w . j  a  v a  2  s. c o m
            }
        }
        if (null != mViewTapListener) {
            mViewTapListener.onViewTap(imageView, e.getX(), e.getY());
        }
    }

    return false;
}

From source file:com.github.chrisbanes.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;// w ww. jav a  2s  . co m
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            final float x = e.getX(), y = e.getY();

            if (mViewTapListener != null) {
                mViewTapListener.onViewTap(mImageView, x, y);
            }

            if (displayRect != null) {

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:com.frank.protean.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;//from   w  w  w.jav a 2 s .c o  m
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), onGestureListener);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            final float x = e.getX(), y = e.getY();

            if (mViewTapListener != null) {
                mViewTapListener.onViewTap(mImageView, x, y);
            }

            if (displayRect != null) {

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:com.huyn.demogroup.zoomageview.view.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;//from   w  w w. j av a  2 s  . co m
    View parent = (View) mImageView.getParent();
    parent.setOnTouchListener(this);
    parent.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mIsDragging) {
                return false;
            }
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            if (displayRect != null) {
                final float x = e.getX(), y = e.getY();

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:org.stockchart.StockChartView.java

public void getHitTestInfo(HitTestInfo info, float x, float y, int hitTestOptions) {
    info.reset();//  w  w w  .  j  a  v  a 2s .  c  o m

    resetPositions();

    for (Area a : fAreas) {
        if (!a.isVisible())
            continue;

        if (a.getAbsoluteBounds().contains(x, y)) {
            if (a.getPlot().getAbsoluteBounds().contains(x, y)) {
                info.element = a.getPlot();
                SeriesPaintInfo pinfo = new SeriesPaintInfo();
                RectF rectF = new RectF();

                if (HIT_TEST_STICKERS == (hitTestOptions & HIT_TEST_STICKERS)) {
                    final float r = AbstractSticker.RADIUS;

                    PointF rel = a.getPlot().getRelativePosition(x, y);

                    for (AbstractSticker s : a.getStickers()) {
                        pinfo.loadFrom(a.getAxis(s.getHorizontalAxis()), a.getAxis(s.getVerticalAxis()));

                        double midX = s.getMidX();
                        double midY = s.getMidY();

                        // mid point
                        rectF.set(pinfo.getX(midX) - r, pinfo.getY(midY) - r, pinfo.getX(midX) + r,
                                pinfo.getY(midY) + r);

                        if (rectF.contains(rel.x, rel.y)) {
                            info.stickerInfo = new StickerInfo(a, s);
                            info.stickerInfo.stickerPoint = STICKER_MID_POINT;
                            break;
                        }

                        // first point
                        rectF.set(pinfo.getX(s.getX1()) - r, pinfo.getY(s.getY1()) - r,
                                pinfo.getX(s.getX1()) + r, pinfo.getY(s.getY1()) + r);

                        if (rectF.contains(rel.x, rel.y)) {
                            info.stickerInfo = new StickerInfo(a, s);
                            info.stickerInfo.stickerPoint = STICKER_FIRST_POINT;
                            break;
                        }

                        // second point
                        rectF.set(pinfo.getX(s.getX2()) - r, pinfo.getY(s.getY2()) - r,
                                pinfo.getX(s.getX2()) + r, pinfo.getY(s.getY2()) + r);

                        if (rectF.contains(rel.x, rel.y)) {
                            info.stickerInfo = new StickerInfo(a, s);
                            info.stickerInfo.stickerPoint = STICKER_SECOND_POINT;
                            break;
                        }
                    }
                }

                if (HIT_TEST_SERIES == (hitTestOptions & HIT_TEST_SERIES)) {

                    for (SeriesBase s : a.getSeries()) {
                        AbstractSeries<?> as = (AbstractSeries<?>) s;

                        pinfo.loadFrom(a.getAxis(as.getXAxisSide()), a.getAxis(as.getYAxisSide()));

                        if (!as.isVisibleOnScreen(pinfo.X.Max, pinfo.X.Min))
                            continue;

                        int index = as.convertToArrayIndexZeroBased(pinfo.X.Min);

                        for (int i = index; i < as.getPointCount(); i++) {
                            AbstractPoint ap = as.getPointAt(i);

                            float scaleIndex = as.convertToScaleIndex(i);

                            if (ap.isVisible()) {
                                double[] maxMin = ap.getMaxMin();
                                float x1 = pinfo.getX(scaleIndex - 0.5f) + 1f;
                                float x2 = pinfo.getX(scaleIndex + 0.5f) - 1f;

                                float max = pinfo.getY(maxMin[0]);
                                float min = pinfo.getY(maxMin[1]);

                                if (maxMin[0] == maxMin[1]) {
                                    float d = (x2 - x1) / 2f;
                                    max -= d;
                                    min += d;
                                }

                                PointF p = a.getPlot().getAbsolutePosition(x1, max);
                                rectF.set(p.x, p.y, p.x + (x2 - x1), p.y + (min - max));

                                if (rectF.contains(x, y)) {
                                    if (null == info.points)
                                        info.points = new TreeMap<String, AbstractPoint>();

                                    info.points.put(s.getName(), ap);
                                    break;
                                }

                            }

                            if (scaleIndex > pinfo.X.Max)
                                break;
                        }
                    }
                }

            } else {
                for (Axis axis : a.getAxes()) {
                    if (axis.getAbsoluteBounds().contains(x, y)) {
                        info.element = axis;
                        break;
                    }
                }
            }

            if (info.element == null)
                info.element = a;

            break;
        }
    }
}