22
22
23
23
public class PolygonElement extends Element
24
24
{
25
+ /**
26
+ * Default constructor with empty point list.
27
+ */
28
+ protected PolygonElement ()
29
+ {
30
+ this .pointList = new ArrayList <>();
31
+ this .borderColor = Color .BLACK ;
32
+ this .backgroundColor = Color .WHITE ;
33
+ }
34
+
35
+
25
36
public PolygonElement (List <Point2D > pointList )
26
37
{
27
38
this (pointList , Color .WHITE );
@@ -77,8 +88,8 @@ public void draw(Graphics2D g)
77
88
78
89
79
90
// ---------------------------------------------------------------------
80
- // Section: Setters and Getters
81
- // ---------------------------------------------------------------------
91
+ // Section: Getters
92
+ // --------------------------------------------------------------------
82
93
83
94
84
95
@ Override
@@ -92,6 +103,11 @@ public Rectangle2D getBounds()
92
103
}
93
104
94
105
106
+ // ---------------------------------------------------------------------
107
+ // Section: Setters
108
+ // ---------------------------------------------------------------------
109
+
110
+
95
111
public void setBackgroundColor (Color color )
96
112
{
97
113
this .backgroundColor = color ;
@@ -104,12 +120,20 @@ public void setBorderColor(Color color)
104
120
}
105
121
106
122
123
+ @ Override
124
+ public void setPosition (Point2D position )
125
+ {
126
+ super .setPosition (position );
127
+ this .buildPolygon ();
128
+ }
129
+
130
+
107
131
// ---------------------------------------------------------------------
108
132
// Section: Variables
109
133
// ---------------------------------------------------------------------
110
134
111
135
112
- private List <Point2D > pointList ;
136
+ protected List <Point2D > pointList ;
113
137
114
138
private Polygon polygon ;
115
139
0 commit comments