Package com.ribomation.droidAtScreen.gui

Source Code of com.ribomation.droidAtScreen.gui.SkinUtil

package com.ribomation.droidAtScreen.gui;

import java.awt.Point;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.swing.ImageIcon;

import com.ribomation.droidAtScreen.Skin;

public class SkinUtil {

  public static Skin loadSkin(String skinName) {
    // create and load default properties
    Properties skinProperties = new Properties();
    InputStream in = null;
    ImageIcon skinImage = null;
    try {
      in = SkinUtil.class.getResourceAsStream("/skins/" + skinName + "/frame.cfg");
      skinProperties.load(in);
      skinImage = GuiUtil.loadSkin(skinName);
    } catch (Exception ignore) {
    } finally {
      try {
        if (in != null) {
          in.close();
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    if (skinImage == null) {
      return null;
    }

    Skin skin = new Skin();
    skin.setFrame(skinImage);
    String property = skinProperties.getProperty("screen.x");
    int x = property == null ? 0 : Integer.parseInt(property);
    property = skinProperties.getProperty("screen.y");
    int y = property == null ? 0 : Integer.parseInt(property);
    skin.setScreenXYCoord(new Point(x, y));
    return skin;
  }
}
TOP

Related Classes of com.ribomation.droidAtScreen.gui.SkinUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.