package cn.card.bean;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import cn.card.bean.inf.BeanInf;
public class Card implements BeanInf
{
private int number;
private Rect numberRect;
private int color;
private Rect colorRect;
private Rect backgroundRect;
private int left;
private int top;
public Card(int number, Rect numberRect, int color, Rect colorRect,
Rect backgroundRect, int left, int top)
{
super();
this.number = number;
this.numberRect = numberRect;
this.color = color;
this.colorRect = colorRect;
this.backgroundRect = backgroundRect;
this.left = left;
this.top = top;
}
@Override
public void draw(Canvas canvas, Paint paint, Bitmap bitmap)
{
Rect dst = getRect(left, top, backgroundRect.width(),
backgroundRect.height());
canvas.drawBitmap(bitmap, backgroundRect, dst, paint);
dst = getRect(left + 1, top + 1, numberRect.width(),
numberRect.height());
canvas.drawBitmap(bitmap, numberRect, dst, paint);
dst = getRect(dst.left, dst.bottom + 1, colorRect.width(),
colorRect.height());
canvas.drawBitmap(bitmap, colorRect, dst, paint);
canvas.save();
dst = getRect(left, top, backgroundRect.width(),
backgroundRect.height());
canvas.rotate(180, dst.exactCenterX(), dst.exactCenterY());
dst = getRect(left + 1, top + 1, numberRect.width(),
numberRect.height());
canvas.drawBitmap(bitmap, numberRect, dst, paint);
dst = getRect(dst.left, dst.bottom + 1, colorRect.width(),
colorRect.height());
canvas.drawBitmap(bitmap, colorRect, dst, paint);
canvas.restore();
}
@Override
public boolean onTouchEvent(MotionEvent e)
{
// TODO Auto-generated method stub
return false;
}
private Rect getRect(int l, int t, int w, int h)
{
int right = l + w;
int bottom = t + h;
return new Rect(l, t, right, bottom);
}
public int getNumber()
{
return number;
}
public void setNumber(int number)
{
this.number = number;
}
public Rect getNumberRect()
{
return numberRect;
}
public void setNumberRect(Rect numberRect)
{
this.numberRect = numberRect;
}
public int getColor()
{
return color;
}
public void setColor(int color)
{
this.color = color;
}
public Rect getColorRect()
{
return colorRect;
}
public void setColorRect(Rect colorRect)
{
this.colorRect = colorRect;
}
public Rect getBackgroundRect()
{
return backgroundRect;
}
public void setBackgroundRect(Rect backgroundRect)
{
this.backgroundRect = backgroundRect;
}
public int getLeft()
{
return left;
}
public void setLeft(int left)
{
this.left = left;
}
public int getTop()
{
return top;
}
public void setTop(int top)
{
this.top = top;
}
}
card
最新推荐文章于 2025-06-08 09:00:00 发布