/******************************************************************************
 ******** File:        ResonanceFrequency.java                         ********
 ******** Description: A program for computing resonace frequencies    ********
 ********              and visualizing the result                      ********
 ******** Project:     ACMUS                                           ********
 ********              A system for the design and simulation of       ********
 ********              musical listening environments acoustics        ********
 ******** Author:      Yang Yili (yili@linux.ime.usp.br)               ********
 ******** Institution: Department of Computer Science                  ********
 ********              Institute of Mathematics and Statistics         ********
 ********              University of São Paulo                         ********
 *****************************************************************************/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
import java.io.*;
/**
 * Computes resonance frequencies
 * @author Yang Yili
 */
public class ResonanceFrequency extends Applet
{
    
    /**
     * Initializes an applet
     * @param no parameter 
     */
    public void init()
    {
	setBackground(Color.gray);
	setLayout(new BorderLayout());
	text.setEditable(false);
	
	inputPanel.add(new Label("Length(m)"));
	length = new TextField("0",3);
  	inputPanel.add(length);
  	inputPanel.add(new Label("Width(m)"));
  	width = new TextField("0", 3);
	inputPanel.add(width);
  	inputPanel.add(new Label("Height(m)"));
  	height = new TextField("0", 3);
	inputPanel.add(height);
	Button button = new Button("Compute");
	button.addActionListener(new Compute());
	inputPanel.add(button);

	add("North", inputPanel);
	add("Center", graph);
	add("East", text);
    } /* method init */

    /** 
     * Describes the action to be performed when a user 
     * presses the button "Compute"
     * @param e ActionEvent
     */
    class Compute implements ActionListener
    {
	/** 
	 * Reads the inputs, computes the resonance frequencies 
	 * and generates the result in different format
	 * @param e ActionEvent
	 */
	public void actionPerformed(ActionEvent e)
	{
	    String w1 = width.getText();
	    Double w2 = Double.valueOf(w1);
	    double w = Math.abs(w2.doubleValue());
	    String l1 = length.getText();
	    Double l2 = Double.valueOf(l1);
	    double l = Math.abs(l2.doubleValue());
	    String h1 = height.getText();
	    Double h2 = Double.valueOf(h1);
	    double h = Math.abs(h2.doubleValue());
	    CalculateFrequency cal = new CalculateFrequency(w, l, h);
	    cal.calculateAxialFrequency();
	    cal.calculateTangentialFrequency();
	    cal.calculateObliqueFrequency();
	    graph.draw(cal);
	    if (cal.returnInputValidity() == false)
		text.setText("Please check the input data");
	    else
	    {
		Vector v = cal.axial_frequency;
		if (v.size() == 0)
		    text.setText("All axial frequencies are greater than 300Hz\n");
		else
		{
		    text.setText("Axial frequencies:\n");
		    text.append("value          Difference\n");
		    double[] difference = new double[v.size() - 1];
		    int index = 0;
		    double[] axial_frequency = new double[v.size()];
		    double sum_difference = 0.0;
		    for ( int i = 0; i < v.size(); i++)
		    {
			double d = ((Double)v.elementAt(i)).doubleValue();
			axial_frequency[i] = d;
		    }
		    sort(axial_frequency);
		    for (int i = 0; i < v.size(); i++)
		    {
			double d = axial_frequency[i];
			d = d * 10;
			int aux = (int)d;
			d = (double)aux / 10.0;
			if (i > 0)
			{
			    double  d1 = axial_frequency[i - 1];
			    d1 = d1 * 10;
			    int aux1 = (int)d1;
			    d1 = (double)aux1 / 10.0;
			    double d2 = d - d1;
			    difference[index] = d2;
			    index ++;
			    sum_difference += d2;
			    d2 = d2 * 10;
			    int aux2 = (int)d2;
			    d2 = (double)aux2 / 10.0;
			    if (d < 10.0)
				text.append("" + d +"            " + d2 + "\n");
			    else if (d > 10.0 && d < 100.0)
				text.append("" + d +"           " + d2 + "\n");
			    else
				text.append("" + d +"          " + d2 + "\n");
			}
			else
			    text.append("" + d + "\n");
		    }
		    double average;
		    if (v.size() > 1)
			average = (double)sum_difference / (v.size() - 1);
		    else
			average = sum_difference;
		    double standard_deviation = 0.0;
		    for (int i = 0; i< index; i++)
		    {
			standard_deviation += (difference[i] - average) * 
			    (difference[i] - average);
		    }
		    if (index > 1)
			standard_deviation = (double)standard_deviation / 
			    (v.size() - 1);
		    standard_deviation = Math.sqrt(standard_deviation);
		    standard_deviation *= 10.0;
		    int sd = (int)standard_deviation;
		    standard_deviation = (double)sd / 10.0;
		    text.append("Standard deviation: " 
				+ standard_deviation + "\n");
		    if (v.size() > 1)
			sum_difference = (double)sum_difference / (v.size() - 1);
		    sum_difference *= 10.0;
		    int s_d = (int)sum_difference;
		    sum_difference = (double)s_d / 10.0;
		    text.append("Average of the differences: " 
				+ sum_difference + "\n");
		}
		text.append("\n");
		v = cal.tangential_frequency;
		if (v.size() == 0)
		    text.append("All tangential frequencies are greater than 300Hz\n");
		else
		{
		    text.append("Tangential frequencies:\n");
		    text.append("value          Difference\n");
		    double[] difference = new double[v.size() - 1];
		    int index = 0;
		    double[] tangential_frequency = new double[v.size()];
		    double sum_difference = 0.0;
		    for ( int i = 0; i < v.size(); i++)
		    {
			double d = ((Double)v.elementAt(i)).doubleValue();
			tangential_frequency[i] = d;
		    }
		    sort(tangential_frequency);
		    for (int i = 0; i < v.size(); i++)
		    {
			double d = tangential_frequency[i];
			d = d * 10;
			int aux = (int)d;
			d = (double)aux / 10.0;
			if (i > 0)
			{
			    double  d1 = tangential_frequency[i - 1];
			    d1 = d1 * 10;
			    int aux1 = (int)d1;
			    d1 = (double)aux1 / 10.0;
			    double d2 = d - d1;
			    difference[index] = d2;
			    index ++;
			    sum_difference += d2;
			    d2 = d2 * 10;
			    int aux2 = (int)d2;
			    d2 = (double)aux2 / 10.0;
			    if (d < 10.0)
				text.append("" + d +"           " + d2 + "\n");
			    else if (d > 10.0 && d < 100.0)
				text.append("" + d +"           " + d2 + "\n");
			    else
				text.append("" + d +"          " + d2 + "\n");
			}
			else
			    text.append("" + d + "\n");
		    }
		    double average;
		    if (v.size() > 1)
			average = (double)sum_difference / (v.size() - 1);
		    else
			average = sum_difference;
		    double standard_deviation = 0.0;
		    for (int i = 0; i< index; i++)
		    {
			standard_deviation += (difference[i] - average) 
			    * (difference[i] - average);
		    }
		    if (v.size() > 1)
			standard_deviation = (double)standard_deviation / 
			    (v.size() - 1);
		    standard_deviation = Math.sqrt(standard_deviation);
		    standard_deviation *= 10.0;
		    int sd = (int)standard_deviation;
		    standard_deviation = (double)sd / 10.0;
		    text.append("Standard deviation: " 
				+ standard_deviation + "\n");
		    if (v.size() > 1)
			sum_difference = (double)sum_difference / (v.size() - 1);
		    sum_difference *= 10.0;
		    int s_d = (int)sum_difference;
		    sum_difference = (double)s_d / 10.0;
		    text.append("Average of the differences: " 
				+ sum_difference + "\n");
		}
		text.append("\n");
		v = cal.oblique_frequency;
		if (v.size() == 0)
		    text.append("All oblique frequencies are greater than 300Hz\n");
		else
		{
		    text.append("Oblique frequencies:\n");
		    text.append("value          Difference\n");
		    double[] difference = new double[v.size() - 1];
		    int index = 0;
		    double[] oblique_frequency = new double[v.size()];
		    double sum = 0.0;
		    double sum_difference = 0.0;
		    for ( int i = 0; i < v.size(); i++)
		    {
			double d = ((Double)v.elementAt(i)).doubleValue();
			oblique_frequency[i] = d;
		    }
		    sort(oblique_frequency);
		    for (int i = 0; i< v.size(); i++)
		    {
			double d = oblique_frequency[i];
			d = d * 10;
			int aux = (int)d;
			d = (double)aux / 10.0;
			if (i > 0)
		        {
			    double  d1 = oblique_frequency[i - 1];
			    d1 = d1 * 10;
			    int aux1 = (int)d1;
			    d1 = (double)aux1 / 10.0;
			    double d2 = d - d1;
			    difference[index] = d2;
			    index ++;
			    sum_difference += d2;
			    d2 = d2 * 10;
			    int aux2 = (int)d2;
			    d2 = (double)aux2 / 10.0;
			    if (d < 10.0)
				text.append("" + d +"            " + d2 + "\n");
			    else if (d > 10.0 && d < 100.0)
				text.append("" + d +"           " + d2 + "\n");
			    else
				text.append("" + d +"          " + d2 + "\n");
			}
			else
			    text.append("" + d + "\n");
		    }
		    double average;
		    if (v.size() > 1)
			average = (double)sum_difference / (v.size() - 1);
		    else
			average = sum_difference;
		    double standard_deviation = 0.0;
		    for (int i = 0; i< index; i++)
                    {
			standard_deviation += (difference[i] - average) * 
			    (difference[i] - average);
		    }
		    if (v.size() > 1)
			standard_deviation = (double)standard_deviation / 
(v.size() - 1);
		    standard_deviation = Math.sqrt(standard_deviation);
		    standard_deviation *= 10.0;
		    int sd = (int)standard_deviation;
		    standard_deviation = (double)sd / 10.0;
		    text.append("Standard deviation: " 
				+ standard_deviation + "\n");
		    if (v.size() > 1)
			sum_difference = (double)sum_difference / (v.size() - 1);
		    sum_difference *= 10.0;
		    int s_d = (int)sum_difference;
		    sum_difference = (double)s_d / 10.0;
		    text.append("Average of the differences: " 
				+ sum_difference + "\n");
		}
	    }
	}
	private void sort(double[] d)
	{
	    for (int i = 0; i < d.length; i++)
	    {
		int index = i;
		double min = d[i];
		for (int j = i + 1; j < d.length; j++)
		{
		    if(d[j] < min){
			index = j;
			min = d[j];
		    }
		}
		if (index != i)
		{
		    double aux = d[i];
		    d[i] = d[index];
		    d[index] = aux;
		}
	    }
	}
	
    }/* class Compute */

    private Panel inputPanel = new Panel();
    private TextField width;
    private TextField length;
    private TextField height;
    private DrawGraph graph = new DrawGraph();
    private TextArea text = new TextArea("Here is a ouput file", 10, 35, 
					 TextArea.SCROLLBARS_VERTICAL_ONLY);
}/* class ResonanceFrequency */

/**
 * Computes the resonance frequencies
 * @author Yang Yili
 * @author yili@linux.ime.usp.br
 */
class CalculateFrequency
{
    /** 
     * Creates a new CalculateFrequency
     * @param x width of a room
     * @param y length of a room
     * @param z height of a room
     */
    CalculateFrequency(double x, double y, double z)
    {
	width = x;
	length = y;
	height = z;
    }
    /**
     * Computes the axial frequencies
     * @param no parameter
     */
    public void calculateAxialFrequency()
    {
	int p, q, r;
	testInput();
	if (input_valid == true)
	{
	    for (p = 1; p <= (int)300.0 * 2.0 * length / v; p ++)
	    {
		double frequency = v / 2.0 * Math.sqrt((p * p) / 
						       (length * length));
		axial_frequency.addElement(new Double(frequency));
	    }
	    for (q = 1;  q <= (int)300.0 * 2.0 * width / v; q ++)
	    {
		double frequency = v / 2.0 * Math.sqrt((q * q) / 
						       (width * width));
		axial_frequency.addElement(new Double(frequency));
	    }
	    for (r = 1;  r <= (int)300.0 * 2.0 * height / v; r ++)
	    {
		double frequency = v / 2.0 * Math.sqrt((r * r) / 
						       (height * height));
		axial_frequency.addElement(new Double(frequency));
	    }
	}
	
    }/* method calculateAxialFrequency */

    /**
     * Computes the tangential frequencies
     * @param no parameter
     */
    public void calculateTangentialFrequency()
    {
	int p, q, r;
	testInput();
	if (input_valid == true)
	{
	    if (1.0 / (width * width) <= 600.0 / v &&
		1.0 / (height * height) <= 600.0 / v)
	    {
		double x = width * Math.sqrt(600.0 * 600.0 / (v * v)
					     - 1.0 / (height * height));
		for (q = 1; q <= (int)x; q ++) 
		{
		    double y = height * Math.sqrt(600.0 * 600.0 / (v * v)
						  - 1.0 / (width * width));
		    for (r = 1; r <= (int)y; r ++)
		    {
			double frequency = v / 2.0 * 
			                   Math.sqrt((r * r) / 
						     (height * height) + 
						     (q * q) / 
						     (width * width));
			if (frequency <= 300.0)
			{
			    tangential_frequency.addElement
				(new Double(frequency));
			}
		    }	
		}
	    }
	    if (1.0 / (length * length) <= 600.0 / v &&
		1.0 / (height * height) <= 600.0 / v)
       	    {
		double x = length * Math.sqrt(600.0 * 600.0 / (v * v) - 
					      1.0 / (height * height));
		for (p = 1; p <= (int)x; p ++) 
		{
		    double y = height * Math.sqrt(600.0 * 600.0 / (v * v) - 
						  1.0 / (length * length));
		    for (r = 1; r <= (int)y; r ++)
		    {
			double frequency = v / 2.0 * 
			                   Math.sqrt((r * r) / 
						     (height * height) + 
						     (p * p) / 
						     (length * length));
			if (frequency <= 300.0)
			{
			    tangential_frequency.addElement
				(new Double(frequency));
			}
		    }
		}
	    }
	    if (1.0 / (length * length) <= 600.0 / v &&
		1.0 / (width * width) <= 600.0 / v)
	    {
		double x = length * Math.sqrt(600.0 * 600.0 / (v * v) - 
					      1.0 / (width * width));
		for (p = 1; p <= (int)x; p ++) 
		{
		    double y = width * Math.sqrt(600.0 * 600.0 / (v * v) - 
						 1.0 / (length * length));
		    for (q = 1; q <= (int)y; q ++)
		    {
			double frequency = v / 2.0 * 
			                   Math.sqrt((q * q) / 
						     (width * width) + 
						     (p * p) / 
						     (length * length));
			if (frequency <= 300.0)
			{
			    tangential_frequency.addElement
				(new Double(frequency));
			}
		    }
		}
	    }
	}
	
    }/* method calculateTangentialFrequency */

    /**
     * Computes the oblique frequencies
     * @param no parameter
     */
    public void calculateObliqueFrequency()
    {
	int p, q, r;
	testInput();
	if (input_valid == true)
	{
	    if (v * Math.sqrt(1 / (height * height) + 
			      1 / (length * length) +
			      1 / (width * width)) / 2.0 <= 300.0)
	    {
		double x = length * Math.sqrt(600.0 * 600.0 / (v * v) - 
					      1.0 / (height * height) - 
					      1.0 / (width * width));
		for (p = 1; p <= (int)x; p ++)
		{
		    double y = width * Math.sqrt(600.0 * 600.0 / (v * v) - 
						 1.0 / (height * height) - 
						 1.0 / (length * length));
		    for (q = 1; q <= (int)y; q++)
		    {	
			double z = height * Math.sqrt(600.0 * 600.0 / (v * v) -
						      1.0 / (width * width) - 
						      1.0 / (length * length));
			for (r = 1; r <= (int)z; r++)
			{
			    double frequency = v / 2.0 * 
				               Math.sqrt((q * q) / 
							 (width * width) + 
							 (p * p) / 
							 (length * length) + 
							 (r * r) / 
							 (height * height));
			    if (frequency <= 300.0)
			    {
				oblique_frequency.addElement
				    (new Double(frequency));
			    }
			}
		    }
		}
	    }
	}
	
    }/* method calculateObliqueFrequency */

    /**
     * returns the input validity
     * @param no parameter
     * @return input_valid the input validity
     */
    public boolean returnInputValidity()
    {
	return input_valid;
    }
    /**
     * Verifies the input validity
     * @param no parameter
     * @return true if the inputs are within
     * acceptable ranges and false otherwise
     */
  
    private void testInput()
    {
	if (length * height * width == 0.0)
	    input_valid = false;
	else
	    input_valid = true;
    }
    private final double v = 344.0; 
    private double width;
    private double length;
    private double height;
    private boolean input_valid;
    Vector axial_frequency = new Vector();
    Vector tangential_frequency = new Vector();
    Vector oblique_frequency = new Vector();
}/* class CalculateFrequency */

/**
 * represents the computation result
 * @author Yang Yili
 * @author yili@linux.ime.usp.br
 */
class DrawGraph extends Canvas
{
    /**
     * create a new DrawGraph
     */
    DrawGraph()
    {
	setSize(20, 360);
    }
    void draw(CalculateFrequency calculate)
    { 
	cal = calculate;
	repaint();
    }
    /**
     * Draws graphs or a data analysis table to
     * represent the result 
     * @param g Graphics
     */ 
    public void paint(Graphics g)
    {
	if (cal == null)
	{
	    g.drawString("Please enter the data ",270, 180);

	}
	else
	{
	    if (cal.returnInputValidity() == false)
		g.drawString("Please check the input data", 235, 180);
	    else
	    {
		drawAxialGraph(g);
		drawTangentialGraph(g);
		drawObliqueGraph(g);
	    }
	}
    }/* method paint */

    /**
     * Draws a graph of axial frequencies
     * @param g Graphics
     */ 
    private void drawAxialGraph(Graphics g)
    {
	if (cal.axial_frequency.isEmpty() == true)
	    g.drawString("All axial frequencies are greater than 300Hz",
			 200, 60);
	else
	{
	    g.drawLine(10, 30, 10, 100);
	    g.drawLine(7, 35, 10, 30);
	    g.drawLine(13, 35, 10, 30);
	    g.drawLine(10, 100, 630, 100);
	    g.drawLine(625, 97, 630, 100);
	    g.drawLine(625, 103, 630, 100);
	    g.drawString("Axial", 300, 30);
	    g.drawString("Hz",640, 110);
	    g.drawLine(30, 100, 30, 103);
	    g.drawLine(50, 100, 50, 103);
	    g.drawLine(70, 100, 70, 103);
	    g.drawLine(90, 100, 90, 103);    
	    g.drawString("50", 110, 115);
	    g.drawLine(110, 100, 110, 106); 
	    g.drawLine(130, 100, 130, 103);
	    g.drawLine(150, 100, 150, 103);
	    g.drawLine(170, 100, 170, 103);
	    g.drawLine(190, 100, 190, 103);   
	    g.drawString("100", 210, 115);
	    g.drawLine(210, 100, 210, 106);
	    g.drawLine(230, 100, 230, 103);
	    g.drawLine(250, 100, 250, 103);
	    g.drawLine(270, 100, 270, 103);
	    g.drawLine(290, 100, 290, 103);    
	    g.drawString("150", 310, 115);
	    g.drawLine(310, 100, 310, 106);
	    g.drawLine(330, 100, 330, 103);
	    g.drawLine(350, 100, 350, 103);
	    g.drawLine(370, 100, 370, 103);
	    g.drawLine(390, 100, 390, 103);    
	    g.drawString("200", 410, 115);
	    g.drawLine(410, 100, 410, 106);
	    g.drawLine(430, 100, 430, 103);
	    g.drawLine(450, 100, 450, 103);
	    g.drawLine(470, 100, 470, 103);
	    g.drawLine(490, 100, 490, 103);    
	    g.drawString("250", 510, 115);
	    g.drawLine(510, 100, 510, 106);
	    g.drawLine(530, 100, 530, 103);
	    g.drawLine(550, 100, 550, 103);
	    g.drawLine(570, 100, 570, 103);
	    g.drawLine(590, 100, 590, 103);    
	    g.drawString("300", 610, 115);
	    g.drawLine(610, 100, 610, 106);   
	    for (int i = 0; i < cal.axial_frequency.size(); i ++)
	    {
		double aux = 600.0 / 300.0 * 
		    ((Double)cal.axial_frequency.elementAt(i)).doubleValue();
		int number = 0;
		for (int j = 0; j < cal.axial_frequency.size(); j ++)
		{
		    double aux1 =  ((Double)cal.axial_frequency.
				    elementAt(i)).doubleValue();
		    double aux2 =  ((Double)cal.axial_frequency.
				    elementAt(j)).doubleValue();
		    if (aux1 == aux2)
			number ++;
		}
		int x = 10 + (int) aux;
		g.drawLine(x, 70, x, 100);
		if (number > 1)
		    g.drawString("" + number, x - 2, 68);
	    }
	}
    }/* method drawAxialGraph */

    /**
     * Draws a graph of tangential frequencies
     * @param g Graphics
     */ 
    private void drawTangentialGraph(Graphics g)
    {
	if (cal.tangential_frequency.isEmpty() == true)	
	    g.drawString("All tangential frequencies are greater than 300Hz",
			 180, 180);
	else
	{
	    g.drawLine(10, 150, 10, 220);
	    g.drawLine(7, 155, 10, 150);
	    g.drawLine(13, 155, 10, 150);
	    g.drawLine(10, 220, 630, 220);
	    g.drawLine(625, 217, 630, 220);
	    g.drawLine(625, 223, 630, 220);
	    g.drawString("Tangential", 300, 150);
	    g.drawString("Hz",640, 235);
	    g.drawLine(30, 220, 30, 223);
	    g.drawLine(50, 220, 50, 223);
	    g.drawLine(70, 220, 70, 223);
	    g.drawLine(90, 220, 90, 223);   
	    g.drawString("50", 110, 235);
	    g.drawLine(110, 220, 110, 226); 
	    g.drawLine(130, 220, 130, 223);
	    g.drawLine(150, 220, 150, 223);
	    g.drawLine(170, 220, 170, 223);
	    g.drawLine(190, 220, 190, 223); 
	    g.drawString("100", 210, 235);
	    g.drawLine(210, 220, 210, 226);
	    g.drawLine(230, 220, 230, 223);
	    g.drawLine(250, 220, 250, 223);
	    g.drawLine(270, 220, 270, 223);
	    g.drawLine(290, 220, 290, 223);  
	    g.drawString("150", 310, 235);
	    g.drawLine(310, 220, 310, 226);
	    g.drawLine(330, 220, 330, 223);
	    g.drawLine(350, 220, 350, 223);
	    g.drawLine(370, 220, 370, 223);
	    g.drawLine(390, 220, 390, 223);
	    g.drawString("200", 410, 235);
	    g.drawLine(410, 220, 410, 226);
	    g.drawLine(430, 220, 430, 223);
	    g.drawLine(450, 220, 450, 223);
	    g.drawLine(470, 220, 470, 223);
	    g.drawLine(490, 220, 490, 223);    
	    g.drawString("250", 510, 235);
	    g.drawLine(510, 220, 510, 226);
	    g.drawLine(530, 220, 530, 223);
	    g.drawLine(550, 220, 550, 223);
	    g.drawLine(570, 220, 570, 223);
	    g.drawLine(590, 220, 590, 223);  
	    g.drawString("300", 610, 235);
	    g.drawLine(610, 220, 610, 226);   
	    for (int i = 0; i < cal.tangential_frequency.size(); i ++)
	    {
		double aux = 600.0 / 300.0 * 
		    ((Double)cal.tangential_frequency.elementAt(i)).
		    doubleValue();
		int x = 10 + (int) aux;
		g.drawLine(x, 190, x, 220);
	    }
	}
    }/* method drawTangentialGraph */

    /**
     * Draws a graph of oblique frequencies
     * @param g Graphics
     */ 
    private void drawObliqueGraph(Graphics g)
    {
	if (cal.oblique_frequency.isEmpty() == true)   
	    g.drawString("All oblique frequencies are greater than 300Hz",
			 190, 300);
	else
	{
	    g.drawLine(10, 270, 10, 340);
	    g.drawLine(7, 275, 10, 270);
	    g.drawLine(13, 275, 10, 270);
	    g.drawLine(10, 340, 630, 340);
	    g.drawLine(625, 337, 630, 340);
	    g.drawLine(625, 343, 630, 340);
	    g.drawString("Oblique", 300, 270);
	    g.drawString("Hz",640, 355);
	    g.drawLine(30, 340, 30, 343);
	    g.drawLine(50, 340, 50, 343);
	    g.drawLine(70, 340, 70, 343);
	    g.drawLine(90, 340, 90, 343);   
	    g.drawString("50", 110, 355);
	    g.drawLine(110, 340, 110, 346); 
	    g.drawLine(130, 340, 130, 343);
	    g.drawLine(150, 340, 150, 343);
	    g.drawLine(170, 340, 170, 343);
	    g.drawLine(190, 340, 190, 343); 
	    g.drawString("100", 210, 355);
	    g.drawLine(210, 340, 210, 346);
	    g.drawLine(230, 340, 230, 343);
	    g.drawLine(250, 340, 250, 343);
	    g.drawLine(270, 340, 270, 343);
	    g.drawLine(290, 340, 290, 343);  
	    g.drawString("150", 310, 355);
	    g.drawLine(310, 340, 310, 346);
	    g.drawLine(330, 340, 330, 343);
	    g.drawLine(350, 340, 350, 343);
	    g.drawLine(370, 340, 370, 343);
	    g.drawLine(390, 340, 390, 343);
	    g.drawString("200", 410, 355);
	    g.drawLine(410, 340, 410, 346);
	    g.drawLine(430, 340, 430, 343);
	    g.drawLine(450, 340, 450, 343);
	    g.drawLine(470, 340, 470, 343);
	    g.drawLine(490, 340, 490, 343);    
	    g.drawString("250", 510, 355);
	    g.drawLine(510, 340, 510, 346);
	    g.drawLine(530, 340, 530, 343);
	    g.drawLine(550, 340, 550, 343);
	    g.drawLine(570, 340, 570, 343);
	    g.drawLine(590, 340, 590, 343);  
	    g.drawString("300", 610, 355);
	    g.drawLine(610, 340, 610, 346);   
	    for (int i = 0; i < cal.oblique_frequency.size(); i ++)
	    {
		double aux = 600.0 / 300.0 * 
		    ((Double)cal.oblique_frequency.elementAt(i)).doubleValue();
		int x = 10 + (int) aux;
		g.drawLine(x, 310, x, 340);
	    }
	}
    }/* method drawObliqueGraph */
 
    private double max;
    private double min;
    private CalculateFrequency cal = null;
}/* class DrawGraph */

