曾有人给了一个例子:
////////////////////////////////////////////////////////////////////////
// drawKLine
// Function : 绘制 K 线
// Argument : g , width , pDayData , start , end
// g , Graphics
// width , 宽度
// pDayData , 逻辑值
// start , 数组开始索引
// end , 数组结束索引
// Return : no
////////////////////////////////////////////////////////////////////////
public void drawKLine(Graphics g, int width, DayLine pDayData, int start, int end )
{
try
{
if( m_boxRect == null ¦¦ pDayData == null)
return; // end - start;
// len ++ ; if( start >= end ¦¦ start < 0 )
return; if( end >= pDayData.m_point .length )
end = pDayData.m_point.length -1 ; boolean bIsUp = true;
// g.setColor(PublicClass.m_FixTextColor);
// CRect crect = new CRect(); int x[] = horiAxis.getScrValuesBySeralInteger( start, end ); Rectangle rect = new Rectangle() ;
int rHalfWidth = width/2 ; for(int i = start ; i <= end ; i++)
{
rect.x = x[ i-start ] - rHalfWidth ;
rect.width = 2*rHalfWidth ; if(pDayData.m_point[i].m_nOpenPrice <= pDayData.m_point[i].m_nClosePrice)
{
// 上涨
rect.y = vertAxis.getScrValue( pDayData.m_point[i].m_nClosePrice );
rect.height = vertAxis.getScrValue( pDayData.m_point[i].m_nOpenPrice);
g.setColor( Resource.COLOR_UPCOLOR );
bIsUp = true ;
}
else
{
// 下跌
rect.y = vertAxis.getScrValue( pDayData.m_point[i].m_nOpenPrice);
rect.height = vertAxis.getScrValue( pDayData.m_point[i].m_nClosePrice );
g.setColor( Resource.COLOR_DOWNCOLOR );
bIsUp = false ;
} rect.height -=rect.y; int iScrMaxPrice = vertAxis.getScrValue( pDayData.m_point[i].m_nHighPrice );
int iScrMinPrice = vertAxis.getScrValue( pDayData.m_point[i].m_nLowPrice) + 1; g.drawLine( x[i-start], iScrMaxPrice, x[i-start], rect.y );
g.drawLine( x[i-start], rect.y+rect.height , x[i-start], iScrMinPrice); if(! bIsUp )
if( rect.width <=0 ¦¦ rect.height <=0 )
g.drawLine( rect.x, rect.y, rect.x+rect.width, rect.y+rect.height );
else
g.fillRect( rect.x , rect.y, rect.width + 1, rect.height ); else // 上涨
if( rect.width <=0 ¦¦ rect.height <=0 )
g.drawLine( rect.x, rect.y, rect.x+rect.width, rect.y+rect.height );
else
{
//g.setColor(Color.black);
//g.fillRect( rect.x, rect.y, rect.width, rect.height );
//g.setColor(PublicClass.m_UpColor);
g.drawRect( rect.x, rect.y, rect.width, rect.height );
}
} return;
}
catch(NullPointerException _ex)
{
return;
}
}但我编译时出现了E:\javatest\DrawLineTest.java:13: 期望class或interface
public void drawKLine(Graphics g, int width, DayLine pDayData, int start, int end )
^
1 个错误
Process completed with exit code 1
请问有什么办法解决?
////////////////////////////////////////////////////////////////////////
// drawKLine
// Function : 绘制 K 线
// Argument : g , width , pDayData , start , end
// g , Graphics
// width , 宽度
// pDayData , 逻辑值
// start , 数组开始索引
// end , 数组结束索引
// Return : no
////////////////////////////////////////////////////////////////////////
public void drawKLine(Graphics g, int width, DayLine pDayData, int start, int end )
{
try
{
if( m_boxRect == null ¦¦ pDayData == null)
return; // end - start;
// len ++ ; if( start >= end ¦¦ start < 0 )
return; if( end >= pDayData.m_point .length )
end = pDayData.m_point.length -1 ; boolean bIsUp = true;
// g.setColor(PublicClass.m_FixTextColor);
// CRect crect = new CRect(); int x[] = horiAxis.getScrValuesBySeralInteger( start, end ); Rectangle rect = new Rectangle() ;
int rHalfWidth = width/2 ; for(int i = start ; i <= end ; i++)
{
rect.x = x[ i-start ] - rHalfWidth ;
rect.width = 2*rHalfWidth ; if(pDayData.m_point[i].m_nOpenPrice <= pDayData.m_point[i].m_nClosePrice)
{
// 上涨
rect.y = vertAxis.getScrValue( pDayData.m_point[i].m_nClosePrice );
rect.height = vertAxis.getScrValue( pDayData.m_point[i].m_nOpenPrice);
g.setColor( Resource.COLOR_UPCOLOR );
bIsUp = true ;
}
else
{
// 下跌
rect.y = vertAxis.getScrValue( pDayData.m_point[i].m_nOpenPrice);
rect.height = vertAxis.getScrValue( pDayData.m_point[i].m_nClosePrice );
g.setColor( Resource.COLOR_DOWNCOLOR );
bIsUp = false ;
} rect.height -=rect.y; int iScrMaxPrice = vertAxis.getScrValue( pDayData.m_point[i].m_nHighPrice );
int iScrMinPrice = vertAxis.getScrValue( pDayData.m_point[i].m_nLowPrice) + 1; g.drawLine( x[i-start], iScrMaxPrice, x[i-start], rect.y );
g.drawLine( x[i-start], rect.y+rect.height , x[i-start], iScrMinPrice); if(! bIsUp )
if( rect.width <=0 ¦¦ rect.height <=0 )
g.drawLine( rect.x, rect.y, rect.x+rect.width, rect.y+rect.height );
else
g.fillRect( rect.x , rect.y, rect.width + 1, rect.height ); else // 上涨
if( rect.width <=0 ¦¦ rect.height <=0 )
g.drawLine( rect.x, rect.y, rect.x+rect.width, rect.y+rect.height );
else
{
//g.setColor(Color.black);
//g.fillRect( rect.x, rect.y, rect.width, rect.height );
//g.setColor(PublicClass.m_UpColor);
g.drawRect( rect.x, rect.y, rect.width, rect.height );
}
} return;
}
catch(NullPointerException _ex)
{
return;
}
}但我编译时出现了E:\javatest\DrawLineTest.java:13: 期望class或interface
public void drawKLine(Graphics g, int width, DayLine pDayData, int start, int end )
^
1 个错误
Process completed with exit code 1
请问有什么办法解决?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货