//***************************************************************************************************************************************************
//
// Copyright (C) 2020 Selim Temizer.
//
// This file is part of COVID-19.
//
// COVID-19 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
//
// COVID-19 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with COVID-19. If not, see <http://www.gnu.org/licenses/>.
//
//***************************************************************************************************************************************************




//***************************************************************************************************************************************************

import java.net.URI          ;
import java.awt.Desktop      ;
import javax.swing.JFrame    ;
import javax.swing.ImageIcon ;

//***************************************************************************************************************************************************




//***************************************************************************************************************************************************

public class GuiInfo extends JFrame
{
  //=================================================================================================================================================

  private static final long serialVersionUID = -1432098453975817230L ;

  //=================================================================================================================================================

  public GuiInfo ( String version )
  {
    initComponents() ;

    ImageIcon icon = new ImageIcon( getClass().getResource( "/media/favicon.png" ) ) ;    setIconImage( icon.getImage() ) ;

    lImage.setIcon( Utilities.getRandomVirusIcon() ) ;
    lText .setText( "<html>"                                                             +
                    " <b>COVID-19 Status</b> &nbsp; " + version                 + "<br>" +
                    " by Selim Temizer"                                         + "<br>" +
                    " <a href=\"http://selimtemizer.com\">selimtemizer.com</a>" + "<br>" +
                    ""                                                          + "<br>" +
                    " Fetching data, please wait..."                                     ) ;
  }

  //=================================================================================================================================================

  /**
   * This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings( "unchecked" )
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents()
  {

    lText = new javax.swing.JLabel();
    lImage = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Wait");
    setLocationByPlatform(true);
    setResizable(false);

    lText.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lText.setText("<html> <b>COVID-19 Status</b> &nbsp; v1.00<br> by Selim Temizer<br> <a href=\"http://selimtemizer.com\">selimtemizer.com</a><br> <br> Fetching data, please wait...");
    lText.addMouseListener(new java.awt.event.MouseAdapter()
    {
      public void mouseClicked(java.awt.event.MouseEvent evt)
      {
        lTextMouseClicked(evt);
      }
    });

    lImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/media/CoronaVirus3.png"))); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(lImage)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(lText, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(lImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(lText))
        .addContainerGap())
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

  private void lTextMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_lTextMouseClicked
  {//GEN-HEADEREND:event_lTextMouseClicked
    try
    {
      Desktop desktop = Desktop.getDesktop()                 ;
      URI     uri     = new URI( "http://selimtemizer.com" ) ;

      desktop.browse( uri ) ;
    }
    catch ( Exception e )  { /* Do nothing */ }
  }//GEN-LAST:event_lTextMouseClicked

  /**
   * @param args the command line arguments
   */
  public static void test_main ( String args[] )
  {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try
    {
      for ( javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels() )
      {
        if ( "Windows".equals( info.getName() ) )
        {
          javax.swing.UIManager.setLookAndFeel( info.getClassName() );
          break;
        }
      }
    }
    catch ( ClassNotFoundException ex )
    {
      java.util.logging.Logger.getLogger( GuiInfo.class.getName() ).log( java.util.logging.Level.SEVERE , null , ex );
    }
    catch ( InstantiationException ex )
    {
      java.util.logging.Logger.getLogger( GuiInfo.class.getName() ).log( java.util.logging.Level.SEVERE , null , ex );
    }
    catch ( IllegalAccessException ex )
    {
      java.util.logging.Logger.getLogger( GuiInfo.class.getName() ).log( java.util.logging.Level.SEVERE , null , ex );
    }
    catch ( javax.swing.UnsupportedLookAndFeelException ex )
    {
      java.util.logging.Logger.getLogger( GuiInfo.class.getName() ).log( java.util.logging.Level.SEVERE , null , ex );
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater( new Runnable()
    {
      @Override public void run ()
      {
        new GuiInfo( "v1.00" ).setVisible( true ) ;
      }
    } ) ;
  }

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JLabel lImage;
  private javax.swing.JLabel lText;
  // End of variables declaration//GEN-END:variables
}

//***************************************************************************************************************************************************