From f485dc6ff0df00c5f998320a44595e21dbbcdfca Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@mail.ru> Date: Tue, 16 Jan 2018 00:14:35 +0100 Subject: [PATCH] Work y steps --- nbproject/jnlp-impl.xml | 4 +- nbproject/jnlp-impl_backup.xml | 4 +- nbproject/project.properties | 2 +- src/chart/painter/ChartPainter.java | 58 ++----------------------- src/chart/painter/OHLCChartPainter.java | 50 +++++++++++++++++++-- 5 files changed, 56 insertions(+), 62 deletions(-) diff --git a/nbproject/jnlp-impl.xml b/nbproject/jnlp-impl.xml index b03f371..32bd923 100644 --- a/nbproject/jnlp-impl.xml +++ b/nbproject/jnlp-impl.xml @@ -261,7 +261,7 @@ made subject to such option by the copyright holder. - + @@ -306,7 +306,7 @@ made subject to such option by the copyright holder. - + diff --git a/nbproject/jnlp-impl_backup.xml b/nbproject/jnlp-impl_backup.xml index 32bd923..b03f371 100644 --- a/nbproject/jnlp-impl_backup.xml +++ b/nbproject/jnlp-impl_backup.xml @@ -261,7 +261,7 @@ made subject to such option by the copyright holder. - + @@ -306,7 +306,7 @@ made subject to such option by the copyright holder. - + diff --git a/nbproject/project.properties b/nbproject/project.properties index cb9ef56..a68b7a5 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Mon, 15 Jan 2018 12:50:01 +0100 +#Mon, 15 Jan 2018 23:45:43 +0100 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/chart/painter/ChartPainter.java b/src/chart/painter/ChartPainter.java index ddedc59..abe2cf6 100644 --- a/src/chart/painter/ChartPainter.java +++ b/src/chart/painter/ChartPainter.java @@ -67,62 +67,12 @@ abstract public class ChartPainter implements ChartPainterInterface{ } - protected float y_scaling; - protected int y_height; - protected float y_min; - protected float y_max; + // protected float y_scaling; +// protected int y_height; +// protected float y_min; +// protected float y_max; - float getY(float y) { -//c_yscaling = ctx.rect.height / c_mm.getDiff(); -// float ys = dim.height / mm.getDiff(); - /* if (minmax.isLog()) { -// return rect.height + rect.y - ((float) Math.log(y) - c_mm.getMin()) * ys; - } - */ -// return (dim.height - ((y - minmax.getMin()) * y_scaling)); - return (y_height - ((y - y_min) * y_scaling)); - } - - double getValAtY(float y) { - float val = 0; - - /* if (c_mm.isLog()) { - float ys = rect.height / c_mm.getDiff(); - - return Math.exp((rect.height + rect.y) / ys + c_mm.getMin() - y / ys); - - } - */ - return (-(y - y_height)) / y_scaling + y_min; - - } - int trest; - - protected float getRoundNumber(float n){ - - - - int ldist = this.em_size*2; - int steps = y_height/ldist; - - System.out.printf("Yheight: %d %d\n",y_height,trest); - - System.out.printf("Steps = %d, h: %d\n", steps, this.y_height); - - - - return (float)0.0; - - } - - void initGetY(MinMax minmax, Dimension dim) { - y_height = dim.height; - y_scaling = dim.height / minmax.getDiff(); - y_min = minmax.getMin(); - y_max = minmax.getMax(); - trest=11; - } @Override abstract public void drawChart(Graphics2D g, ChartPanel p, ChartDef def); diff --git a/src/chart/painter/OHLCChartPainter.java b/src/chart/painter/OHLCChartPainter.java index c1b4b6f..8e6c40c 100644 --- a/src/chart/painter/OHLCChartPainter.java +++ b/src/chart/painter/OHLCChartPainter.java @@ -101,7 +101,52 @@ public abstract class OHLCChartPainter extends ChartPainter { protected float y_scaling; protected int y_height; protected float y_min; + protected float y_max; + + + protected float getRoundNumber(float n){ + + + + int ldist = this.em_size*2; + int steps = y_height/ldist; + + System.out.printf("Yheight: %d \n",y_height); + + System.out.printf("Steps = %d, h: %d\n", steps, this.y_height); + + float stepsize = (y_max - y_min) / steps; + + + + stepsize = 2; + + // double minl10 = Math.log10(y_min); + // double maxl10 = Math.log10(y_max); + + double lo = Math.ceil(Math.log10(stepsize)); + double rss = Math.pow(10, lo); + + System.out.printf("Ste size %f %f %f\n",stepsize,lo, rss); + + + + + return (float)0.0; + + } + + void initGetY(MinMax minmax, Dimension dim) { + y_height = dim.height; + y_scaling = dim.height / minmax.getDiff(); + y_min = minmax.getMin(); + y_max = minmax.getMax(); + + } + + + float getY(float y) { //c_yscaling = ctx.rect.height / c_mm.getDiff(); // float ys = dim.height / mm.getDiff(); @@ -127,9 +172,8 @@ public abstract class OHLCChartPainter extends ChartPainter { return (-(y - y_height)) / y_scaling + y_min; } - - /* @Override - void initGetY(MinMax minmax, Dimension dim) { + + /* void initGetY(MinMax minmax, Dimension dim) { y_height = dim.height; y_scaling = dim.height / minmax.getDiff(); y_min = minmax.getMin();