71 lines
1.6 KiB
Java
71 lines
1.6 KiB
Java
package com.codigoparallevar.minicards.parts;
|
|
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Color;
|
|
import android.graphics.Paint;
|
|
|
|
public class Placeholder implements Part {
|
|
private int _left;
|
|
private int _top;
|
|
private int _right;
|
|
private int _bottom;
|
|
|
|
public Placeholder(int left, int top, int right, int bottom) {
|
|
_left = left;
|
|
_top = top;
|
|
_right = right;
|
|
_bottom = bottom;
|
|
}
|
|
|
|
@Override
|
|
public int getLeft() {
|
|
return _left;
|
|
}
|
|
|
|
@Override
|
|
public int getRight() {
|
|
return _right;
|
|
}
|
|
|
|
@Override
|
|
public int getTop() {
|
|
return _top;
|
|
}
|
|
|
|
@Override
|
|
public int getBottom() {
|
|
return _bottom;
|
|
}
|
|
|
|
@Override
|
|
public void draw(Canvas canvas) {
|
|
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
paint.setColor(Color.WHITE);
|
|
|
|
// Top
|
|
canvas.drawLine(_left, _top, _right, _top, paint);
|
|
// Bottom
|
|
canvas.drawLine(_left, _bottom, _right, _bottom, paint);
|
|
// Left
|
|
canvas.drawLine(_left, _top, _left, _bottom, paint);
|
|
// Right
|
|
canvas.drawLine(_right, _top, _right, _bottom, paint);
|
|
// Cross, top-left, bottom-right
|
|
canvas.drawLine(_left, _top, _right, _bottom, paint);
|
|
// Cross, top-right, bottom-left
|
|
canvas.drawLine(_right, _top, _left, _bottom, paint);
|
|
}
|
|
|
|
@Override
|
|
public void move(int x, int y) {
|
|
final int width = _right - _left;
|
|
final int height = _bottom - _top;
|
|
|
|
_left = x - width / 2;
|
|
_right = _left + width;
|
|
|
|
_top = y - height / 2;
|
|
_bottom = _top + height;
|
|
}
|
|
}
|