// About.java
/* A Java class for
 * Polarization.java
 * Electromagnetic Waves Applets 
 * Prepared by Umberto Ravaioli 
 * for 6th edition of Fundamentals of Applied Electromagnetics Book
 * July 2009 - All Rights Reserved
 */   


import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.util.*;

public class About extends Panel implements ActionListener{
    
    //private static final Color bgcolor = new Color(236,236,236);
    private static final Color bgcolor = Color.white;
    private static final Font labfont=new Font("SanSerif",Font.PLAIN,12);
    private static final Font symbolfont = new Font("Symbol",Font.PLAIN,12);
    private static final Font normalfont12 = new Font("SanSerif",Font.PLAIN,12);
    private static final Font normalfont14 = new Font("SanSerif",Font.PLAIN,14);
    private static final Font normalfont16 = new Font("SanSerif",Font.PLAIN,16);
    private static final Font normalfont18 = new Font("SanSerif",Font.PLAIN,18);
    private static final Font normalfont20 = new Font("SanSerif",Font.PLAIN,20);
    
    private static final Font textfont = new Font("SanSerif",Font.PLAIN,14);
    
    private static final Font font_one = new Font("Serif",Font.PLAIN,20);
    private static final Font font_two = new Font("Serif",Font.PLAIN,40);
    
    public TextField epsilon;
    private Paint paint;
    
    public Button bupdate;
    private Image im;
    private Graphics buf;
  
    public About(){
	super();
	setLayout(null);
	setBackground(bgcolor);
	
	// update button
	bupdate = new Button("CLOSE");
        bupdate.setBackground(new Color(240,240,255));
	add(bupdate);
        int buttonx = 280;
        int buttony =140;
        int buttonwide = 70;
        int buttonheight = 27;
        
        bupdate.setBounds(buttonx,buttony,buttonwide,buttonheight);	
        Panel ps7 = new Panel();
	    ps7.setBackground(Color.lightGray);
	    add(ps7);
	    ps7.setBounds(buttonx-1,buttony-1,buttonwide+2,buttonheight+2);
	    
	Panel ps8 = new Panel();
	    ps8.setBackground(Color.black);
	    add(ps8);
	    ps8.setBounds(buttonx-2,buttony-2,buttonwide+4,buttonheight+4);
	
	//Listeners
	bupdate.addActionListener(this);
    }
    
    public void paint(Graphics g){
            
	    if(im == null){
		im = createImage(getSize().width,getSize().height);
		buf = im.getGraphics();
		drawCanvas(buf);
	    }
	    else{
		drawCanvas(buf);
	    }
	    g.drawImage(im,0,0,null);
    }
	
	//Addition to reduce flicker new routine
    public void update(Graphics g){		// added to avoid clearing
            paint(g);
    }
    
    public void clear(){
	    this.getGraphics().clearRect(0,0,getSize().width,getSize().height);
	    repaint();
    }
    
    public void drawCanvas(Graphics g){
        FontMetrics fm;
        String temp_zero, temp_one, temp_two, temp_three, temp_four, temp_five, temp_six;
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
        //g.setColor(Color.white);
        //g.fillRect(0,0,getSize().width,getSize().height);
        
        g.clearRect(0,0,getSize().width-1,getSize().height-1);
        
        g.setFont(font_one);
        fm = g.getFontMetrics();
        
        int rectx = 40;
        
        g.setColor(Color.blue.darker());
        g.fillRect(rectx,34,550,54);
        
        g.setColor(Color.white);
        g.fillRect(rectx-6,28,550,54);
        
        g.setColor(Color.black);
        g.drawRect(rectx-6,28,550,54);
        
        g.setColor(Color.blue.darker());
        
        temp_three = "Fundamentals of Applied Electromagnetics  - ";
        temp_four = "Sixth Edition";
        temp_five = "";
        temp_six = "Interactive Smith Chart - version 1.0 (May 2009)";
        
        MaestroG.subscripter2types(""+temp_three,"",""+temp_four,g,18,50,60); 
        
        g.setColor(Color.red.darker());
            g.drawLine(20,220,getSize().width-20,220);
            int down = 30;
            int left = 60;
            
            g.setFont(normalfont16);
            g.drawString("Module 7.2 - Polarization - version 1.0 (July 2009)",left,260);
       
        g.setColor(Color.blue.darker());
             
            g.setFont(normalfont14);
            g.drawString("Applet Design: Umberto Ravaioli",left,260+down);
  
            MaestroG.superscripter("Interactive Java","TM"," platform:  www.amanogawa.com",g,12,left,260+2*down);
        
            g.setFont(normalfont12);
            g.drawString("All Rights Reserved",left,260+3*down);
            
        // frame of panel
        g2d.setStroke(new BasicStroke(2));
        g.drawRect(5,5,getSize().width-10,getSize().height-10);
        g2d.setStroke(new BasicStroke(1));
        
        g.setColor(Color.black);
        g.drawRect(0,0,getSize().width-1,getSize().height-1);
    }
    
    
//----------------------------------------------------------------------------------------

public void actionPerformed(ActionEvent evt){
    
    if(evt.getSource()==bupdate){
	
    }  
} 
 
//----------------------------------------------------------------------------------------    
}//End
    

