-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicShape.java
More file actions
108 lines (98 loc) · 2.25 KB
/
BasicShape.java
File metadata and controls
108 lines (98 loc) · 2.25 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* Gerard Ortega, 171668
I have not discussed the Java language code
in my program with anyone
other than my instructor or the teaching
assistants assigned to this course.
I have not used Java language code
obtained from another student, or
any other unauthorized source, either
modified or unmodified.
If any Java language
code or documentation used in my program was
obtained from another source, such as a text
book or course notes, those have been clearly
noted with a proper citation in the
comments of my code. */
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class BasicShape implements DrawingObject
{
protected final static double EPS = 0.00001;
protected double x;
protected double y;
protected boolean isOutlined;
protected boolean isFilled;
protected Color outlineColor;
protected Paint fillColor;
protected Paint awakenedFillColor;
protected boolean awakenable;
protected boolean awakened;
public BasicShape(){}
public BasicShape(double x, double y, Paint fillColor)
{
this.x = x;
this.y = y;
isFilled = true;
this.fillColor = fillColor;
isOutlined = false;
outlineColor = Color.BLACK;
awakenable = false;
awakened = false;
awakenedFillColor = this.fillColor;
}
public void setShowFill(boolean show)
{
isFilled = show;
}
public void setFillColor(Color c)
{
fillColor = c;
}
public void setShowOutline(boolean show)
{
isOutlined = show;
}
public void setOutlineColor(Color c)
{
outlineColor = c;
}
public void setAwakenedFillColor(Color c)
{
awakenedFillColor = c;
}
public Paint getColor(boolean awake)
{
return (awake ? awakenedFillColor : fillColor);
}
public void drawShape(Graphics2D g2d, Shape s)
{
if(isFilled)
{
if(awakened)
g2d.setPaint(awakenedFillColor);
else
g2d.setPaint(fillColor);
g2d.fill(s);
}
if(isOutlined)
{
g2d.setColor(outlineColor);
g2d.draw(s);
}
}
public void awakenableToggle()
{
awakenable = !awakenable;
}
public boolean canBeAwakened()
{
return awakenable;
}
public void awakenToggle()
{
awakened = !awakened;
}
public void draw(Graphics2D g2d, AffineTransform af){}
public void animate(){}
}