// created: 2.1.01
// modified: 

import javax.swing.*;
import java.awt.*;

class InfoPanel extends JPanel
 {
  
 JLabel nameLabel;
 JLabel locLabel;
 JLabel textLabel;
 JLabel imagesLabel;
 JLabel tablesLabel;
 JLabel linksLabel;
 JLabel downloadsLabel;
 JLabel otherDownloadsLabel;
 JLabel imageDownloadsLabel;
 JLabel soundDownloadsLabel;
 JLabel videoDownloadsLabel;
 JLabel framesLabel;
 JLabel extensionLabel;

 InfoPanel(WebPage page)
  {
  if (page.isParsed())  // set all information
   { 
   nameLabel = new JLabel(" name:  "+page.getName()+" ");
   locLabel = new JLabel(" location:  \""+page.getLocation()+"\" ");
   locLabel.setPreferredSize(new Dimension(400,0));
   textLabel = new JLabel(" # text:  "+String.valueOf(page.getAmountText())+" ");
   imagesLabel = new JLabel(" # images:  "+String.valueOf(page.getNumImages())+" ");
   tablesLabel = new JLabel(" # tables:  "+String.valueOf(page.getNumTables())+" ");
   linksLabel = new JLabel(" # links:  "+String.valueOf(page.getNumLinks())+" ");
   downloadsLabel = new JLabel(" total # downloads:  "+String.valueOf(page.getNumDownloads())+" ");
   otherDownloadsLabel = new JLabel(" # other downloads:  "+String.valueOf(page.getNumOtherDownloads())+" ");
   imageDownloadsLabel = new JLabel(" # image downloads:  "+String.valueOf(page.getNumImageDownloads())+" ");
   soundDownloadsLabel = new JLabel(" # sound downloads:  "+String.valueOf(page.getNumSoundDownloads())+" ");
   videoDownloadsLabel = new JLabel(" # video downloads:  "+String.valueOf(page.getNumVideoDownloads())+" ");
   if (page.hasFrames())
    framesLabel = new JLabel(" frames:  yes ");
   else
    framesLabel = new JLabel(" frames:  no ");
   extensionLabel = new JLabel(" extension:  "+page.getExtension()+" ");
   }
  else  // set as unknown
   {
   nameLabel = new JLabel(" name:  unknown ");
   locLabel = new JLabel(" location:  \""+page.getLocation()+"\" ");
//   locLabel.setPreferredSize(new Dimension(400,0));
   textLabel = new JLabel(" # text:  unknown ");
   imagesLabel = new JLabel(" # images:  unknown ");
   tablesLabel = new JLabel(" # tables:  unknown ");
   linksLabel = new JLabel(" # links:  unknown ");
   downloadsLabel = new JLabel(" total # downloads:  unknown ");
   otherDownloadsLabel = new JLabel(" # other downloads:  unknown ");
   imageDownloadsLabel = new JLabel(" # image downloads:  unknown ");
   soundDownloadsLabel = new JLabel(" # sound downloads:  unknown ");
   videoDownloadsLabel = new JLabel(" # video downloads:  unknown ");
   framesLabel = new JLabel(" frames:  unknown ");
   extensionLabel = new JLabel(" extension:  "+page.getExtension()+" ");
   }

  // set the layout  
  JPanel leftPanel = new JPanel();
  leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));
  JPanel rightPanel = new JPanel();
  rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));

  GridBagLayout gridbag = new GridBagLayout();
  this.setLayout(gridbag);
  GridBagConstraints c = new GridBagConstraints();
  c.anchor = GridBagConstraints.WEST;
  c.gridx = 0;
  c.gridy = 0;
  c.gridwidth = 2;
  gridbag.setConstraints(locLabel,c);
  c.gridx = 0;
  c.gridy = 1;
  c.gridwidth = 1;
  gridbag.setConstraints(leftPanel,c);
  c.gridx = 1;
  c.gridy = 1;
  c.gridwidth = 1;
  gridbag.setConstraints(rightPanel,c); 

  // add attributes

  leftPanel.add(nameLabel);
  rightPanel.add(extensionLabel);
  leftPanel.add(textLabel);
  rightPanel.add(imagesLabel);
  leftPanel.add(tablesLabel);
  rightPanel.add(linksLabel);
  leftPanel.add(downloadsLabel);
  rightPanel.add(otherDownloadsLabel);
  leftPanel.add(imageDownloadsLabel);
  rightPanel.add(soundDownloadsLabel);
  leftPanel.add(videoDownloadsLabel); 
  rightPanel.add(framesLabel);

  add(locLabel);
  add(leftPanel);
  add(rightPanel);
  }

 }