?? kline.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: KLine.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 KLine extends IndicatorBase
{
public static final int LineType_K = 0;
public static final int LineType_USA = 1;
public static final int LineType_POLY = 2;
int m_iLineType;
public KLine(IndicatorPos pos, int iLineType, int Precision)
{
super(pos, Precision);
m_strIndicatorName = "KLine";
m_iLineType = iLineType;
}
public void Paint(Graphics g, Rectangle rc, KLineData data[])
{
super.Paint(g, rc, data);
GetMaxMin();
DrawCoordinate(g, m_iPrecision);
switch(m_iLineType)
{
case 2: // '\002'
DrawPolyLine(g);
break;
case 1: // '\001'
drawUSA(g);
break;
default:
DrawKLine(g);
break;
}
}
public void Calculate()
{
}
protected void GetMaxMin()
{
if(m_pos.m_Begin > m_pos.m_End)
{
m_max = 0.0F;
m_min = 0.0F;
return;
}
m_max = 0.0F;
m_min = 1E+008F;
for(int i = m_pos.m_Begin; i <= m_pos.m_End; i++)
if(m_iLineType == 0 || m_iLineType == 1)
{
if(m_kData[i].highPrice > 0.0F)
{
if(m_kData[i].highPrice > m_max)
m_max = m_kData[i].highPrice;
if(m_kData[i].lowPrice < m_min)
m_min = m_kData[i].lowPrice;
}
} else
if(m_kData[i].closePrice > 0.0F)
{
if(m_kData[i].closePrice > m_max)
m_max = m_kData[i].closePrice;
if(m_kData[i].closePrice < m_min)
m_min = m_kData[i].closePrice;
}
}
private void DrawKLine(Graphics g)
{
int begin = m_pos.m_Begin;
int end = m_pos.m_End;
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 = begin; i <= end; i++)
{
int open = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].openPrice) / valuey);
int high = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].highPrice) / valuey);
int low = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].lowPrice) / valuey);
int close = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].closePrice) / valuey);
if(m_kData[i].openPrice == m_kData[i].closePrice)
{
g.setColor(HQApplet.rhColor.clKLineEqual);
g.drawLine((int)valuex - width, open, (int)valuex + width, close);
g.drawLine((int)valuex, high, (int)valuex, low);
} else
if(m_kData[i].openPrice > m_kData[i].closePrice)
{
g.setColor(HQApplet.rhColor.clKLineDown);
g.drawLine((int)valuex, high, (int)valuex, low);
g.fillRect((int)valuex - width, open, 2 * width + 1, close - open);
} else
{
g.setColor(HQApplet.rhColor.clKLineUp);
g.drawLine((int)valuex, high, (int)valuex, close);
g.drawLine((int)valuex, open, (int)valuex, low);
g.drawRect((int)valuex - width, close, 2 * width, open - close);
}
valuex += m_pos.m_Ratio;
}
}
private void drawUSA(Graphics g)
{
int begin = m_pos.m_Begin;
int end = m_pos.m_End;
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 = begin; i <= end; i++)
{
int open = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].openPrice) / valuey);
int high = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].highPrice) / valuey);
int low = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].lowPrice) / valuey);
int close = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].closePrice) / valuey);
g.setColor(HQApplet.rhColor.clUSALine);
g.drawLine((int)valuex, high, (int)valuex, low);
g.drawLine((int)valuex - width, open, (int)valuex, open);
g.drawLine((int)valuex + width + 1, close, (int)valuex, close);
valuex += m_pos.m_Ratio;
}
}
private void DrawPolyLine(Graphics g)
{
int begin = m_pos.m_Begin;
int end = m_pos.m_End;
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);
g.setColor(HQApplet.rhColor.clPolyLine);
int oldx = -1;
int oldy = -1;
for(int i = begin; i <= end; i++)
{
int close = m_rc.y + m_iTextH + (int)((m_max - m_kData[i].closePrice) / valuey);
if(oldx != -1 && oldy != -1)
{
g.drawLine(oldx, oldy, (int)valuex, close);
if((float)(oldy - close) > valuex - (float)oldx)
{
g.drawLine(oldx - 1, oldy, (int)valuex - 1, close);
g.drawLine(oldx + 1, oldy, (int)valuex + 1, close);
} else
if((float)(close - oldy) > valuex - (float)oldx)
{
g.drawLine(oldx - 1, oldy, (int)valuex - 1, close);
g.drawLine(oldx + 1, oldy, (int)valuex + 1, close);
} else
{
g.drawLine(oldx, oldy - 1, (int)valuex, close - 1);
g.drawLine(oldx, oldy + 1, (int)valuex, close + 1);
}
}
oldx = (int)valuex;
oldy = close;
valuex += m_pos.m_Ratio;
}
}
public void DrawCursor(Graphics g, int iPos)
{
int iIndex = m_pos.m_Begin + iPos;
int y = (int)((float)(m_rc.y + m_iTextH) + ((m_max - m_kData[iIndex].closePrice) * (float)(m_rc.height - m_iTextH)) / (m_max - m_min));
g.drawLine(m_rc.x, y, m_rc.x + m_rc.width, y);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -