📄 draw_kline.java
字号:
case 3: // '\003'
str = ((MenuListener) (parent)).m_applet.getShowString("MonthLine");
break;
case 4: // '\004'
str = ((MenuListener) (parent)).m_applet.getShowString("5MinLine");
break;
case 5: // '\005'
str = ((MenuListener) (parent)).m_applet.getShowString("15MinLine");
break;
case 6: // '\006'
str = ((MenuListener) (parent)).m_applet.getShowString("30MinLine");
break;
case 7: // '\007'
str = ((MenuListener) (parent)).m_applet.getShowString("60MinLine");
break;
}
g.setFont(new Font("\u5B8B\u4F53", 0, 14));
FontMetrics fm = g.getFontMetrics();
int x = m_rcPane[0].x - fm.stringWidth(str) - 1;
int y = m_rcPane[0].y + fm.getAscent();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(str, x, y);
}
private boolean ChangePos(boolean bIsLeft) {
boolean bNeedRepaint = false;
if(m_kData.length == 0)
return bNeedRepaint;
if(m_iPos == -1) {
if(bIsLeft)
DrawCursor(m_pos.m_End - m_pos.m_Begin);
else
DrawCursor(0);
DrawLabel();
} else
if(bIsLeft) {
if(m_iPos == 0) {
if(m_pos.m_Begin > 0) {
m_pos.m_EndPos++;
bNeedRepaint = true;
} else {
return false;
}
} else {
DrawCursor(m_iPos - 1);
DrawLabel();
}
} else
if(m_iPos == m_pos.m_End - m_pos.m_Begin) {
if(m_pos.m_Begin < m_pos.m_MaxPos) {
bNeedRepaint = true;
m_pos.m_EndPos--;
} else {
return false;
}
} else {
DrawCursor(m_iPos + 1);
DrawLabel();
}
return bNeedRepaint;
}
boolean MouseLeftClicked(int x, int y) {
if(m_rcPane[0] == null)
return false;
if(x < m_rcPane[0].x || x > m_rcPane[0].x + m_rcPane[0].width)
return false;
int iNewPos = (int)((float)(x - m_rcPane[0].x) / m_pos.m_Ratio);
if(iNewPos != m_iPos && iNewPos >= 0 && iNewPos <= m_pos.m_End - m_pos.m_Begin) {
DrawCursor(iNewPos);
DrawLabel();
}
return false;
}
boolean MouseDragged(int x, int y) {
return MouseLeftClicked(x, y);
}
private void DrawCursor(int iNewPos) {
Graphics g = ((MenuListener) (parent)).m_applet.getGraphics();
g.setColor(HQApplet.rhColor.clBackGround);
g.setXORMode(HQApplet.rhColor.clCursor);
if(m_iPos != -1) {
int x = m_rcPane[0].x + (int)(m_pos.m_Ratio / 2.0F + (float)m_iPos * m_pos.m_Ratio);
g.drawLine(x, m_rcPane[0].y + 1, x, (m_rcPane[2].y + m_rcPane[2].height) - 1);
m_indicator[0].DrawCursor(g, m_iPos);
}
if(iNewPos != -1) {
m_iPos = iNewPos;
int x = m_rcPane[0].x + (int)(m_pos.m_Ratio / 2.0F + (float)m_iPos * m_pos.m_Ratio);
g.drawLine(x, m_rcPane[0].y + 1, x, (m_rcPane[2].y + m_rcPane[2].height) - 1);
m_indicator[0].DrawCursor(g, m_iPos);
}
g.setPaintMode();
}
private void DrawLabel() {
if(m_kData == null || m_kData.length == 0)
return;
Graphics g = ((MenuListener) (parent)).m_applet.getGraphics();
int iIndex;
if(m_iPos < 0)
iIndex = m_kData.length - 1;
else
iIndex = m_pos.m_Begin + m_iPos;
for(int i = 0; i < 3; i++)
m_indicator[i].DrawTitle(g, iIndex);
if(m_iPos < 0)
return;
g.clearRect(m_rcLabel.x, m_rcLabel.y, m_rcLabel.width, m_rcLabel.height);
g.setColor(HQApplet.rhColor.clNumber);
g.drawRect(m_rcLabel.x, m_rcLabel.y, m_rcLabel.width, m_rcLabel.height);
g.setFont(new Font("\u5B8B\u4F53", 0, 14));
FontMetrics fm = g.getFontMetrics();
int x = m_rcLabel.x + 1;
int y = m_rcLabel.y + fm.getAscent() + 1;
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Date"), x, y);
y += fm.getHeight();
String str = String.valueOf(m_kData[iIndex].date);
switch(((MenuListener) (parent)).m_applet.m_iKLineCycle) {
case 1: // '\001'
case 2: // '\002'
break;
case 3: // '\003'
if(str.length() >= 6)
str = str.substring(0, 6);
break;
default:
if(str.length() >= 4)
str = str.substring(0, 8);
break;
}
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.setColor(HQApplet.rhColor.clEqual);
g.drawString(str, x, y);
if(((MenuListener) (parent)).m_applet.m_iKLineCycle >= 4 && ((MenuListener) (parent)).m_applet.m_iKLineCycle <= 7) {
str = String.valueOf(m_kData[iIndex].date);
str = str.substring(8, 10) + ":" + str.substring(10);
y += fm.getHeight();
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
}
x = m_rcLabel.x + 1;
y += fm.getHeight();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Open"), x, y);
float fPreClose;
if(iIndex > 0)
fPreClose = m_kData[iIndex - 1].balancePrice;
else
fPreClose = m_kData[iIndex].openPrice;
y += fm.getHeight();
str = Common.FloatToString(m_kData[iIndex].openPrice, m_iPrecision);
if(m_kData[iIndex].openPrice > fPreClose)
g.setColor(HQApplet.rhColor.clIncrease);
else
if(m_kData[iIndex].openPrice < fPreClose)
g.setColor(HQApplet.rhColor.clDecrease);
else
g.setColor(HQApplet.rhColor.clEqual);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
x = m_rcLabel.x + 1;
y += fm.getHeight();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("High"), x, y);
y += fm.getHeight();
str = Common.FloatToString(m_kData[iIndex].highPrice, m_iPrecision);
if(m_kData[iIndex].highPrice > fPreClose)
g.setColor(HQApplet.rhColor.clIncrease);
else
if(m_kData[iIndex].highPrice < fPreClose)
g.setColor(HQApplet.rhColor.clDecrease);
else
g.setColor(HQApplet.rhColor.clEqual);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
x = m_rcLabel.x + 1;
y += fm.getHeight();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Low"), x, y);
y += fm.getHeight();
str = Common.FloatToString(m_kData[iIndex].lowPrice, m_iPrecision);
if(m_kData[iIndex].lowPrice > fPreClose)
g.setColor(HQApplet.rhColor.clIncrease);
else
if(m_kData[iIndex].lowPrice < fPreClose)
g.setColor(HQApplet.rhColor.clDecrease);
else
g.setColor(HQApplet.rhColor.clEqual);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
x = m_rcLabel.x + 1;
y += fm.getHeight();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Close"), x, y);
y += fm.getHeight();
str = Common.FloatToString(m_kData[iIndex].closePrice, m_iPrecision);
if(m_kData[iIndex].closePrice > fPreClose)
g.setColor(HQApplet.rhColor.clIncrease);
else
if(m_kData[iIndex].closePrice < fPreClose)
g.setColor(HQApplet.rhColor.clDecrease);
else
g.setColor(HQApplet.rhColor.clEqual);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
boolean bShowBalance = true;
if(((MenuListener) (parent)).m_applet.m_iKLineCycle != 1 && (((MenuListener) (parent)).m_applet.getProductType(m_product.sCode) == 2 || ((MenuListener) (parent)).m_applet.getProductType(m_product.sCode) == 3))
bShowBalance = false;
x = m_rcLabel.x + 1;
y += fm.getHeight();
if(bShowBalance) {
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Balance"), x, y);
}
y += fm.getHeight();
if(bShowBalance) {
str = Common.FloatToString(m_kData[iIndex].balancePrice, m_iPrecision);
if(m_kData[iIndex].balancePrice > fPreClose)
g.setColor(HQApplet.rhColor.clIncrease);
else
if(m_kData[iIndex].balancePrice < fPreClose)
g.setColor(HQApplet.rhColor.clDecrease);
else
g.setColor(HQApplet.rhColor.clEqual);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
}
x = m_rcLabel.x + 1;
y += fm.getHeight();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Volume"), x, y);
y += fm.getHeight();
str = String.valueOf(m_kData[iIndex].totalAmount);
g.setColor(HQApplet.rhColor.clVolume);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
x = m_rcLabel.x + 1;
y += fm.getHeight();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Money"), x, y);
y += fm.getHeight();
str = String.valueOf((long)(m_kData[iIndex].totalMoney / 100D));
g.setColor(HQApplet.rhColor.clVolume);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
x = m_rcLabel.x + 1;
y += fm.getHeight();
g.setColor(HQApplet.rhColor.clItem);
g.drawString(((MenuListener) (parent)).m_applet.getShowString("Order"), x, y);
y += fm.getHeight();
str = String.valueOf(m_kData[iIndex].reserveCount);
g.setColor(HQApplet.rhColor.clReserve);
x = (m_rcLabel.x + m_rcLabel.width) - fm.stringWidth(str) - 1;
g.drawString(str, x, y);
}
void CreateIndicator() {
int iPrecision = ((MenuListener) (parent)).m_applet.GetPrecision(((MenuListener) (parent)).m_applet.strCurrentCode);
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("ASI"))
m_indicator[2] = new ASI(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("BIAS"))
m_indicator[2] = new BIAS(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("BRAR"))
m_indicator[2] = new BRAR(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("BOLL"))
m_indicator[2] = new BOLL(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("CCI"))
m_indicator[2] = new CCI(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("CR"))
m_indicator[2] = new CR(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("DMA"))
m_indicator[2] = new DMA(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("DMI"))
m_indicator[2] = new DMI(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("EMV"))
m_indicator[2] = new EMV(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("EXPMA"))
m_indicator[2] = new EXPMA(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("KDJ"))
m_indicator[2] = new KDJ(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("MACD"))
m_indicator[2] = new MACD(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("MIKE"))
m_indicator[2] = new MIKE(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("OBV"))
m_indicator[2] = new OBV(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("ORDER"))
m_indicator[2] = new Reserve(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("PSY"))
m_indicator[2] = new PSY(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("ROC"))
m_indicator[2] = new ROC(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("RSI"))
m_indicator[2] = new RSI(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("SAR"))
m_indicator[2] = new SAR(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("TRIX"))
m_indicator[2] = new TRIX(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("VR"))
m_indicator[2] = new VR(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("W%R"))
m_indicator[2] = new W_R(m_pos, iPrecision);
else
if(((MenuListener) (parent)).m_applet.m_strIndicator.equals("WVAD"))
m_indicator[2] = new WVAD(m_pos, iPrecision);
}
void ChangeIndicator(boolean bDown) {
int iCur = -1;
for(int i = 0; i < IndicatorBase.INDICATOR_NAME.length; i++) {
if(!IndicatorBase.INDICATOR_NAME[i][0].equals(((MenuListener) (parent)).m_applet.m_strIndicator))
continue;
iCur = i;
break;
}
if(bDown)
iCur = (iCur + 1) % IndicatorBase.INDICATOR_NAME.length;
else
if(iCur < 1)
iCur = IndicatorBase.INDICATOR_NAME.length - 1;
else
iCur = (iCur - 1) % IndicatorBase.INDICATOR_NAME.length;
((MenuListener) (parent)).m_applet.m_strIndicator = IndicatorBase.INDICATOR_NAME[iCur][0];
CreateIndicator();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -