import java.awt.Point;
import java.awt.Cursor;
import java.awt.Toolkit;

import java.net.URL;

import java.util.Hashtable;

import javax.swing.ImageIcon;


public class ProyectoProperties
{
  static public String baseAddress;
  static private Properties properties;
  static public Hashtable cursors = new Hashtable();
  static public Hashtable simpleImages = new Hashtable();
  static public Hashtable complexImages = new Hashtable();


  public static void read() throws Exception
  {
    properties = new Properties("resources.Proyecto");

    int i;
    String str[];

    str = properties.getStrings("simpleImages");
    for(i = 0; i < str.length; i++)
      simpleImages.put(str[i], new ImageIcon(properties.getResource(str[i] + "Image")));

    str = properties.getStrings("complexImages");
    for(i = 0; i < str.length; i++) {
      complexImages.put(str[i], new ImageIcon(properties.getResource(str[i] + "Image")));
      complexImages.put(str[i] + "Over", new ImageIcon(properties.getResource(str[i] + "OverImage")));
      complexImages.put(str[i] + "Pressed", new ImageIcon(properties.getResource(str[i] + "PressedImage")));
      complexImages.put(str[i] + "Disabled", new ImageIcon(properties.getResource(str[i] + "DisabledImage")));
      complexImages.put(str[i] + "Label", properties.getString(str[i] + "Label"));
    }

    str = properties.getStrings("cursors");
    for(i = 0; i < str.length; i++) {
      ImageIcon imageIcon = new ImageIcon(properties.getResource(str[i] + "Image"));
      Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
        imageIcon.getImage(),
        new Point(
          Integer.parseInt(properties.getString(str[i] + "HotSpotX")),
          Integer.parseInt(properties.getString(str[i] + "HotSpotY"))
        ),
        str[i] + "Cursor"
      );
      cursors.put(str[i], cursor);
    }
  }

  public static String getString(String nm)
  {
    return properties.getString(nm);
  }

  public static String[] getStrings(String nm)
  {
    return properties.getStrings(nm);
  }

  public static URL getResource(String key)
  {
    return properties.getResource(key);
  }
}
