?? vol.java
字號:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: VOL.java
package gnnt.MEBS.HQApplet.Indicator;
import gnnt.MEBS.HQApplet.*;
import java.awt.Graphics;
import java.awt.Rectangle;
// Referenced classes of package gnnt.MEBS.HQApplet.Indicator:
// IndicatorBase, IndicatorPos
public class VOL extends IndicatorBase
{
private final int m_iParam[] = {
5, 10
};
public VOL(IndicatorPos pos, int Precision)
{
super(pos, Precision);
m_strIndicatorName = "VOL";
m_iPrecision = 0;
m_strParamName = new String[m_iParam.length];
for(int i = 0; i < m_iParam.length; i++)
m_strParamName[i] = "MA" + m_iParam[i];
}
public void Paint(Graphics g, Rectangle rc, KLineData data[])
{
super.Paint(g, rc, data);
Calculate();
GetMaxMin();
for(int i = 0; i < m_iParam.length; i++)
GetValueMaxMin(m_data[i], m_iParam[i] - 1);
DrawCoordinate(g, 0);
DrawVolume(g);
for(int i = 0; i < m_iParam.length; i++)
DrawLine(g, m_data[i], m_iParam[i] - 1, HQApplet.rhColor.clIndicator[i]);
}
public void Calculate()
{
m_data = new float[m_iParam.length][];
for(int i = 0; i < m_iParam.length; i++)
AverageVolume(i);
m_data = new float[m_iParam.length][];
for(int i = 0; i < m_iParam.length; i++)
AverageVolume(i);
}
private void GetMaxMin()
{
m_max = 0.0F;
m_min = 0.0F;
for(int i = m_pos.m_Begin; i <= m_pos.m_End; i++)
if((float)m_kData[i].totalAmount > m_max)
m_max = m_kData[i].totalAmount;
}
private void DrawVolume(Graphics g)
{
if(m_max - m_min == 0.0F || m_rc.height - m_iTextH <= 0)
return;
int width = m_pos.m_Ratio >= 3F ? (int)((m_pos.m_Ratio + 1.0F) / 3F) : 0;
if(width % 2 == 0 && width > 0)
width--;
float valuex = (float)m_rc.x + m_pos.m_Ratio / 2.0F;
float valuey = (m_max - m_min) / (float)(m_rc.height - m_iTextH);
for(int i = m_pos.m_Begin; i <= m_pos.m_End; i++)
{
int value = m_rc.y + m_iTextH + (int)((m_max - (float)m_kData[i].totalAmount) / valuey);
if(m_kData[i].openPrice > m_kData[i].closePrice)
{
g.setColor(HQApplet.rhColor.clKLineDown);
g.fillRect((int)valuex - width, value, 2 * width + 1, (m_rc.y + m_rc.height) - value - 1);
} else
if(m_kData[i].openPrice < m_kData[i].closePrice)
{
g.setColor(HQApplet.rhColor.clKLineUp);
g.drawRect((int)valuex - width, value, 2 * width, (m_rc.y + m_rc.height) - value - 1);
} else
{
g.setColor(HQApplet.rhColor.clKLineEqual);
g.drawRect((int)valuex - width, value, 2 * width, (m_rc.y + m_rc.height) - value - 1);
}
valuex += m_pos.m_Ratio;
}
}
private void AverageVolume(int iIndex)
{
if(m_kData == null || m_kData.length == 0)
return;
int n = m_iParam[iIndex];
if(n > m_kData.length || n < 1)
return;
m_data[iIndex] = new float[m_kData.length];
float data[] = m_data[iIndex];
float prevolume = 0.0F;
double sum = 0.0D;
for(int i = 0; i < n - 1; i++)
sum += m_kData[i].totalAmount;
for(int i = n - 1; i < m_kData.length; i++)
{
sum -= prevolume;
sum += m_kData[i].totalAmount;
data[i] = (float)(sum / (double)n);
prevolume = m_kData[(i - n) + 1].totalAmount;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -