import java.awt.*;
//import java.awt.event.*;

class Canvas_graph_total extends java.awt.Canvas //implements ActionListener
{
  Dimension size;
    
	public Dimension getPreferredSize()
	{
	  return getMinimumSize();
	}

	public Dimension getMinimumSize()
	{
	  return size;
	}
  
	public Canvas_graph_total(int initialWidth, int initialHeight)
	{
	  size = new Dimension(initialWidth, initialHeight);
	}	
	
	double f(double x)
  {
    	return (- Vibration.g1.amplitude * Math.sin(x * Vibration.g1.omega) - Vibration.g2.amplitude * Math.sin(x * Vibration.g2.omega - Vibration.g2.phase) + 2) * size.height/4;
  }

  public void paint(Graphics g)
  {
    g.drawRect(0,0,size.width,size.height-1);
    g.drawLine(0,size.height/2,size.width,size.height/2);
    
  	for (int x = 0 ; x < size.width ; x++)
    {
      g.drawLine(x, (int)f(x), x + 1, (int)f(x + 1));
    }
  }
}