ShareMarketReadingControl.java
资源名称:src.zip [点击查看]
上传用户:luxiaowei
上传日期:2022-06-06
资源大小:58k
文件大小:3k
源码类别:
J2ME
开发平台:
Java
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.MOM.ui.control;
- import com.MOM.Constants;
- import com.MOM.resources.Resources;
- import com.framework.DisplayManager;
- import com.framework.GTantra;
- import com.framework.UIControl;
- import com.framework.Util;
- import javax.microedition.lcdui.Graphics;
- /**
- *
- * @author Swaroop Kumar
- */
- public class ShareMarketReadingControl extends UIControl{
- Info sensex,nifty;
- public ShareMarketReadingControl() {
- sensex = new Info("Sensex");
- nifty = new Info("Nifty");
- setHeight((Constants.TOP_PADDING << 1) + Resources.getInstance().getFontWhiteMediumBold().getFontHeight() + Resources.getInstance().getFontGreenSmallPalin().getFontHeight());
- setWidth(DisplayManager.getInst().getWidth());
- setSelectable(false);
- }
- public void setNiftyReading(String text)
- {
- nifty.reading = text;
- }
- public void setSexsexReading(String text)
- {
- sensex.reading = text;
- }
- public void setNiftyChange(String text)
- {
- nifty.chage = text;
- }
- public void setSensexChange(String text)
- {
- sensex.chage = text;
- }
- public void paint(Graphics g) {
- sensex.paint(g, 0, (width >> 1) - 1,height,Constants.TOP_PADDING);
- nifty.paint(g, (width >> 1) + 1,width >> 1,height, Constants.TOP_PADDING);
- g.setColor(0x94A5B7);
- g.fillRect(0, 0, width, 3);
- }
- class Info
- {
- String shareMarket;
- String reading;
- String chage;
- public Info(String title) {
- this.shareMarket = title;
- }
- void paint(Graphics g,int x,int width,int height,int topPadding)
- {
- g.setColor(0x002448);
- g.fillRect(x, 0, width, height);
- GTantra whiteFont = Resources.getInstance().getFontWhiteMediumBold();
- whiteFont.drawString(g, shareMarket, x + Constants.LEFT_PADDING, topPadding , GTantra.TEXT_LEFT);
- int y = whiteFont.getFontHeight();
- GTantra readingFont = Resources.getInstance().getFontGreenSmallPalin();
- int arrowColor = 0x00C846;
- readingFont.drawString(g, reading, x + Constants.LEFT_PADDING, y + topPadding , GTantra.TEXT_LEFT);
- int _x = x + Constants.LEFT_PADDING + readingFont.getStringWidth(reading) +Constants.LEFT_PADDING ;
- g.setColor(arrowColor);
- // for up
- Util.drawFilledTriangle(g, _x , y + topPadding + (readingFont.getFontHeight() >> 1) , true, readingFont.getFontHeight() >> 1, false);
- // for down
- // Util.drawFilledTriangle(g, _x , y + topPadding + (readingFont.getFontHeight() >> 1) , false, readingFont.getFontHeight() >> 1, false);
- readingFont.drawString(g, chage, _x + (readingFont.getFontHeight() >> 1) + Constants.LEFT_PADDING, y + topPadding , GTantra.TEXT_LEFT);
- }
- }
- }