From ce0bb75bab813def2e67db95c43ba6d28adb088d Mon Sep 17 00:00:00 2001
From: 7u83 <7u83@mail.ru>
Date: Mon, 2 Oct 2017 23:05:29 +0200
Subject: [PATCH] line chart candlestick chart in separate objects
---
nbproject/private/private.xml | 43 ++++++-
nbproject/project.properties | 2 +-
src/chart/CandleStickChartPainter.java | 72 +++++++++++
src/chart/Chart1.form | 28 ----
src/chart/Chart1.java | 170 -------------------------
src/chart/ChartDef.java | 2 +-
src/chart/ChartPanel.java | 5 +-
src/chart/ChartTestDialog.form | 4 +-
src/chart/ChartTestDialog.java | 30 +++--
src/chart/LineChartPainter.java | 53 ++++++++
src/chart/OHLCChartPainter.java | 76 ++++-------
src/gui/jp99.form | 4 +-
src/gui/jp99.java | 4 +-
13 files changed, 212 insertions(+), 281 deletions(-)
create mode 100644 src/chart/CandleStickChartPainter.java
delete mode 100644 src/chart/Chart1.form
delete mode 100644 src/chart/Chart1.java
create mode 100644 src/chart/LineChartPainter.java
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
index fa95d00..f2e0d9e 100644
--- a/nbproject/private/private.xml
+++ b/nbproject/private/private.xml
@@ -3,10 +3,45 @@
- file:/home/tobias/v/SeSim/src/chart/OHLCChartPainter.java
- file:/home/tobias/v/SeSim/src/chart/Chart.java
- file:/home/tobias/v/SeSim/src/chart/XLegendChartPainter.java
- file:/home/tobias/v/SeSim/src/chart/NewPanel.java
+ file:/home/tube/NetBeansProjects/SeSim/src/traders/RandomTraderA.java
+ file:/home/tube/NetBeansProjects/SeSim/test/sesim/Test.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/StatisticsPanel.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/tools/NummericCellRenderer.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderInterface.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/ChartTestDialog.java
+ file:/home/tube/NetBeansProjects/SeSim/src/traders/ManTrader/ManTraderConsoleDialog.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderLoader.java
+ file:/home/tube/NetBeansProjects/SeSim/src/traders/ManTrader/ManTrader.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/NewPanel.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/SeSimApplication.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/Globals.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/XLegendChartPainter.java
+ file:/home/tube/NetBeansProjects/SeSim/src/traders/RandomTraderB.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/OHLCChartPainter.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/Logger.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/EditPreferencesDialog.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/QuotePanel.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderBase.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/Statistics.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/EditStrategies.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/MainChart.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/Chart.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/Clock.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/OHLCData.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/IDGenerator.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/MinMax.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderGui.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/Exchange.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/jp99.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/Locker.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/orderbook/OrderBook.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/ChartPanal.java
+ file:/home/tube/NetBeansProjects/SeSim/src/sesim/OHLCDataItem.java
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/AboutDialog.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/Chart1.java
+ file:/home/tube/NetBeansProjects/SeSim/src/chart/ChartPainter.java
+ file:/home/tube/NetBeansProjects/SeSim/README.md
+ file:/home/tube/NetBeansProjects/SeSim/src/gui/TestChartdialog.java
diff --git a/nbproject/project.properties b/nbproject/project.properties
index bc7bbc5..3d7a5de 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -1,4 +1,4 @@
-#Mon, 02 Oct 2017 16:43:06 +0200
+#Mon, 02 Oct 2017 22:55:32 +0200
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
diff --git a/src/chart/CandleStickChartPainter.java b/src/chart/CandleStickChartPainter.java
new file mode 100644
index 0000000..738bf1f
--- /dev/null
+++ b/src/chart/CandleStickChartPainter.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, 7u83 <7u83@mail.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package chart;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import sesim.OHLCDataItem;
+
+/**
+ *
+ * @author 7u83 <7u83@mail.ru>
+ */
+public class CandleStickChartPainter extends OHLCChartPainter {
+
+ @Override
+ protected void drawItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) {
+
+ if (i.open < i.close) {
+ int xl = (int) (x + iwidth / 2);
+
+ g.setColor(Color.BLACK);
+ g.drawLine(xl, (int) getY(i.close), xl, (int) getY(i.high));
+ g.drawLine(xl, (int) getY(i.low), xl, (int) getY(i.open));
+
+ float w = iwidth;
+ float h = (int) (getY(i.open) - getY(i.close));
+
+ g.setColor(Color.GREEN);
+ g.fillRect((int) (x), (int) getY(i.close), (int) w, (int) h);
+ g.setColor(Color.BLACK);
+ g.drawRect((int) (x), (int) getY(i.close), (int) w, (int) h);
+
+ } else {
+ int xl = (int) (x + iwidth / 2);
+ g.setColor(Color.RED);
+ g.drawLine(xl, (int) getY(i.high), xl, (int) getY(i.close));
+ g.drawLine(xl, (int) getY(i.open), xl, (int) getY(i.low));
+
+ float w = iwidth;
+ float h = (int) (getY(i.close) - getY(i.open));
+
+ g.fillRect((int) (x), (int) getY(i.open), (int) w, (int) h);
+ g.setColor(Color.BLACK);
+ g.drawRect((int) (x), (int) getY(i.open), (int) w, (int) h);
+ }
+ }
+
+
+}
diff --git a/src/chart/Chart1.form b/src/chart/Chart1.form
deleted file mode 100644
index 9312e7a..0000000
--- a/src/chart/Chart1.form
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
diff --git a/src/chart/Chart1.java b/src/chart/Chart1.java
deleted file mode 100644
index 40b0a94..0000000
--- a/src/chart/Chart1.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package chart;
-
-import gui.Globals;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.awt.event.AdjustmentEvent;
-import java.awt.event.AdjustmentListener;
-import java.awt.geom.AffineTransform;
-import java.util.ArrayList;
-import javax.swing.JScrollBar;
-import javax.swing.JViewport;
-import javax.swing.Scrollable;
-import sesim.Exchange.QuoteReceiver;
-import sesim.OHLCData;
-import sesim.OHLCDataItem;
-import sesim.Quote;
-
-/**
- *
- * @author 7u83 <7u83@mail.ru>
- */
-public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, AdjustmentListener {
-
- public JScrollBar xbar;
-
- /**
- * Creates new form Chart1
- */
- public Chart1() {
- initComponents();
- System.out.printf("Now cursor\n");
-
- setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
-
- if (Globals.se == null) {
- return;
- }
-
- setSize(new Dimension(9000, 500));
- Globals.se.addQuoteReceiver(this);
- }
-
-
- ArrayList chartPainters = new ArrayList<>();
-
- /**
- *
- * @param p
- */
- public void addChartPainter(ChartPainter p){
- chartPainters.add(p);
- }
-
- private void drawChart(Graphics2D g) {
-
- JViewport vp = new JViewport();
-
- // if (Globals.se==null)
-// return;
- Dimension d = new Dimension(200, 200);
- setPreferredSize(d);
-
- g.setClip(10, 10, 800, 200);
- g.setColor(Color.red);
- g.drawLine(0, 0, 8000, 610);
-
- if (Globals.se == null) {
- return;
- }
-
- revalidate();
-
- System.out.printf("Setting pref size\n");
-
- OHLCData data = Globals.se.getOHLCdata(60000);
- /*
- int first_bar = 0;
- int last_bar = data.size();
-
- OHLCDataItem prev = null;
-
- for (int i = first_bar; i < last_bar; i++) {
- OHLCDataItem di = data.get(i);
-
- int x_unit_width = 1;
- int x = (int) (i * em_width * x_unit_width);
-
- g.setColor(Color.red);
- g.drawLine(x, 0, x, 10);
-
-//em_width;
- //this.drawItem(ctx, (int) (x - em_width * x_unit_width), x, prev, di); //, ctx.scaling, data.getMin());
- // myi++;
- prev = di;
-
- }
- */
- }
- OHLCData data;
-
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
-
- if (Globals.se==null)
- return;
-
-
- //this.xbar.setMaximum(994000);
-
- XLegendChartPainter p = new XLegendChartPainter();
- data = Globals.se.getOHLCdata(60000*60);
-
- ChartDef def = new ChartDef();
- def.x_unit_width = 1.0;
- def.x_scrollbar=xbar;
-
-
- for (ChartPainter painter: chartPainters){
- painter.drawChart((Graphics2D)g, xbar, data, this, def);
- }
-
-
- }
-
- /**
- * 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
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // //GEN-BEGIN:initComponents
- private void initComponents() {
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 498, Short.MAX_VALUE)
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 341, Short.MAX_VALUE)
- );
- }// //GEN-END:initComponents
-
- @Override
- public void UpdateQuote(Quote q) {
-
- int s = data.size();
- System.out.printf("Data size %d",s);
-// xbar.setMaximum(data.size());
- repaint();
- }
-
- @Override
- public void adjustmentValueChanged(AdjustmentEvent e) {
- System.out.printf("Adjustemntlistener called %d\n", xbar.getValue());
-
- this.repaint();
- }
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- // End of variables declaration//GEN-END:variables
-}
diff --git a/src/chart/ChartDef.java b/src/chart/ChartDef.java
index 9c24c5e..a98431d 100644
--- a/src/chart/ChartDef.java
+++ b/src/chart/ChartDef.java
@@ -37,7 +37,7 @@ public class ChartDef {
/**
* width of an x unit in em
*/
- double x_unit_width=1.0;
+ double x_unit_width=4.0;
ChartDef(){
diff --git a/src/chart/ChartPanel.java b/src/chart/ChartPanel.java
index 144d869..36979cc 100644
--- a/src/chart/ChartPanel.java
+++ b/src/chart/ChartPanel.java
@@ -1,7 +1,7 @@
package chart;
import gui.Globals;
-import java.awt.Color;
+
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -108,14 +108,13 @@ public class ChartPanel extends javax.swing.JPanel implements QuoteReceiver, Adj
public void UpdateQuote(Quote q) {
int s = data.size();
- System.out.printf("Data size %d",s);
+// System.out.printf("Data size %d",s);
// xbar.setMaximum(data.size());
repaint();
}
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
- System.out.printf("Adjustemntlistener called %d\n", xbar.getValue());
this.repaint();
}
diff --git a/src/chart/ChartTestDialog.form b/src/chart/ChartTestDialog.form
index 5eae9c8..db29401 100644
--- a/src/chart/ChartTestDialog.form
+++ b/src/chart/ChartTestDialog.form
@@ -59,7 +59,7 @@
-
+
@@ -74,7 +74,7 @@
-
+
diff --git a/src/chart/ChartTestDialog.java b/src/chart/ChartTestDialog.java
index b64e65c..7b1d10b 100644
--- a/src/chart/ChartTestDialog.java
+++ b/src/chart/ChartTestDialog.java
@@ -34,7 +34,7 @@ import sesim.Quote;
*
* @author 7u83 <7u83@mail.ru>
*/
-public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceiver{
+public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceiver {
/**
* Creates new form ChartTestDialog
@@ -43,21 +43,23 @@ public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceive
super(parent, modal);
initComponents();
setLocationRelativeTo(parent);
- this.chart12.xbar=this.jScrollBar1;
+ this.chart12.xbar = this.jScrollBar1;
this.jScrollBar1.addAdjustmentListener(chart12);
ChartPainter p = new XLegendChartPainter();
- chart12.addChartPainter(p);
- Globals.se.addQuoteReceiver(this);
-
+ chart12.addChartPainter(p);
+ Globals.se.addQuoteReceiver(this);
- this.chart11.xbar=this.jScrollBar1;
+ this.chart11.xbar = this.jScrollBar1;
this.jScrollBar1.addAdjustmentListener(chart11);
- p = new OHLCChartPainter();
+
+ p = new CandleStickChartPainter();
this.chart11.addChartPainter(p);
-
-
+ p = new LineChartPainter();
+ this.chart11.addChartPainter(p);
+
+
}
/**
@@ -70,8 +72,8 @@ public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceive
private void initComponents() {
jScrollBar1 = new javax.swing.JScrollBar();
- chart12 = new chart.Chart1();
- chart11 = new chart.Chart1();
+ chart12 = new chart.ChartPanel();
+ chart11 = new chart.ChartPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setMaximumSize(new java.awt.Dimension(800, 600));
@@ -175,14 +177,14 @@ public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceive
}
// Variables declaration - do not modify//GEN-BEGIN:variables
- private chart.Chart1 chart11;
- private chart.Chart1 chart12;
+ private chart.ChartPanel chart11;
+ private chart.ChartPanel chart12;
private javax.swing.JScrollBar jScrollBar1;
// End of variables declaration//GEN-END:variables
@Override
public void UpdateQuote(Quote q) {
- OHLCData data = Globals.se.getOHLCdata(60000*60*4);
+ OHLCData data = Globals.se.getOHLCdata(60000 * 60 * 4);
this.jScrollBar1.setMaximum(data.size());
repaint();
System.out.printf("SETMAXIMUM: %d", data.size());
diff --git a/src/chart/LineChartPainter.java b/src/chart/LineChartPainter.java
new file mode 100644
index 0000000..d6b2764
--- /dev/null
+++ b/src/chart/LineChartPainter.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017, 7u83 <7u83@mail.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package chart;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import sesim.OHLCDataItem;
+
+/**
+ *
+ * @author 7u83 <7u83@mail.ru>
+ */
+public class LineChartPainter extends OHLCChartPainter{
+
+ @Override
+ void drawItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) {
+
+ if (prev == null) {
+ prev = i;
+ }
+ int y1 = (int) getY(prev.close);
+ int y2 = (int) getY(i.close);
+ Color cur = g.getColor();
+ g.setColor(Color.RED);
+
+ g.drawLine(prevx, y1, x, y2);
+ g.setColor(cur);
+ }
+
+}
diff --git a/src/chart/OHLCChartPainter.java b/src/chart/OHLCChartPainter.java
index 2ded304..09fe756 100644
--- a/src/chart/OHLCChartPainter.java
+++ b/src/chart/OHLCChartPainter.java
@@ -39,92 +39,60 @@ import static sun.awt.geom.Curve.prev;
*
* @author 7u83 <7u83@mail.ru>
*/
-public class OHLCChartPainter extends ChartPainter {
+public abstract class OHLCChartPainter extends ChartPainter {
- private float iwidth;
+ protected float iwidth;
private MinMax mm;
private Dimension dim;
private float y_scaling;
-
float getY(float y) {
//c_yscaling = ctx.rect.height / c_mm.getDiff();
// float ys = dim.height / mm.getDiff();
if (mm.isLog()) {
// return rect.height + rect.y - ((float) Math.log(y) - c_mm.getMin()) * ys;
}
- return (dim.height - ((y - mm.getMin()) * y_scaling)) ;
-
-
+ return (dim.height - ((y - mm.getMin()) * y_scaling));
+
}
- private void drawCandleItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) {
+ abstract void drawItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i);
+
- if (i.open < i.close) {
- int xl = (int) (x + iwidth / 2);
-
- g.setColor(Color.BLACK);
- g.drawLine(xl, (int) getY(i.close), xl, (int) getY(i.high));
- g.drawLine(xl, (int) getY(i.low), xl, (int) getY(i.open));
-
- float w = iwidth;
- float h = (int) (getY(i.open) - getY(i.close));
-
- g.setColor(Color.GREEN);
- g.fillRect((int) (x), (int) getY(i.close), (int) w, (int) h);
- g.setColor(Color.BLACK);
- g.drawRect((int) (x), (int) getY(i.close), (int) w, (int) h);
-
- } else {
- int xl = (int) (x + iwidth / 2);
- g.setColor(Color.RED);
- g.drawLine(xl, (int) getY(i.high), xl, (int) getY(i.close));
- g.drawLine(xl, (int) getY(i.open), xl, (int) getY(i.low));
-
- float w = iwidth;
- float h = (int) (getY(i.close) - getY(i.open));
-
- g.fillRect((int) (x), (int) getY(i.open), (int) w, (int) h);
- g.setColor(Color.BLACK);
- g.drawRect((int) (x), (int) getY(i.open), (int) w, (int) h);
-
- }
-
- }
@Override
public void drawChart(Graphics2D g, JScrollBar sb, OHLCData data, JPanel p, ChartDef def) {
init(g);
-
+
iwidth = (float) ((def.x_unit_width * em_width) * 0.9f);
-
+
int first_bar = def.x_scrollbar.getValue();
dim = p.getSize();
int bars = (int) (dim.width / (def.x_unit_width * em_width));
-
- int last_bar = first_bar+bars;
-
- mm = data.getMinMax(first_bar, first_bar+bars);
-
+
+ int last_bar = first_bar + bars+1;
+
+ mm = data.getMinMax(first_bar, last_bar);
+
y_scaling = dim.height / mm.getDiff();
- OHLCDataItem prevd=null;
+ OHLCDataItem prevd = null;
int prevx;
-
- if (data.size()>0 && first_bar 0 && first_bar < data.size()) {
prevd = data.get(first_bar);
}
- for (int b = first_bar,n=0; b < last_bar && b
-
+
@@ -56,4 +56,4 @@
-
+
\ No newline at end of file
diff --git a/src/gui/jp99.java b/src/gui/jp99.java
index 606f805..0c80e04 100644
--- a/src/gui/jp99.java
+++ b/src/gui/jp99.java
@@ -28,7 +28,7 @@ public class jp99 extends javax.swing.JPanel {
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
- chart11 = new chart.Chart1();
+ chart11 = new chart.ChartPanel();
javax.swing.GroupLayout chart11Layout = new javax.swing.GroupLayout(chart11);
chart11.setLayout(chart11Layout);
@@ -63,7 +63,7 @@ public class jp99 extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
- private chart.Chart1 chart11;
+ private chart.ChartPanel chart11;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}