📄 draw_kline.java
字号:
private void MakeToday5MinLine()
{
if(m_product.realData == null)
return;
KLineData today5Min[] = get5MinKLine(m_product.sCode, m_product.vBill, m_product.realData.yesterBalancePrice);
if(m_product.min5KLine == null)
{
m_kData = today5Min;
return;
}
if(today5Min.length == 0)
{
m_kData = m_product.min5KLine;
return;
}
int iMax;
for(iMax = m_product.min5KLine.length - 1; iMax >= 0; iMax--)
if(m_product.min5KLine[iMax].date / 10000L < (long)((MenuListener) (parent)).m_applet.m_iDate)
break;
iMax++;
m_kData = new KLineData[iMax + today5Min.length];
for(int i = 0; i < iMax; i++)
m_kData[i] = m_product.min5KLine[i];
for(int i = 0; i < today5Min.length; i++)
m_kData[i + iMax] = today5Min[i];
}
KLineData[] get5MinKLine(String code, Vector vBillData, float fPreClosePrice)
{
if(vBillData == null)
return new KLineData[0];
CodeTable codeTable = (CodeTable)((MenuListener) (parent)).m_applet.m_htProduct.get(code);
Vector vector = new Vector();
KLineData data = null;
int curTime = -1;
float preMoney = 0.0F;
long preAmount = 0L;
for(int i = 0; i < vBillData.size(); i++)
{
BillDataVO bill = (BillDataVO)vBillData.elementAt(i);
if(bill.curPrice > 0.0F)
{
int time = Common.GetCurrent5MinTime(bill.time);
if(time != curTime)
{
if(data != null)
{
if(data.totalAmount > 0L)
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount);
vector.addElement(data);
}
data = new KLineData();
data.date = (long)((MenuListener) (parent)).m_applet.m_iDate * 10000L + (long)(time / 100);
data.openPrice = bill.curPrice;
data.highPrice = bill.curPrice;
data.lowPrice = bill.curPrice;
data.closePrice = bill.curPrice;
data.balancePrice = bill.balancePrice;
data.reserveCount = bill.reserveCount;
data.totalAmount += bill.totalAmount - preAmount;
data.totalMoney += bill.totalMoney - (double)preMoney;
curTime = time;
} else
{
if(bill.curPrice > data.highPrice)
data.highPrice = bill.curPrice;
if(bill.curPrice < data.lowPrice)
data.lowPrice = bill.curPrice;
data.closePrice = bill.curPrice;
data.balancePrice = bill.balancePrice;
data.reserveCount = bill.reserveCount;
data.totalAmount += bill.totalAmount - preAmount;
data.totalMoney += bill.totalMoney - (double)preMoney;
}
preAmount = bill.totalAmount;
preMoney = (float)bill.totalMoney;
}
}
if(data != null)
{
if(data.totalAmount > 0L)
if(codeTable != null)
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount / (double)codeTable.fUnit);
else
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount);
vector.addElement(data);
}
KLineData dataList[] = new KLineData[0];
if(vector.size() > 0)
{
TradeTimeVO timeRange[] = Common.getTimeRange(code, ((MenuListener) (parent)).m_applet);
int totalMin = TradeTimeVO.GetIndexFromTime(((MenuListener) (parent)).m_applet.m_iTime / 100, timeRange);
int iLen = totalMin / 5;
if(totalMin % 5 > 0)
iLen++;
dataList = new KLineData[iLen];
int iCur = 0;
for(int i = 0; i < iLen; i++)
{
int hhmm = TradeTimeVO.GetTimeFromIndex(i * 5 + 4, timeRange);
long cTime = (long)((MenuListener) (parent)).m_applet.m_iDate * 10000L + (long)hhmm;
if(iCur < vector.size())
{
data = (KLineData)vector.elementAt(iCur);
if(cTime == data.date)
{
dataList[i] = data;
iCur++;
continue;
}
}
dataList[i] = new KLineData();
dataList[i].date = cTime;
if(i == 0)
{
dataList[i].balancePrice = fPreClosePrice;
dataList[i].openPrice = dataList[i].highPrice = dataList[i].lowPrice = dataList[i].closePrice = fPreClosePrice;
dataList[i].reserveCount = 0;
dataList[i].totalAmount = 0L;
dataList[i].totalMoney = 0.0D;
} else
{
dataList[i].balancePrice = dataList[i - 1].balancePrice;
dataList[i].openPrice = dataList[i].highPrice = dataList[i].lowPrice = dataList[i].closePrice = dataList[i - 1].closePrice;
dataList[i].reserveCount = dataList[i - 1].reserveCount;
dataList[i].totalAmount = 0L;
dataList[i].totalMoney = 0.0D;
}
}
}
return dataList;
}
private void MakeWeek()
{
CodeTable codeTable = (CodeTable)((MenuListener) (parent)).m_applet.m_htProduct.get(m_product.sCode);
Vector vector = new Vector();
KLineData data = null;
for(int i = 0; i < m_kData.length; i++)
{
boolean bNewWeek;
if(data != null)
{
Calendar c1 = Calendar.getInstance();
c1.set((int)data.date / 10000, ((int)data.date / 100) % 100 - 1, (int)data.date % 100);
int iWeek1 = c1.get(7);
Calendar c2 = Calendar.getInstance();
c2.set((int)m_kData[i].date / 10000, ((int)m_kData[i].date / 100) % 100 - 1, (int)m_kData[i].date % 100);
int iWeek2 = c2.get(7);
if(iWeek1 >= iWeek2)
{
bNewWeek = true;
} else
{
c1.add(5, 7);
if(c1.before(c2))
bNewWeek = true;
else
bNewWeek = false;
}
} else
{
bNewWeek = true;
}
if(bNewWeek)
{
if(data != null)
{
if(data.totalAmount > 0L)
if(codeTable != null)
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount / (double)codeTable.fUnit);
else
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount);
vector.addElement(data);
}
data = new KLineData();
data.closePrice = m_kData[i].closePrice;
data.date = m_kData[i].date;
data.highPrice = m_kData[i].highPrice;
data.lowPrice = m_kData[i].lowPrice;
data.openPrice = m_kData[i].openPrice;
data.balancePrice = m_kData[i].balancePrice;
data.totalAmount = m_kData[i].totalAmount;
data.totalMoney = m_kData[i].totalMoney;
data.reserveCount = m_kData[i].reserveCount;
} else
{
data.date = m_kData[i].date;
if(m_kData[i].highPrice > data.highPrice)
data.highPrice = m_kData[i].highPrice;
if(m_kData[i].lowPrice < data.lowPrice)
data.lowPrice = m_kData[i].lowPrice;
data.closePrice = m_kData[i].closePrice;
data.balancePrice = m_kData[i].balancePrice;
data.totalAmount += m_kData[i].totalAmount;
data.totalMoney += m_kData[i].totalMoney;
data.reserveCount = m_kData[i].reserveCount;
}
}
if(data != null)
{
if(data.totalAmount > 0L)
if(codeTable != null)
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount / (double)codeTable.fUnit);
else
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount);
vector.addElement(data);
}
m_kData = new KLineData[vector.size()];
for(int i = 0; i < vector.size(); i++)
m_kData[i] = (KLineData)vector.elementAt(i);
}
private void MakeMonth()
{
Vector vector = new Vector();
KLineData data = null;
int iCurMonth = -1;
CodeTable codeTable = (CodeTable)((MenuListener) (parent)).m_applet.m_htProduct.get(m_product.sCode);
for(int i = 0; i < m_kData.length; i++)
{
int iMonth = (int)m_kData[i].date / 100;
if(iMonth != iCurMonth)
{
if(data != null)
{
if(data.totalAmount > 0L)
if(codeTable != null)
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount / (double)codeTable.fUnit);
else
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount);
vector.addElement(data);
}
data = new KLineData();
data.closePrice = m_kData[i].closePrice;
data.highPrice = m_kData[i].highPrice;
data.lowPrice = m_kData[i].lowPrice;
data.openPrice = m_kData[i].openPrice;
data.balancePrice = m_kData[i].balancePrice;
data.totalAmount = m_kData[i].totalAmount;
data.totalMoney = m_kData[i].totalMoney;
data.reserveCount = m_kData[i].reserveCount;
data.date = iMonth * 100;
iCurMonth = iMonth;
} else
{
if(m_kData[i].highPrice > data.highPrice)
data.highPrice = m_kData[i].highPrice;
if(m_kData[i].lowPrice < data.lowPrice)
data.lowPrice = m_kData[i].lowPrice;
data.closePrice = m_kData[i].closePrice;
data.balancePrice = m_kData[i].balancePrice;
data.totalAmount += m_kData[i].totalAmount;
data.totalMoney += m_kData[i].totalMoney;
data.reserveCount = m_kData[i].reserveCount;
}
}
if(data != null)
{
if(data.totalAmount > 0L)
if(codeTable != null)
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount / (double)codeTable.fUnit);
else
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount);
vector.addElement(data);
}
m_kData = new KLineData[vector.size()];
for(int i = 0; i < vector.size(); i++)
m_kData[i] = (KLineData)vector.elementAt(i);
}
private void MakeMinCycle(int iMin)
{
Vector vector = new Vector();
KLineData data = null;
long curDate = -1L;
CodeTable codeTable = (CodeTable)((MenuListener) (parent)).m_applet.m_htProduct.get(m_product.sCode);
for(int i = 0; i < m_kData.length; i++)
{
long date = GetCurrentDateTime(m_kData[i].date, iMin);
if(date != curDate)
{
if(data != null)
{
if(data.totalAmount > 0L)
if(codeTable != null)
data.balancePrice = (float)(data.totalMoney / (double)data.totalAmount / (double)codeTable.fUnit);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -