Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Shapes {
- protected int xs1,ys1,xs2,ys2;
- public Paint style;
- protected int ColorIndex;
- protected Paint.Style PaintStyle;
- Shapes(){
- style = new Paint();
- setPaintStyle(Paint.Style.FILL);
- style.setStrokeWidth(12);
- setColorIndex(Color.BLACK);
- style.setAntiAlias(true);
- }
- // Shapes(int color,Paint.Style pstyle){
- // setColorIndex(color);
- // setPaintStyle(pstyle);
- //style.setColor(Color.CYAN);
- // }
- public final void Set(int x1,int y1,int x2,int y2)
- {
- xs1 = x1;
- ys1 = y1;
- xs2 = x2;
- ys2 = y2;
- }
- public void setColorIndex(int index){
- this.ColorIndex = index;
- }
- public int getColorIndex(){
- return ColorIndex;
- }
- public void setPaintStyle(Paint.Style pstyle){
- this.PaintStyle= pstyle;
- }
- public Paint.Style getPaintStyle(){
- return PaintStyle;
- }
- public void Show(Canvas canvas){
- }
- }
- public class RectShape extends Shapes{
- // public RectShape(){
- // super();
- // }
- public RectShape(int color,Paint.Style pstyle){
- //super(color,pstyle);
- super();
- setColorIndex(color);
- setPaintStyle(pstyle);
- //style.setColor(Color.CYAN);
- }
- @Override
- public void Show(Canvas canvas){
- if(xs2>xs1 && ys2>ys1)
- canvas.drawRect(xs1,ys1,xs2,ys2, style);
- else if(xs2<xs1 && ys2>ys1)
- canvas.drawRect(xs2,ys1,xs1,ys2, style);
- else if(xs2>xs1 && ys2<ys1)
- canvas.drawRect(xs1,ys2,xs2,ys1, style);
- else
- canvas.drawRect(xs2,ys2,xs1,ys1, style);
- }
- }
Add Comment
Please, Sign In to add comment