- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarGraphPanel.java
More file actions
Latest commit
39 lines (33 loc) · 1.02 KB
/
Copy pathBarGraphPanel.java
File metadata and controls
39 lines (33 loc) · 1.02 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
/*
Bar Graph Panel object for Parkrun data collector
Daniel Mesham
28 January 2017
*/
importjavax.swing.*;
importjava.awt.*;
importjava.lang.Math;
classBarGraphPanelextendsGraphPanel {
privateGraphBar[] dataBars;
privateColorcolor = Color.RED;
publicBarGraphPanel(intwidthIn, intheightIn, doublemaxX, doublemaxY, GraphBar[] dataBarsIn) {
super(widthIn, heightIn, maxX, maxY);
dataBars = dataBarsIn;
}
//@Override
publicvoidpaintComponent(Graphicsg) {
super.paintComponent(g);
plot(dataBars, color, g);
}
privatevoidplot(GraphBar[] dataIn, ColorcolorIn, Graphicsg) {
ColoroldColor = g.getColor();
g.setColor(colorIn);
for (GraphBargb : dataIn) {
intwidth = lengthToX(gb.getWidth());
intheight = lengthToY(gb.getHeight());
intx = valToX(gb.getX());
inty = valToY(0) - height;
g.fillRect(x,y,width,height);
}
g.setColor(oldColor);
}
}