-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPieChartSlice.java
More file actions
105 lines (103 loc) · 2 KB
/
PieChartSlice.java
File metadata and controls
105 lines (103 loc) · 2 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
import java.util.ArrayList;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Line2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Arc2D;
import java.awt.Color;
import java.awt.geom.Rectangle2D;
public class PieChartSlice extends Arc2D.Double
{
final double x = 50;
final double y = 85;
final double w = 250;
final double h = 250;
double angle;
String name;
Color color;
/**
creates the slice for a pie chart.
@param name, angleStart, and extent
*/
public PieChartSlice(String name,double angle, double extent)
{
super();
this.name = name;
this.angle = angle;
setArc(x,y,w,h,0,0,Arc2D.PIE);
}
/**
creates and empty slice.
*/
public PieChartSlice()
{
}
/**
sets the name for the slice
@param name
*/
public void setName(String name)
{
this.name = name;
}
/**
returns name
*/
public String getName()
{
return name;
}
/**
sets color for each slice
*/
public void setColor(Color color)
{
this.color = color;
}
/**
returns color
*/
public Color getColor()
{
return color;
}
/**
sets the starting angle for slice
@param angle
*/
public void setAngleStart(double angle)
{
super.setAngleStart(angle);
}
/**
returns the starting angle
*/
public double getAngleStart()
{
return super.getAngleStart();
}
/**
sets the size for each slice
@param extent
*/
public void setAngleExtent(double extent)
{
super.setAngleExtent(extent);
}
/**
returns the size for each slice
*/
public double getAngleExtent()
{
return super.getAngleExtent();
}
/**
draws each slice
*/
public void draw(Graphics2D g)
{
Graphics2D g2 = (Graphics2D) g;
g2.setColor(color);
g2.fill(this);
}
}