From f337ab9a08b4ee3072db142181e2f8d53b031456 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiol.ru> Date: Sat, 25 Mar 2017 19:09:12 +0100 Subject: [PATCH] Work on y legend --- src/chart/Chart.java | 31 ++++++++++++++++++++++--------- src/sesim/MinMax.java | 5 +++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/chart/Chart.java b/src/chart/Chart.java index a479802..d5556d0 100644 --- a/src/chart/Chart.java +++ b/src/chart/Chart.java @@ -263,8 +263,10 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab // ys = c_rect.height / c_mm.getDiff(); - return (c_rect.height - (((float)Math.log(y) - c_mm.getMin()) * ys)) + c_rect.y; - + // return (c_rect.height - (((float)Math.log(y) - c_mm.getMin()) * ys)) + c_rect.y; + return c_rect.height + c_rect.y - ((float)Math.log(y) - c_mm.getMin()) * ys; + + /* float m = c_mm.getMax() / c_mm.getMin(); float fac = (float) c_rect.height / (float) Math.log(m); @@ -293,9 +295,21 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab // -(y-c_rect.y-c_rect.heigh) = (val - c_mm.getMin()) * c_yscaling // (-(y-c_rect.y-c_rect.heigh))/c_yscaling = (val - c_mm.getMin()) - - if (logs){ - return (-(Math.exp(y)-c_rect.y-c_rect.height))/c_yscaling+Math.exp(c_mm.getMin()); + + if (c_mm.isLog()){ + float ys = c_rect.height / c_mm.getDiff(); + + + //val = return c_rect.height + c_rect.y - ((float)Math.log(y) - c_mm.getMin()) * ys; + // ((float)Math.log(y) - c_mm.getMin()) * ys = c_rect.height + c_rect.y + // ((float)Math.log(y) - c_mm.getMin()) = (c_rect.height + c_rect.y)/ys + // ((float)Math.log(y) = (c_rect.height + c_rect.y)/ys + c_mm.getMin()) + + //return (-(Math.exp(y)-c_rect.y-c_rect.height))/ys+c_mm.getMin(); + + + return Math.exp( (c_rect.height + c_rect.y)/ys + c_mm.getMin() ); + } @@ -413,7 +427,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab for (int yp=(int) y2; yp