package uk.co.patrickhaston.mars;
import java.awt.Graphics;
//import java.awt.Insets;
import java.awt.Insets;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.border.BevelBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.SoftBevelBorder;

// This over-rides the standard JPanel for the Mars Application
//  It allows the creation of a standard look-and-feel for the application
//
// Version 0.901
// last updated 14 Sept 2004

public class MPanel extends JPanel 
{
  private boolean hasBorder;
  // this is used to determine whether or not this panel has a
  // decorated border
  
  public static int PLAIN = 0;
  public static int BEVEL = 1;
  
  public MPanel()
  {
    super();
    try
    {
      jbInit();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }

  }

  private void jbInit() throws Exception
  {
    hasBorder = false;
    this.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
    this.setBackground(Color.black);
    this.setForeground(Color.orange);
    //this.setMargin(new Insets(0, 0, 0, 0));
  }
/*
  public void paintBorder(Graphics g)
  {
    if( hasBorder)
    {
      // get the dimensions
      Insets insets = this.getInsets();
      int w = this.getWidth() - insets.left;// - insets.right;
      int h = this.getHeight() - insets.top;// - insets.bottom;
      // Draw the decoration
      // First draw the grey metal background
      setForeground(Color.lightGray);
      g.drawRect(0,0,w , h);
      g.drawRect(0,0,w , h);
      g.drawRect(0,0,w , h);
    }
  }
*/  
  public void showBorder(boolean visible, int type)
  {
    hasBorder = visible;
    if(visible)
    {
      if (type == PLAIN)
      {
        setBorder( new LineBorder(Color.gray, 3, false));
      }
      if (type == BEVEL)
      {
        setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.DARK_GRAY));
      }
    }
  }
  
  public boolean isBorderVisible()
  {
    return hasBorder;
  }
  
  public void pan(int direction)
  {
    // a stub to allow those widows that can handle it to over-ride
  }
  
  public void zoomIn()
  {
    // a stub to allow those widows that can handle it to over-ride
  }

   public void zoomOut()
   {
     // a stub to allow those widows that can handle it to over-ride
   }
   
  public void setPanelSize(int w, int h)
  {
    setPreferredSize(new Dimension(w,h));
  }

}
