Particular method doubts in my coding please explain
<p>now i am post my full coding....i have doubts in some method that method can you explain...please...</p>

<p>full coding:</p>

<pre><code>package com.momojo.gba.input;

import com.androidemu.Emulator;
import com.momojo.gba.R;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public abstract class AbstractMultitouchPad implements MultitouchPad
{
public final Paint       myPaint      = new Paint(Paint.ANTI_ALIAS_FLAG);
public int orientation = Configuration.ORIENTATION_UNDEFINED;

public VirtualButton     aButton      = null;
public VirtualButton     bButton      = null;
public VirtualButton     selectButton = null;
public VirtualButton     startButton  = null;
public VirtualButton     leftButton  = null;
public VirtualButton     rightButton  = null;
public VirtualButton     dpadButton   = null;

VirtualButton[]          buttons      = new VirtualButton[7];
private static final int DEAD_ZONE    = 20;
private static final int DPAD_INDEX = 6;
private View             view         = null;
private int[]            KEYVALS      = new int[] { Emulator.GAMEPAD_A,
        Emulator.GAMEPAD_B, Emulator.GAMEPAD_LEFT, Emulator.GAMEPAD_RIGHT, Emulator.GAMEPAD_SELECT, Emulator.GAMEPAD_START };

private GameKeyListener  gameKeyListener;
private int              keyStates;

public AbstractMultitouchPad(Resources resources, View view)
{
    myPaint.setColor(0xFFFF0000);
    myPaint.setAlpha(100);
    setView(view);
    aButton = new VirtualButton(resources, R.drawable.a);
    bButton = new VirtualButton(resources, R.drawable.b);
    selectButton = new VirtualButton(resources, R.drawable.start);
    startButton = new VirtualButton(resources, R.drawable.start);
    dpadButton = new VirtualButton(resources, R.drawable.dpad);
    leftButton = new VirtualButton(resources, R.drawable.l);
    rightButton = new VirtualButton(resources, R.drawable.r);

    buttons[0] = aButton;
    buttons[1] = bButton;
    buttons[2] = leftButton;
    buttons[3] = rightButton;
    buttons[4] = selectButton;
    buttons[5] = startButton;
    buttons[6] = dpadButton;
}

public void setView(View view)
{
    this.view = view;
}

@Override
public abstract void draw(View view, Canvas canvas);

public boolean handleEvent(MotionEvent event)
{

    int action = event.getAction();
    int key = 0;
    int actionCode = action &amp; MotionEvent.ACTION_MASK;

    int index = 0;

    if (actionCode == MotionEvent.ACTION_POINTER_DOWN
                || actionCode == MotionEvent.ACTION_POINTER_UP)
    {

        index = action &gt;&gt; MotionEvent.ACTION_POINTER_ID_SHIFT;
    }


   key = getGameKey(event.getX(index), event.getY(index));

    switch (actionCode)
    {
    case MotionEvent.ACTION_POINTER_DOWN:            
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_MOVE:
        keyStates |= key;
        break;
    case MotionEvent.ACTION_POINTER_UP:
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_OUTSIDE:
    case MotionEvent.ACTION_CANCEL:
    {          
        keyStates &amp;= ~key;            
        break;
    }
    default:
    {            
       return false;
    }
    }

    gameKeyListener.onGameKeyChanged();
    return true;

}

private int getGameKey(float x, float y)
{
    int key = 0;
    boolean foundKey = false;

    for (int j = 0; j &lt; buttons.length - 1 &amp;&amp; !foundKey; j++)
    {
        if (buttons[j].isHit(x, y))
        {
            key = KEYVALS[j];
            foundKey = true;
        }
    }

    if (!foundKey &amp;&amp; buttons[DPAD_INDEX].isHit(x, y))
    {  
        key = getDpadKey(x, y);
        foundKey = true;
    }

    if(!foundKey )
    {
        if((keyStates &amp; Emulator.GAMEPAD_A) == Emulator.GAMEPAD_A)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_A;
        }
        if((keyStates &amp; Emulator.GAMEPAD_B) == Emulator.GAMEPAD_B)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_B;
        }
    }

   return key;

}

private int getDpadKey(float fx, float fy)
{
    final int x = (int) (fx + 0.5f);
    final int y = (int) (fy + 0.5f);
    final int cx = (int) dpadButton.x + dpadButton.bitmap.getWidth() / 2;
    final int cy = (int) dpadButton.y + dpadButton.bitmap.getHeight() / 2;

    int key = 0;
    if (x &lt; cx - DEAD_ZONE &amp;&amp; x &gt; dpadButton.x)
    {
        if((keyStates &amp; Emulator.GAMEPAD_RIGHT) == Emulator.GAMEPAD_RIGHT)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_RIGHT;
        }
        key |= Emulator.GAMEPAD_LEFT;                        
    }
    else if (x &gt; cx + DEAD_ZONE &amp;&amp; x &lt; dpadButton.x2)
    {
        if((keyStates &amp; Emulator.GAMEPAD_LEFT) == Emulator.GAMEPAD_LEFT)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_LEFT;
        }
        key |= Emulator.GAMEPAD_RIGHT;            
    }
    if (y &lt; cy - DEAD_ZONE &amp;&amp; y &gt; dpadButton.y)
    {
        if((keyStates &amp; Emulator.GAMEPAD_DOWN) == Emulator.GAMEPAD_DOWN)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_DOWN;
        }
        key |= Emulator.GAMEPAD_UP;
    }
    else if (y &gt; cy + DEAD_ZONE &amp;&amp; y &lt; dpadButton.y2)
    {
        if((keyStates &amp; Emulator.GAMEPAD_UP) == Emulator.GAMEPAD_UP)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_UP;
        }
        key |= Emulator.GAMEPAD_DOWN;
    }
    return key;
}

public void setGameKeyListener(GameKeyListener listener)
{
    gameKeyListener = listener;
}

public int getKeyStates()
{
    return keyStates;
}

private void setKeyStates(int newStates)
{
    if (keyStates != newStates)
    {
        keyStates = newStates;
        gameKeyListener.onGameKeyChanged();
    }
}

public void reset()
{
    keyStates = 0;
}

public void setOrientation(int orientation)
{
    this.orientation = orientation;
}

@Override
public void setTransparency(int level)
{
    myPaint.setAlpha((int)((level/100f) * 255));

}  

}
</code></pre>

<p>doubts:</p>

<pre><code>    public AbstractMultitouchPad(Resources resources, View view)
{
    myPaint.setColor(0xFFFF0000);
    myPaint.setAlpha(100);
    setView(view);
    aButton = new VirtualButton(resources, R.drawable.a);
    bButton = new VirtualButton(resources, R.drawable.b);
    selectButton = new VirtualButton(resources, R.drawable.start);
    startButton = new VirtualButton(resources, R.drawable.start);
    dpadButton = new VirtualButton(resources, R.drawable.dpad);
    leftButton = new VirtualButton(resources, R.drawable.l);
    rightButton = new VirtualButton(resources, R.drawable.r);

    buttons[0] = aButton;
    buttons[1] = bButton;
    buttons[2] = leftButton;
    buttons[3] = rightButton;
    buttons[4] = selectButton;
    buttons[5] = startButton;
    buttons[6] = dpadButton;
}

public void setView(View view)
{
    this.view = view;
}

@Override
public abstract void draw(View view, Canvas canvas);

public boolean handleEvent(MotionEvent event)
{

    int action = event.getAction();
    int key = 0;
    int actionCode = action &amp; MotionEvent.ACTION_MASK;

    int index = 0;

    if (actionCode == MotionEvent.ACTION_POINTER_DOWN
                || actionCode == MotionEvent.ACTION_POINTER_UP)
    {

        index = action &gt;&gt; MotionEvent.ACTION_POINTER_ID_SHIFT;
    }


   key = getGameKey(event.getX(index), event.getY(index));

    switch (actionCode)
    {
    case MotionEvent.ACTION_POINTER_DOWN:            
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_MOVE:
        keyStates |= key;
        break;
    case MotionEvent.ACTION_POINTER_UP:
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_OUTSIDE:
    case MotionEvent.ACTION_CANCEL:
    {          
        keyStates &amp;= ~key;            
        break;
    }
    default:
    {            
       return false;
    }
    }

    gameKeyListener.onGameKeyChanged();
    return true;

}

private int getGameKey(float x, float y)
{
    int key = 0;
    boolean foundKey = false;

    for (int j = 0; j &lt; buttons.length - 1 &amp;&amp; !foundKey; j++)
    {
        if (buttons[j].isHit(x, y))
        {
            key = KEYVALS[j];
            foundKey = true;
        }
    }

    if (!foundKey &amp;&amp; buttons[DPAD_INDEX].isHit(x, y))
    {  
        key = getDpadKey(x, y);
        foundKey = true;
    }

    if(!foundKey )
    {
        if((keyStates &amp; Emulator.GAMEPAD_A) == Emulator.GAMEPAD_A)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_A;
        }
        if((keyStates &amp; Emulator.GAMEPAD_B) == Emulator.GAMEPAD_B)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_B;
        }
    }

   return key;

}

private int getDpadKey(float fx, float fy)
{
    final int x = (int) (fx + 0.5f);
    final int y = (int) (fy + 0.5f);
    final int cx = (int) dpadButton.x + dpadButton.bitmap.getWidth() / 2;
    final int cy = (int) dpadButton.y + dpadButton.bitmap.getHeight() / 2;

    int key = 0;
    if (x &lt; cx - DEAD_ZONE &amp;&amp; x &gt; dpadButton.x)
    {
        if((keyStates &amp; Emulator.GAMEPAD_RIGHT) == Emulator.GAMEPAD_RIGHT)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_RIGHT;
        }
        key |= Emulator.GAMEPAD_LEFT;                        
    }
    else if (x &gt; cx + DEAD_ZONE &amp;&amp; x &lt; dpadButton.x2)
    {
        if((keyStates &amp; Emulator.GAMEPAD_LEFT) == Emulator.GAMEPAD_LEFT)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_LEFT;
        }
        key |= Emulator.GAMEPAD_RIGHT;            
    }
    if (y &lt; cy - DEAD_ZONE &amp;&amp; y &gt; dpadButton.y)
    {
        if((keyStates &amp; Emulator.GAMEPAD_DOWN) == Emulator.GAMEPAD_DOWN)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_DOWN;
        }
        key |= Emulator.GAMEPAD_UP;
    }
    else if (y &gt; cy + DEAD_ZONE &amp;&amp; y &lt; dpadButton.y2)
    {
        if((keyStates &amp; Emulator.GAMEPAD_UP) == Emulator.GAMEPAD_UP)
        {
            keyStates &amp;= ~Emulator.GAMEPAD_UP;
        }
        key |= Emulator.GAMEPAD_DOWN;
    }
    return key;
}
</code></pre>
