Blackberry - пользовательское поле BubbleChartField

Мне нужно разработать приложение для ежевики, которое должно отображать пузырьковую диаграмму.
Как реализовать настраиваемый элемент управления для этой цели?
спасибо.


person Community    schedule 27.07.2009    source источник


Ответы (1)


ОБНОВЛЕНИЕ: это KB Как - создать поля графика

Вы должны быть более конкретными и полными в своем вопросе ...
Ну, просто чтобы показать вам направление:

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 );
   }
}

и где-то в приложении:

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));
    }
}
person Maksym Gontar    schedule 27.07.2009