Resources.java
资源名称:src.zip [点击查看]
上传用户:luxiaowei
上传日期:2022-06-06
资源大小:58k
文件大小:6k
源码类别:
J2ME
开发平台:
Java
- /*
- * Resources.java
- *
- * Created on April 20, 2010, 10:48 AM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
- package com.MOM.resources;
- import com.framework.DisplayManager;
- import com.framework.GTantra;
- import com.framework.Util;
- import javax.microedition.lcdui.Font;
- import javax.microedition.lcdui.Image;
- /**
- *
- * @author Tejaswi
- */
- public class Resources {
- static final int DEFAULT_IMAGE_WIDTH_RESOLUTION = 240;
- static final int DEFAULT_IMAGE_HEIGHT_RESOLUTION = 320;
- private static Resources instance;
- static byte counter;
- private Image images[];
- static final byte RESIZE_NONE = 0;
- static final byte RESIZE_ONLY_WIDTH = 1;
- static final byte RESIZE_ONLY_HEIGHT = 2;
- static final byte RESIZE_BOTH = 3;
- /** Images Ids */
- public static final ImageLoadInfo CNBC_LOGO_IMAGE = new ImageLoadInfo("CNBClogo" ,RESIZE_BOTH);
- public static final ImageLoadInfo TAB_BUTTON_OFF_IMAGE = new ImageLoadInfo("ButtonOff" ,RESIZE_BOTH);
- public static final ImageLoadInfo TAB_BUTTON_ON_IMAGE = new ImageLoadInfo("ButtonOn" ,RESIZE_BOTH);
- public static final ImageLoadInfo CNBC_LOGO_ADD_IMAGE = new ImageLoadInfo("Add" ,RESIZE_BOTH);
- public static final ImageLoadInfo HOME_ICON_ON_IMAGE = new ImageLoadInfo("HomeIconeOn" ,RESIZE_BOTH);
- public static final ImageLoadInfo HOME_ICON_OFF_IMAGE = new ImageLoadInfo("HomeIconeOff" ,RESIZE_BOTH);
- public static final ImageLoadInfo SCROLLER_ARROW_IMAGE = new ImageLoadInfo("Scroller_arrow" ,RESIZE_BOTH);
- public static final ImageLoadInfo SEARCH_ICON_IMAGE = new ImageLoadInfo("Searchicone" ,RESIZE_BOTH);
- public static final ImageLoadInfo SEARCH_BUTTON_IMAGE = new ImageLoadInfo("SerachButton" ,RESIZE_BOTH);
- public static final ImageLoadInfo RADIO_BUTTON_IMAGE = new ImageLoadInfo("RadioButton" ,RESIZE_BOTH);
- public static final ImageLoadInfo RADIO_BUTTON_ON_IMAGE = new ImageLoadInfo("RadioButtonOn" ,RESIZE_BOTH);
- /** Diffrent font declearations */
- private GTantra softKeyFont = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
- private GTantra tabButtonTitleFont = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- private GTantra lableTitleFont = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
- private GTantra buttonTextFont = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- private GTantra editControlFont = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
- private GTantra fontBlackMediumBold = new GTantra(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM);
- private GTantra fontWhiteMediumBold = new GTantra(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM);
- private GTantra fontGreenSmallPalin = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- private GTantra fontRedSmallPalin = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- private GTantra fontRightArrow = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
- private GTantra fontWhiteSmallPalin = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- private GTantra fontBlackSmallPalin = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- private GTantra fontBlueSmallPlain = new GTantra(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- /** Creates a new instance of Resources */
- public Resources() {
- }
- public synchronized static Resources getInstance()
- {
- if(instance == null)
- {
- instance = new Resources();
- instance.load();
- }
- return instance;
- }
- private void load()
- {
- images = new Image[ImageLoadInfo.counter];
- // write loading things
- softKeyFont.setColor(0);
- tabButtonTitleFont.setColor(0xffffff);
- lableTitleFont.setColor(0xffffff);
- buttonTextFont.setColor(0xffffff);
- editControlFont.setColor(0);
- fontBlackMediumBold.setColor(0);
- fontWhiteMediumBold.setColor(0xffffff);
- fontGreenSmallPalin.setColor(0x00ff00);
- fontRedSmallPalin.setColor(0xff0000);
- fontWhiteSmallPalin.setColor(0xffffff);
- fontBlackSmallPalin.setColor(0);
- fontBlueSmallPlain.setColor(0x0000ff);
- }
- public GTantra getFontGreenSmallPalin() {
- return fontGreenSmallPalin;
- }
- public GTantra getFontRedSmallPalin() {
- return fontRedSmallPalin;
- }
- public GTantra getFontWhiteMediumBold() {
- return fontWhiteMediumBold;
- }
- static Image loadResizeImage(String str , int width , int height)
- {
- try {
- int newWidth = 0 , newHeight = 0;
- Image img = Image.createImage("/"+str+".png");
- if(width == -1)
- newWidth = img.getWidth();
- else
- newWidth = (img.getWidth() * DisplayManager.getInst().getWidth()) / width;
- if(height == -1)
- newHeight = img.getHeight();
- else
- newHeight = (img.getHeight() * DisplayManager.getInst().getHeight()) / height;
- return Util.resizeImageWithTransperency(img, newWidth, newHeight);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- protected void setImage(int id, Image image)
- {
- images[id] = image;
- }
- protected Image getImage(int id)
- {
- return images[id];
- }
- public Image getImage(ImageLoadInfo id)
- {
- return id.getImage();
- }
- public GTantra getSoftKeyFont() {
- return softKeyFont;
- }
- public GTantra getTabButtonTitleFont() {
- return tabButtonTitleFont;
- }
- public GTantra getLableTitleFont() {
- return lableTitleFont;
- }
- public GTantra getButtonTextFont() {
- return buttonTextFont;
- }
- public GTantra getEditControlFont() {
- return editControlFont;
- }
- public GTantra getFontBlackMediumBold() {
- return fontBlackMediumBold;
- }
- public GTantra getFontRightArrow() {
- return fontRightArrow;
- }
- public GTantra getFontBlackSmallPalin() {
- return fontBlackSmallPalin;
- }
- public GTantra getFontWhiteSmallPalin() {
- return fontWhiteSmallPalin;
- }
- public GTantra getFontBlueSmallPlain() {
- return fontBlueSmallPlain;
- }
- }