User interface 黑莓-自定义BubbleChartField
我需要开发一个黑莓应用程序,该应用程序应该显示气泡图。User interface 黑莓-自定义BubbleChartField,user-interface,blackberry,charts,custom-controls,User Interface,Blackberry,Charts,Custom Controls,我需要开发一个黑莓应用程序,该应用程序应该显示气泡图。 如何为此实现自定义控件? 谢谢。更新这是知识库 你的问题应该更具体、更完整…… 好吧,我只是想告诉你方向: public class BubbleChart extends Field { int mWidth = Display.getWidth(); int mHeight = Display.getHeight(); int[] mXpos = null; int[] mYpos = null;
如何为此实现自定义控件?
谢谢。更新这是知识库 你的问题应该更具体、更完整……
好吧,我只是想告诉你方向:
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 );
}
}
更新这是知识库 你的问题应该更具体、更完整……
好吧,我只是想告诉你方向:
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 );
}
}