Это пример, я думаю, это поможет
import java.awt.*;
import javax.swing.*;
public class ActivityGraph extends JFrame {
int[] active = {0,1,1,0,0,0,1,0,1,0,1,0,1,1,1,1,0,0,1,0,1,1};
int length = 25, //basic length in pixels for drawing the lines
offset = 50; //so the lines aren't sticked at the border
private ActivityGraph(String name, int x, int y, int width, int height) {
super(name);
setBounds(x, y, width, height);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel panel = new GraphPanel();
//panel.setBounds(0, 0, 800, 400); not nessesary
add(panel);
}
public static void main(String[] args) {
new ActivityGraph("Activity Graph", 60, 60, 800, 400).setVisible(true);
}
private class GraphPanel extends JPanel {
public void paint(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, 800, 400);
//setting background (method setBackground() doesn't want to work for me)
g.setColor(Color.black);
for(int i = 0; i<active.length; i++) {
if(active[i]==0) {
g.drawLine(offset + i*length, offset + length, offset + i*length + length, offset + length);
}
else {
g.drawLine(offset + i*length, offset, offset + i*length + length, offset);
}
/*
* draw line from XY point to another XY point
* notice that X = Y = 0 point is in left top corner
* so higher Y values will mean "downer" points acctualy
*/
}
}
}
}
Если вы хотите, я могу выслать вам блок графиков для математических функций (например, sinus, power, ...)