import java.awt.* ;
import javax.swing.* ;
import javax.swing.border.*;

public class CatenaryController extends JFrame {
    private JLabel weightLabel, yMinLabel, poleXLabel, poleYLabel, tensionLabel;
    private JTextField weightField, yMinField, poleXField, poleYField;
    private JButton calcButton, quitButton;
    private JPanel inputHolder;
    
    private JPanel fieldHolder;
    private JPanel buttonHolder;
    
    private Container contentPane;
    private ScrollPane scrollPane;     
    
    private JPanel canvas ;
    
    private CatenaryModel analysis = null;
    
    public static final int X = 900 ;   // Size of canvas (x-dimension)
    public static final int Y = 600 ;   // Size of canvas (y-dimension)

    public CatenaryController() {
        
        //Get outer pane
    	contentPane = getContentPane() ;
		setSize( X, Y + 120 ) ;           // '120' for button holder
        setTitle( "Catenary Curve" ) ;
        
        //Create scrollpane
        scrollPane = new ScrollPane();
        contentPane.add(scrollPane);
        
        //Create canvas to draw 2D graph
        canvas = new JPanel();
        canvas.setLayout(new BorderLayout());
        scrollPane.add(canvas);
        
        //Create input (input field/label/button) holder
        inputHolder = new JPanel();
        inputHolder.setLayout(new BorderLayout());
        canvas.add(inputHolder, BorderLayout.SOUTH);
        inputHolder.setBorder(new EtchedBorder());
		inputHolder.setPreferredSize(new Dimension(900, 70));
		
        //Create field (input field and labels) holder
		fieldHolder = new JPanel();
        inputHolder.add(fieldHolder, BorderLayout.NORTH);
        
        // Text field for cable weight w
        weightLabel = new JLabel( "Cable weight (N/m) =" ) ;
        fieldHolder.add( weightLabel ) ;
        weightField = new JTextField( 10 ) ;
        weightField.setText("10");
        fieldHolder.add( weightField ) ;
        
        // Text field for min elevation ymin
        yMinLabel = new JLabel( "     Min height (m)  =" ) ;
        fieldHolder.add( yMinLabel ) ;
        yMinField = new JTextField( 10 ) ;
        yMinField.setText("5");
        fieldHolder.add( yMinField ) ;
		
        // Text field for pole x
        poleXLabel = new JLabel( "     Pole x =" ) ;
        fieldHolder.add( poleXLabel ) ;
        poleXField = new JTextField( 10 ) ;
        poleXField.setText("50");
        fieldHolder.add( poleXField ) ;
        
		// Text field for pole y
		poleYLabel = new JLabel( "    Pole y =" ) ;
		fieldHolder.add( poleYLabel ) ;
		poleYField = new JTextField( 10 ) ;
		poleYField.setText("15");
		fieldHolder.add( poleYField ) ;
		
        // Create button holder
        buttonHolder = new JPanel() ;
        inputHolder.add( buttonHolder, BorderLayout.SOUTH) ;
		
        // Calculate button
        calcButton = new JButton( "Calculate" ) ;
        calcButton.setPreferredSize(new Dimension(120, 27));
        buttonHolder.add( calcButton ) ;
        
        // Quit button
        quitButton = new JButton( "Quit" ) ;
        quitButton.setPreferredSize(new java.awt.Dimension(120, 27));
        buttonHolder.add( quitButton ) ;

    }
    
    public static void main(String[] args) {
        CatenaryController application = new CatenaryController() ;
        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
        application.setResizable( false ) ;        
        application.setVisible( true ) ;   
    }

}