import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;

public class TitlePanel extends Panel {
    private static final Color bgcolor = new Color(236,236,221);
    String titulo, titulo2;
    NewGuide_State state;

    private BufferedImage greater_or_equal;

    public TitlePanel(){
            super();
            titulo="Unknown Title";
            titulo2="Unknown Title";
    }
    public TitlePanel(String titulo, String titulo2, NewGuide_State state){
            super();
            this.state = state;
            this.titulo=titulo;
            this.titulo2=titulo2;

	    getImages();	    
    }



    private void getImages() {
        // read in the 'greater_or_equal' image, because CHEERPJ does not render this
	//  symbol in any font!  (java to javascript converter)
        try {
	    BufferedImage img =
		ImageIO.read(getClass().getResource("greater_or_equal.png"));
	    int targetWidth = (int) (state.sfactor * img.getWidth());
	    int targetHeight = (int) (state.sfactor * img.getHeight());
	    greater_or_equal =
		new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
	    Graphics2D graphics2D = greater_or_equal.createGraphics();
	    graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
					RenderingHints.VALUE_INTERPOLATION_BILINEAR);
	    graphics2D.drawImage(img, 0, 0, targetWidth, targetHeight, 0, 0,
				 img.getWidth(), img.getHeight(), null);
	    graphics2D.dispose();
	} catch (IOException e) {
            e.printStackTrace();
        }
    }

    
    public void paint(Graphics g){
            FontMetrics fmetrics=g.getFontMetrics();
            
            g.setColor(Color.gray);	
            g.fillRect(0,0,getSize().width-1,getSize().height-1);
            g.setColor(Color.black);
            g.drawLine(0,getSize().height-1,getSize().width-1,getSize().height-1);
            g.drawLine(getSize().width-1,0,getSize().width-1,getSize().height-1);
            g.setColor(Color.white);
            g.drawLine(0,0,getSize().width-1,0);
            g.drawLine(0,0,0,getSize().height-1);

            g.setColor(Color.black);
            g.drawLine(5,5,getSize().width-6,5);
            g.drawLine(5,5,5,getSize().height-6);
            g.setColor(Color.white);
            g.drawLine(5,getSize().height-5,getSize().width-5,getSize().height-5);
            g.drawLine(getSize().width-5,5,getSize().width-5,getSize().height-5);

            g.setColor(bgcolor);
            g.fillRect(6,6,getSize().width-11,getSize().height-11);

            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

            g.setFont(new Font("SanSerif",Font.BOLD,state.font11));
            g.setColor(Color.black);
            g.drawString(titulo,state.s15,state.s18);
            
            g.setFont(new Font("SanSerif",Font.BOLD,state.font12));
            fmetrics=g.getFontMetrics();
            
            // CHANGE ======================================================
            g.setColor(Color.red.darker());
            //MaestroG.special4("Large Parabolic Reflector ( ","d"," \u2265 ","2 \u03bb"," )",g,
	    MaestroG.special4("Large Parabolic Reflector ( ","d"," - ","2 \u03bb"," )",g,
                    state.font12,state.s40,getSize().height - state.s8);
	    // *** BELOW IS NEW !!!
	    g.drawImage(greater_or_equal,state.s228,getSize().height-state.s8-greater_or_equal.getHeight(),this);
            //==============================================================
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }
}
