效果图如下:

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JPanel;
import javax.swing.JFrame;
public class sellhis extends JPanel {
static int Len;
int leftMargine = 50;
int rightMargine = 20;
int topMargine = 80;
int buttomMargine = 20;
int width, height, w, h;
int minStickLength = 3; //坐标的短刻度
int majStickLength = 8; //坐标的长刻度
int minStick = 10;
int majStick;
String title;
String xTitle = "股票代碼";
String xCode[];
float yData[], xPce[];
String MaxPce;
boolean Mouse_Move;
int x0, y0, X, Y, hx, hy;
Label label[] = new Label[3];
boolean mouse_move = false;
public sellhis() {
width = 1000; //this.getBounds().width;
height = 800; //this.getBounds().height;
w = width - leftMargine - rightMargine;
h = height - topMargine - buttomMargine;
setSize(width, height);
Color bc = new Color(229, 229, 229);
setBackground(bc);
setLayout(null);
for (int I = 0; I < 3; I++) {
label[I] = new Label();
label[I].setForeground(Color.blue);
this.add(label[I]);
if (I == 0) {
label[I].setBounds(75, topMargine - 25, 60, 15); //reshape
}
if (I == 1) {
label[I].setBounds(230, topMargine - 25, 80, 15); //reshape
}
if (I == 2) {
label[I].setBounds(505, topMargine - 25, 60, 15); //reshape
}
}
try {
title = getTitle("200201"); //getParameter("itemmonth"));
} catch (Exception e) {
System.out.println("Param itemmonth error!");
System.out.println(e);
}
try {
xCode = Subicode("00002,00014,00019,00023,00041,00102,00113,00114,00129,00132,00142,00146,00179,00203,00213,00223,00341");
//Subicode(getParameter("itemcode"));
Len = xCode.length;
hx = w / Len;
} catch (Exception e) {
System.out.println("Param itemcode error!");
System.out.println(e);
}
try {
yData = Substr("272950,193950,1015600,142700,1618500,671650,2453300,630150,28375,1827660,7700,75700,27375,3375600,47500,17500,17500");
//getParameter("itemval"));
} catch (Exception e) {
System.out.println("Param itemval error!");
System.out.println(e);
}
try {
xPce = Substr(
"219,156,817,114,2302,540,1974,507,22,1471,6,60,22,4717,38,114,14");
//getParameter("itempce"));
MaxPce = getMaxVal(xPce);
majStick = Integer.parseInt(MaxPce.substring(0, 1)) + 2; //取最大pce的最大整数
} catch (Exception e) {
System.out.println("Param itempce error!");
System.out.println(e);
}
try {
addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent evt) { //检测释放鼠标按键事件
setCursor(Cursor.getDefaultCursor());
Point ioc = evt.getPoint();
X = ioc.x; //把当前座标传递给另一线程
Y = ioc.y;
//repaint();
}
});
addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent evt) {
Point ioc = evt.getPoint();
if ((ioc.x > leftMargine & ioc.x < w + leftMargine) &
(ioc.y > topMargine & ioc.y < h + topMargine)) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else {
setCursor(Cursor.getDefaultCursor());
}
}
public void mouseMoved(MouseEvent evt) { //检测鼠标移动事件
Point ioc = evt.getPoint();
X = ioc.x;
Y = ioc.y;
Graphics gten;
gten = getGraphics();
gten.setXORMode(Color.white);
gten.setColor(Color.blue);
int Axsis;
if (ioc.x > leftMargine & ioc.x < w + leftMargine &
ioc.y > topMargine & ioc.y < h + topMargine) {
try {
Axsis = (X - leftMargine) / hx; //设定横座标范围
//在以下区域内,把鼠标当前横座标处的各种股票参数显示在相应的标签上
label[0].setText(xCode[Axsis]);
label[1].setText(Float.toString(yData[Axsis]));
float pcent = (xPce[Axsis] / 100);
label[2].setText(Float.toString(pcent));
} catch (Exception err) {
}
try {
if (y0 > topMargine & y0 < h + topMargine) {
gten.drawLine(leftMargine, y0, w + leftMargine,
y0);
}
if (Y > topMargine & Y < h + topMargine) {
gten.drawLine(leftMargine, Y, w + leftMargine,
Y);
}
if (x0 > leftMargine & x0 < w + leftMargine) {
gten.drawLine(x0, topMargine, x0,
h + topMargine);
}
if (X > leftMargine & X < w + leftMargine) {
gten.drawLine(X, topMargine, X, h + topMargine);
}
x0 = X;
y0 = Y;
} finally {
gten.dispose();
}
}
}
});
} catch (Exception e) {
System.out.println("sellhis construct add mouse listener error!");
System.out.println(e);
}
}
public void paint(Graphics g) { //paintComponent()
try {
g.drawString("股票代碼:", 20, topMargine - 15);
g.drawString("賣空成交金額:", 150, topMargine - 15);
g.drawString("賣空成交金額占總賣空成交金額%:", 320, topMargine - 15);
g.drawRect(leftMargine, topMargine, w, h); //矩形方框
int x0, y0, x1, y1, dy;
int totalStick = (majStick - 1) * minStick;
x0 = leftMargine;
dy = h / ((majStick - 1) * minStick);
for (int I = 1; I <= totalStick; I++) {
y0 = height - buttomMargine - I * dy;
y1 = y0;
x1 = x0 - minStickLength;
if (I % minStick == 0) {
x1 = x0 - majStickLength;
g.drawString("" + ((I) / minStick) + "0%", x1 - 25, y0 + 5); //y轴刻度数字
}
g.drawLine(x0, y0, x1, y1); //y轴刻度标
}
for (int I = 0; I < Len; I++) {
x0 = leftMargine + I * hx;
hy = (int) ((xPce[I] / 100) * (h / ((majStick - 1) * 10)));
y0 = height - buttomMargine - hy;
float pcent = (xPce[I] / 100);
Color pceCololr = new Color(153, 0, 153);
g.setColor(pceCololr);
g.setFont(new Font("Times New Roman", Font.PLAIN, 11));
g.drawString(Float.toString(pcent), x0, y0 - 5); //在柱状图上绘制%
if (I % 2 == 0) {
g.setColor(Color.orange);
} else {
g.setColor(Color.red);
}
g.fillRect(x0, y0, hx, hy); //绘制柱状图
//g.setColor(Color.red);  //绘制股票代码
//g.setFont(new Font("Times New Roman",Font.PLAIN,10));
//g.drawString(""+xCode[I],x0,height-topMargine+40);
}
Color titleColor = new Color(0, 64, 128);
g.setColor(titleColor);
g.setFont(new Font("monospaced", Font.BOLD, 20));
g.drawString(title, 190, 40);
} catch (Exception e) {
System.out.println("sellhis paint error.");
System.out.println(e);
}
}
public static float[] Substr(String str) {
int I = 0;
StringTokenizer st = new StringTokenizer(str, ",");
int len = st.countTokens();
float[] val = new float[len];
while (st.hasMoreTokens()) {
val[I] = Integer.parseInt(st.nextToken());
I++;
}
return val;
}
public static String[] Subicode(String str) {
int I = 0;
StringTokenizer st = new StringTokenizer(str, ",");
int len = st.countTokens();
String[] val = new String[len];
while (st.hasMoreTokens()) {
val[I] = st.nextToken();
I++;
}
return val;
}
public static String getMaxVal(float[] Maxval) {
int I;
float result;
result = Maxval[0];
for (I = 0; I < Maxval.length; I++) {
if (result < Maxval[I]) {
result = Maxval[I];
}
}
return Float.toString(result);
}
public String getTitle(String str) {
String title;
title = str.substring(0, 4) + "年" + str.substring(4, 6) + "月賣空股票統計";
return title;
}
public int getLeftMargine() {
return leftMargine;
}
public int getButtomMargine() {
return buttomMargine;
}
public void setLeftMargine(int leftMargine) {
this.leftMargine = leftMargine;
}
public void setButtomMargine(int buttomMargine) {
this.buttomMargine = buttomMargine;
}
public static void main(String[] args) {
JFrame frame = new JFrame();
sellhis se = new sellhis();
//se.setBounds(0,0,500,400);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(se, BorderLayout.CENTER);
frame.setVisible(true);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
//se.updateUI();
}
}

sellhis股票平面图相关推荐

  1. STATA单元回归分析单个股票与市场收益率的笔记

    ssc install cntrade,replace//命令下载最新版命令 cntrade 300750//选择宁德时代股票 describe//描述 tsset date,daily//设定时间变 ...

  2. LeetCode简单题之买卖股票的最‭佳时机

    题目 给定一个数组 prices ,它的第 i 个元素 prices[i] 表示一支给定股票第 i 天的价格. 你只能选择 某一天 买入这只股票,并选择在 未来的某一个不同的日子 卖出该股票.设计一个 ...

  3. python 生命之花_python股票用什么电脑配置:贵州合力股票价格多少钱_XAC配资之家...

    python股票用什么电脑配置:贵州合力股票价格多少钱 你好朋友,本文将为你分析python股票用什么电脑配置怎么样以及贵州合力股票价格多少钱的相关问题,如有任何疑问和留言咨询站长!之后我听说,那个小 ...

  4. 股票移动平均线matlab,股票的移动平均线 (图文)

    股票的移动平均线 [泸指]股票的移动平均线 移动平均线是个强大的工具,能够更清晰地展示一系列无规律的数值变化 (比如股市波动).此外,泸指移动平均线还可别除任何周期性变化(正常的季节性温度变化)的影响 ...

  5. 五连阳回调买入法_“4连阳+1阴”这种股票,吃透主升浪!挣得万贯家财

    根据以往的个股表现情况来看,那些即将进入主升浪的个股具有以下几个特点: 1.个股前期已经有了一定的涨幅,但向上的步伐比较谨慎,走势比较温和; 2.股价所处的位置并不低,有的是一段时期以来的最高位置,有 ...

  6. S-T平面图中利用最短路求最小割(BZOJ 1001)

    BZOJ 1001: [BeiJing2006]狼抓兔子 最小割 题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1001 现在小朋友们最喜欢 ...

  7. 某月某日前包括当天吗_创恒国际投资平台介绍股票交易制度:股票是否可以当天买?当天卖?...

    股票是否可以当天买?当天卖?在股市中,股票买入当天能卖吗?想必很多新股民都不是很清楚,下面小编就简单的给大家讲讲.A股目前实行的是T+1的交易规则,当日买入股票当日不能卖出.但是允许当日卖出可以当日买 ...

  8. 码农技术炒股之路——抓取股票基本信息、实时交易信息、主力动向信息

    从本节开始,我们开始介绍各个抓取和备份业务.(转载请指明出于breaksoftware的csdn博客) 因为我们数据库很多,数据库中表也很多,所以我们需要一个自动检测并创建数据库和表的功能.在< ...

  9. bootstrap 时间线_股票配资均量线的实战用法绝技是什么?怎么用它判断买卖点?...

    已经很久没有和大家讨论过股票交易量的有关内容了,主要是关于它的介绍和用法我们学习的太多了,不过好像漏了一个关于它的用法,就和和成交量息息相关的均量线,那么什么是均量线?和成交量有啥关系呢? 一.什么是 ...

最新文章

  1. Python持续点火,跟进还是观望?
  2. centos7 选定默认启动内核,及删除无用内核
  3. oracle 10g 4031
  4. 利用Comet4J 及时推送消息
  5. PHP线程安全和非线程安全的区别
  6. 破冰接入云信,打造陌生人游戏社交APP
  7. 脑芯编:窥脑究竟,织网造芯(二)
  8. kafka系统设计开篇
  9. 玩转 SpringBoot 2 快速整合 | JSP 篇
  10. html中charset和content-language的区别
  11. vijos P1009清帝之惑之康熙
  12. vue-music 关于搜索历史本地存储
  13. 巨头垂涎却不能染指,loT数据库风口已至
  14. PX4Flow使用操作
  15. 第一次制作中秋博饼小游戏的心得与吐槽(软件工程)
  16. linux命令之文件和目录操作
  17. udacity 学java_刷完udacity的JavaScript,我想说……
  18. TCGA数据库ensembl id 转为 gene Symbol,提取出需要的RNA种类表达谱列表信息
  19. android 高德路线,【Android呼叫高德路线规划】
  20. Android开发环境搭建+AS常用功能指导

热门文章

  1. LiveVideoStack线上分享第四季(十二):实时音视频抗丢包的实践
  2. 英特尔开源WebRTC开发套件OWT
  3. 数据结构与算法之打印两个有序链表公共部分和判断一个链表是否具有回文结构
  4. Web内核微信小程序框架实践
  5. 「递归」第3集 | 向善的信念,让技术自带光芒
  6. 实现对象的复用——享元模式
  7. 从(知乎大量的数据上保持毫秒级的查询响应时间)上看什么是 TiDB?
  8. leetcode 19. Remove Nth Node From End of List | 19. 删除链表的倒数第 N 个结点(Java)
  9. java中解决脏读_多线程出现脏读以及解决方法(使用synchronized)
  10. 一次bug调试经验----To prevent a memory leak, the JDBC Driver has been forcibly unregistered.