-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrawFreqGraph.java
42 lines (35 loc) · 1.01 KB
/
DrawFreqGraph.java
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
import javax.swing.*;
import java.awt.*;
public class DrawFreqGraph extends JComponent
{
/**Default Constructor*/
public DrawFreqGraph ()
{
super ();
this.setPreferredSize(new Dimension(1339, 620));
}
/** Overrides paintComponent to paint a smiley face
@param g The Graphics component used to display the smiley face*/
public void paintComponent(Graphics g)
{
super.paintComponent(g);
//Axis
g.drawLine (100,550, 1240,550);
g.drawLine (100,550, 100,100);
if (Graph.getMaxValue()>=20){
for (int x =1; x<= 20; x++)
{
int spaceX= 57;
g.drawLine (100+(x*spaceX), 560, 100+(x*spaceX), 540);
}
}
else
{
for (int x =1; x<= Graph.getMaxValue() ; x++)
{
int spaceX= (int)(Math.round((1140.0/Graph.getMaxValue())));
g.drawLine (100+(x*spaceX), 560, 100+(x*spaceX), 540);
}
}
}
}