2009-07-27 5 views
1

버블 차트가 표시되어야하는 블랙 베리 애플리케이션을 개발해야합니다.
이 목적을 위해 사용자 지정 컨트롤을 구현하는 방법은 무엇입니까?
감사합니다.Blackberry - custom BubbleChartField

+0

Spamtastic! ... –

답변

4

UPDATE 여기는 KB입니다 How To - Create graph fields

당신은 더 구체적이고 당신이 질문에 완전해야

...
글쎄, 당신에게 방향을 표시합니다 : 응용 프로그램에서 어딘가에

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