Android Open Source - ArchPad C Target View






From Project

Back to project page ArchPad.

License

The source code is released under:

GNU General Public License

If you think the Android project ArchPad listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.Andryyo.ArchPad.target;
/*from   w w w . j  a v  a2  s.c  o m*/
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.Andryyo.ArchPad.CShot;
import com.Andryyo.ArchPad.database.CSQLiteOpenHelper;

/**
 * Created with IntelliJ IDEA.
 * User: ???????
 * Date: 09.06.13
 * Time: 21:41
 * To change this template use File | Settings | File Templates.
 */
public class CTargetView extends View{

    private Context context;
    private CTarget target = null;
    private int center;

    public CTargetView(Context context, long _id)    {
        super(context);
        setTarget(_id);
        this.context = context;
    }

    public CTargetView(Context context, CTarget target)    {
        super(context);
        setTarget(target);
        this.context = context;
    }

    public CTargetView(Context context)    {
        super(context);
        this.context = context;
    }

    public CTargetView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    public void setTarget(long _id) {
        target = CSQLiteOpenHelper.getHelper(context).getTarget(_id);
        if (target!=null)
            target.setDrawingRadius(center);
    }

    public void setTarget(CTarget target)   {
        this.target = target;
        if (target!=null)
            target.setDrawingRadius(center);
    }

    public CTarget getTarget() {
        return target;
    }

    public float getRealRadius()    {
        return target.realRadius;
    }

    public int getCenter()  {
        return center;
    }

    @Override
    public void onMeasure(int w, int h) {
        center = Math.min(MeasureSpec.getSize(w),MeasureSpec.getSize(h))/2;
        this.setMeasuredDimension(center*2, center*2);
    }

    @Override
    public void onSizeChanged(int w, int h, int oldw, int oldh) {
        if (target!=null)
            target.setDrawingRadius(center);
    }

    @Override
    public void onDraw(Canvas canvas)   {
        if (target!=null)
            target.draw(canvas);
    }
}




Java Source Code List

com.Andryyo.ArchPad.CArrow.java
com.Andryyo.ArchPad.CShot.java
com.Andryyo.ArchPad.MainActivity.java
com.Andryyo.ArchPad.archeryFragment.CArcheryFragment.java
com.Andryyo.ArchPad.archeryFragment.CCurrentEndView.java
com.Andryyo.ArchPad.archeryFragment.CDistanceTemplate.java
com.Andryyo.ArchPad.archeryFragment.CDistance.java
com.Andryyo.ArchPad.archeryFragment.CRoundTemplate.java
com.Andryyo.ArchPad.archeryFragment.CRound.java
com.Andryyo.ArchPad.archeryFragment.IOnShotAddListener.java
com.Andryyo.ArchPad.archeryFragment.?EndsCounterView.java
com.Andryyo.ArchPad.database.CSQLiteOpenHelper.java
com.Andryyo.ArchPad.note.CNoteCreateActivity.java
com.Andryyo.ArchPad.note.CNotesFragment.java
com.Andryyo.ArchPad.sight.CSightSelectFragment.java
com.Andryyo.ArchPad.sight.?SightPropertiesFragment.java
com.Andryyo.ArchPad.start.CArrowSelectView.java
com.Andryyo.ArchPad.start.CColorSelectView.java
com.Andryyo.ArchPad.start.CRoundSelectView.java
com.Andryyo.ArchPad.start.CStartFragment.java
com.Andryyo.ArchPad.start.CTargetSelectView.java
com.Andryyo.ArchPad.start.IOnFragmentSwapRequiredListener.java
com.Andryyo.ArchPad.statistics.CBorderedTextView.java
com.Andryyo.ArchPad.statistics.CRecordViewFragment.java
com.Andryyo.ArchPad.statistics.CStatisticsFragment.java
com.Andryyo.ArchPad.statistics.IOnUpdateListener.java
com.Andryyo.ArchPad.target.CEditableTargetView.java
com.Andryyo.ArchPad.target.CRing.java
com.Andryyo.ArchPad.target.CTargetView.java
com.Andryyo.ArchPad.target.CTarget.java
com.Andryyo.ArchPad.target.CZoomableTargetView.java