黑莓 - 定制BubbleChartField [英] Blackberry - custom BubbleChartField

查看:134
本文介绍了黑莓 - 定制BubbleChartField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开发一个黑莓应用程序,它应该表现出气泡图。

如何实现这一目的的自定义控制?

谢谢。

I need to develop a blackberry application which should show a bubble chart.
How to implement custom control for this purpose?
thanks.

推荐答案

更新这里是KB <一个href=\"http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/How_To_-_Create_graph_fields.html?nodeid=1889634&vernum=0\"相对=nofollow>如何 - 创建图形领域

在你的问题你应该更加具体和完整的...结果
好了,只是为了显示你的方向:

You should be more specific and complete in you question...
Well, just to show you direction:

public class BubbleChart extends Field {

    int mWidth = Display.getWidth();
    int mHeight = Display.getHeight();

    int[] mXpos = null;
    int[] mYpos = null;
    int[] mRad = null;
    int[] mColor = null;

    public BubbleChart(int[] xPos, int[] yPos, int[] rad, int[] colors) {
        this(xPos, yPos, rad);
        mColor = colors;
    }

    public BubbleChart(int[] xPos, int[] yPos, int[] rad) {
        mXpos = xPos;
        mYpos = yPos;
        mRad = rad;
    }

    public int getPreferredWidth() {
        return mWidth;
    }

    public int getPreferredHeight() {
        return mHeight;
    }

    protected void layout(int width, int height) {
        setExtent(getPreferredWidth(), getPreferredHeight());
    }

   protected void paint( Graphics graphics )
   {
       for( int i = 0, cnt = mXpos.length; i < cnt; i++ )
       {
           if( null != mColor )
               graphics.setColor( mColor[ i ] );
           else
               graphics.setColor( Color.WHITE );
           drawFilledCircle( graphics, mXpos[ i ], mYpos[ i ], mRad[ i ] );
           graphics.setColor( Color.BLACK );
           drawCircle( graphics, mXpos[ i ], mYpos[ i ], mRad[ i ] );
       }
   }

   private void drawFilledCircle( Graphics g, int x, int y, int r )
   {
       g.fillEllipse( x, y, x + r, y, x, y + r, 0, 360 );
   }

   private void drawCircle( Graphics g, int x, int y, int r )
   {
       g.drawEllipse( x, y, x + r, y, x, y + r, 0, 360 );
   }
}

和在应用程序的某个地方:

and somewhere in app:

class Scr extends MainScreen {
    public Scr() {
        int[] x = { 20, 100, 150 };
        int[] y = { 20, 100, 150 };
        int[] r = { 10, 50, 80 };
        int[] c = { Color.RED, Color.GREEN, Color.YELLOW };
        add(new BubbleChart(x, y, r, c));
    }
}

这篇关于黑莓 - 定制BubbleChartField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆