improving y-legend
This commit is contained in:
parent
83ad22e74f
commit
04690ddd72
@ -1,4 +1,4 @@
|
|||||||
#Wed, 17 Jan 2018 09:43:23 +0100
|
#Thu, 18 Jan 2018 10:46:19 +0100
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processors.list=
|
annotation.processing.processors.list=
|
||||||
|
@ -105,11 +105,13 @@ public abstract class OHLCChartPainter extends ChartPainter {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected float getRoundNumber(float n){
|
protected float getRoundNumber(float n){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int ldist = this.em_size*2;
|
int ldist = em_size*2;
|
||||||
int steps = y_height/ldist;
|
int steps = y_height/ldist;
|
||||||
|
|
||||||
System.out.printf("Yheight: %d \n",y_height);
|
System.out.printf("Yheight: %d \n",y_height);
|
||||||
|
@ -43,8 +43,8 @@ public class YLegendPainter extends OHLCChartPainter {
|
|||||||
|
|
||||||
ChartPanel master;
|
ChartPanel master;
|
||||||
|
|
||||||
public YLegendPainter (/*ChartPanel master*/){
|
public YLegendPainter(/*ChartPanel master*/) {
|
||||||
// this.master=master;
|
// this.master=master;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,25 +56,24 @@ public class YLegendPainter extends OHLCChartPainter {
|
|||||||
|
|
||||||
Dimension dim = def.mainChart.getSize();
|
Dimension dim = def.mainChart.getSize();
|
||||||
int first_bar = getFirstBar(master);
|
int first_bar = getFirstBar(master);
|
||||||
int last_bar = first_bar + getBars(master,def);
|
int last_bar = first_bar + getBars(master, def);
|
||||||
MinMax minmax = this.getData().getMinMax(first_bar, last_bar);
|
MinMax minmax = this.getData().getMinMax(first_bar, last_bar);
|
||||||
|
|
||||||
this.initGetY(minmax, dim);
|
this.initGetY(minmax, dim);
|
||||||
|
|
||||||
|
// calculate the number of captionable bars
|
||||||
|
int ldist = em_size * 2;
|
||||||
|
int steps = y_height / ldist;
|
||||||
|
|
||||||
|
|
||||||
this.getRoundNumber(90);
|
this.getRoundNumber(90);
|
||||||
|
|
||||||
|
|
||||||
//Rectangle dim;
|
//Rectangle dim;
|
||||||
// dim = p.getSize();
|
// dim = p.getSize();
|
||||||
// dim = this.clip_bounds;
|
// dim = this.clip_bounds;
|
||||||
|
|
||||||
// Dimension rv = this.getSize();
|
// Dimension rv = this.getSize();
|
||||||
// int yw = (int) (this.yl_width * em_size);
|
// int yw = (int) (this.yl_width * em_size);
|
||||||
|
|
||||||
// g.drawLine(dim.width + dim.x - yw, 0, dim.width + dim.x - yw, dim.height);
|
// g.drawLine(dim.width + dim.x - yw, 0, dim.width + dim.x - yw, dim.height);
|
||||||
|
|
||||||
|
|
||||||
float y1 = getY(minmax.getMin(false));
|
float y1 = getY(minmax.getMin(false));
|
||||||
float y2 = getY(minmax.getMax(false));
|
float y2 = getY(minmax.getMax(false));
|
||||||
float ydiff = y1 - y2;
|
float ydiff = y1 - y2;
|
||||||
@ -91,7 +90,6 @@ public class YLegendPainter extends OHLCChartPainter {
|
|||||||
// v1 = ctx.getValAtY(y1);
|
// v1 = ctx.getValAtY(y1);
|
||||||
// v2 = ctx.getValAtY(y2);
|
// v2 = ctx.getValAtY(y2);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,7 +97,43 @@ public class YLegendPainter extends OHLCChartPainter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void drawChart_old(Graphics2D g, ChartPanel p, ChartDef def) {
|
||||||
|
init(g);
|
||||||
|
this.master = def.mainChart;
|
||||||
|
|
||||||
|
OHLCData da = getData();
|
||||||
|
|
||||||
|
Dimension dim = def.mainChart.getSize();
|
||||||
|
int first_bar = getFirstBar(master);
|
||||||
|
int last_bar = first_bar + getBars(master, def);
|
||||||
|
MinMax minmax = this.getData().getMinMax(first_bar, last_bar);
|
||||||
|
|
||||||
|
this.initGetY(minmax, dim);
|
||||||
|
|
||||||
|
this.getRoundNumber(90);
|
||||||
|
|
||||||
|
//Rectangle dim;
|
||||||
|
// dim = p.getSize();
|
||||||
|
// dim = this.clip_bounds;
|
||||||
|
// Dimension rv = this.getSize();
|
||||||
|
// int yw = (int) (this.yl_width * em_size);
|
||||||
|
// g.drawLine(dim.width + dim.x - yw, 0, dim.width + dim.x - yw, dim.height);
|
||||||
|
float y1 = getY(minmax.getMin(false));
|
||||||
|
float y2 = getY(minmax.getMax(false));
|
||||||
|
float ydiff = y1 - y2;
|
||||||
|
// System.out.printf("%s y1: %f, y2: %f, diff %f\n", Boolean.toString(c_mm.isLog()), y1, y2, ydiff);
|
||||||
|
int c_font_height = g.getFontMetrics().getHeight();
|
||||||
|
|
||||||
|
for (int yp = (int) y2; yp < y1; yp += em_size * 3) {
|
||||||
|
g.drawLine(0, yp, em_size, yp);
|
||||||
|
double v1 = getValAtY(yp);
|
||||||
|
g.drawString(String.format("%.2f", v1), em_size * 1.5f, yp + c_font_height / 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
double v1, v2;
|
||||||
|
// v1 = ctx.getValAtY(y1);
|
||||||
|
// v2 = ctx.getValAtY(y2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user