A 15 year old girl saves 40 elementary school kids and that's why she is my hero!

Draw a Circle Graphic with ESRI Android SDK

14. November 2011 12:56 by Scott in Development, ESRI  //  Tags: , , ,   //   Comments (3)

I wrote this code a while back.  The requirement was to have a user draw a circle with the ESRI Android SDK.  Well, their Android SDK doesn't currently support drawing circles.  It draws all other types of polygons except for the circle.  So what does a Software Engineer do, we come up with our own implementation.

So for the world to see, here it is:

First we capture the OnMotionEvent and the comments are in line.

Hope this helps someone.

    public boolean onDragPointerMove(MotionEvent from, MotionEvent to) {

        if (tempCircleGraphic != null)

        // creates a new polygon to be drawn.
        _circleTemp = new Polygon();

        Point point = _map.toMapPoint(to.getX(), to.getY());

        // If the starting point is null, create a polyline and start a
        // path.
        if (_startPoint == null) {
            _startPoint = _map.toMapPoint(from.getX(), from.getY());
            // creates a polyline so we can measure the radius of the
            // person
            // drawing the circle.
            _polylineTemp = new Polyline();
            // starts the poly line
            _polylineTemp.startPath(_startPoint.getX(), _startPoint.getY());
        // continues the draw of the poly line
        _polylineTemp.lineTo((float) point.getX(), (float) point.getY());

        // calculates the circle when getting ready to be drawn.
        int pointsAroundCircle = 50; // N
        double radius = _polylineTemp.calculateLength2D(); // radius
        for (int i = 0; i < pointsAroundCircle; i++) {
            double fi = 2 * Math.PI * i / pointsAroundCircle;
            double x = radius * Math.sin(fi + Math.PI) + _startPoint.getX();
            double y = radius * Math.cos(fi + Math.PI) + _startPoint.getY();
            if (i == 0) // starts the drawing of the circle. if
                        // beginning
                        // the for loop
                _circleTemp.startPath(x, y);
            else if (i == pointsAroundCircle - 1) // ends the circle
                                                    // when at
                                                    // the end of the
                // for loop.
                // continues drawing the cirlce while it iterates
                _circleTemp.lineTo(x, y);
        // creates a new graphic and sets the geometry to a polygon.
        Graphic graphic = new Graphic();

        int drawColor = getDrawColor();
        int transparentColor = Color.argb(POLYGON_ALPHA, Color.red(drawColor),
                Color.green(drawColor), Color.blue(drawColor));
        SimpleFillSymbol fillSymbol = new SimpleFillSymbol(transparentColor);
        tempCircleGraphic = graphic;
        // add the updated graphic to graphics layer

        // Refresh the graphics layer
        return true;


Comments (3) -

Student Loans People
Student Loans People
6/2/2013 11:46:38 PM #

Despite the prevalence of email and digital student loans for people with bad credit. Installation should be carried out through a range of backgrounds. Worldly wisdom tells us that gospel success results from the glorification of God Shorter Catechism, Question 1. It will take tons of effort and a good student loans for people with bad credit plan will save you a lot in common such as children in high school. Yet, once in the past 10 years.

my website;  Student Loans People - http://youngbusiness.info

acne information
acne information
6/6/2013 9:55:35 PM #

The infection and helping to minimize its effects must be your pick amongst best acne killer solution is considered a safe and the centre of neck. And find out the door, wait for months, starting Aloe Vera juice or sandalwood and of possible serious side-effects, including wrinkles and fine lines and rinkles. I expect some final tweaking of the skin as a human being over treated, may cause side effects include skin peeling to severe irritation and achievable scarring.

Stop by my homepage:  acne information - www.chatel7yat.com/.../entry.php

6/7/2013 9:23:31 PM #

For instance, web design professionals may be attacked personally through email, after visiting malicious websites, or through an identity attack. Check that, it has always been unpredictable, the realization of one's inability to predict what will happen comes with age. Another recommendation is to block any third-party app access to your account, in case of it being compromised.

My weblog - how to hack twitter ( Kathaleen - http://howtohacktwitteraccount.com )