better charts

This commit is contained in:
7u83 2017-12-24 10:32:29 +01:00
parent 6780f78e14
commit ab78a513a6
2 changed files with 100 additions and 38 deletions

View File

@ -1,4 +1,4 @@
#Wed, 20 Dec 2017 19:18:09 +0100
#Fri, 22 Dec 2017 23:54:42 +0100
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=

View File

@ -25,14 +25,20 @@
*/
package chart;
import chart.painter.ChartPainter;
import chart.painter.XLegendPainter;
import gui.Globals;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;
import sesim.ChartDef;
import sesim.ChartPanel;
import sesim.OHLCData;
import sesim.Stock;
/**
@ -51,40 +57,101 @@ public class MMChart extends javax.swing.JPanel {
initComponents();
setupLayout();
}
JPanel xLegend;
ChartPanel xLegend;
JPanel yLegend;
JPanel mainChart;
private final void setupYLegend() {
yLegend = new ChartPanel();
Border redborder = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0));
yLegend.setBorder(redborder);
yLegend.setPreferredSize(new Dimension(this.em_width * 10, 110));
yLegend.setMinimumSize(new Dimension(em_width*10,110));
GridBagConstraints gbConstraints;
gbConstraints = new java.awt.GridBagConstraints();
gbConstraints.gridx = 1;
gbConstraints.gridy = 0;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.weightx = 0.0;
gbConstraints.weighty = 1.0;
add(yLegend, gbConstraints);
}
final void setupXLegend() {
xLegend = new ChartPanel();
// xLegend.setBackground(Color.blue);
xLegend.setPreferredSize(new Dimension(em_width*2,em_width*3));
xLegend.setMinimumSize(new Dimension(em_width*2,em_width*3));
xLegend.setChartDef(chartDef);
GridBagConstraints gbConstraints;
gbConstraints = new java.awt.GridBagConstraints();
gbConstraints.gridx = 0;
gbConstraints.gridy = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.weightx = 1.0;
gbConstraints.weighty = 0.0;
add(xLegend,gbConstraints);
ChartPainter p;
OHLCData mydata = Globals.se.getOHLCdata(Globals.se.getDefaultStock(),60000 * 20);
// this.xScrollBar.setMaximum(0);
p = new XLegendPainter();
p.setOHLCData(mydata);
xLegend.addChartPainter(p);
}
final void setupMainChart(){
mainChart = new ChartPanel();
mainChart.setBackground(Color.green);
GridBagConstraints gbConstraints;
gbConstraints = new java.awt.GridBagConstraints();
gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.weightx = 1.0;
gbConstraints.weighty = 1.0;
add(mainChart,gbConstraints);
}
ChartDef chartDef;
final void setupLayout() {
this.removeAll();
removeAll();
Border redborder = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0));
Border blueborder = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 255));
yLegend = new JPanel();
java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
java.awt.GridBagConstraints gridBagConstraints;
setupYLegend();
setupXLegend();
setupMainChart();
yLegend.setBorder(redborder);
yLegend.setPreferredSize(new Dimension(0,0));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
chartDef = new ChartDef();
chartDef.x_unit_width = 3.0;
add(yLegend, gridBagConstraints);
java.awt.GridBagConstraints gbConstraints;
mainChart = new JPanel();
mainChart.setPreferredSize(new Dimension(100, 40));
mainChart.setBackground(Color.blue);
/* p = new JPanel();
p.setPreferredSize(new Dimension(100,40));
@ -114,11 +181,7 @@ public class MMChart extends javax.swing.JPanel {
*/
// p.setLayout(layout);
}
int em_width;
@ -134,7 +197,6 @@ public class MMChart extends javax.swing.JPanel {
super.paint(g); //To change body of generated methods, choose Tools | Templates.
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always