-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyShape.java
More file actions
93 lines (73 loc) · 1.88 KB
/
Copy pathMyShape.java
File metadata and controls
93 lines (73 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import java.awt.Graphics2D;
import java.awt.Paint;
import java.io.Serializable;
public abstract class MyShape implements Serializable{
private int x1; //第一个点的x值
private int y1; //第一个点的y值
private int x2; //第二个点的x值
private int y2; //第二个点的y值
private Paint myColor;//图形的颜色
private boolean filled;//图形是否填充
private float stroke = 1.0f; //线条粗细
public MyShape(){//缺省构造法
stroke = 1.0f;
}
public MyShape(Paint p,float s){ //构造2 颜色+stroke
this.setMyColor(p);
this.setStroke(s);
}
public MyShape(float s){ //构造3 stroke
this.setStroke(s);
}
public MyShape(int x1, int y1, int x2, int y2,Paint myColor){ //构造4
super();
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.myColor = myColor;
}
public float getStroke(){//获得stroke属性
return stroke;
}
public void setStroke(float stroke){//设置stroke属性
this.stroke = stroke;
}
public int getX1(){//获取第一个点的x值
return x1;
}
public void setX1(int x1){//设置第一个点的x值
this.x1 = x1;
}
public int getY1(){//获取第一个点的y值
return y1;
}
public void setY1(int y1){//设置第一个点的y值
this.y1 = y1;
}
public int getX2(){//获取第二个点的x值
return x2;
}
public void setX2(int x2){//设置第二个点的x值
this.x2 = x2;
}
public int getY2(){ //获取第二个点的y值
return y2;
}
public void setY2(int y2){ //设置第二个点的y值
this.y2 = y2;
}
public Paint getMyColor(){ //获取颜色
return myColor;
}
public void setMyColor(Paint myColor){//设置颜色
this.myColor = myColor;
}
public boolean isFilled(){//判断是否要填充
return filled;
}
public void setFilled(boolean filled){//设置是否填充
this.filled = filled;
}
public abstract void draw(Graphics2D g); //draw方法在子类中重写
}