Added color to X-legend
This commit is contained in:
parent
5b9f21876c
commit
b5c21d6218
@ -34,7 +34,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
private int em_height;
|
private int em_height;
|
||||||
private int em_width;
|
private int em_width;
|
||||||
|
|
||||||
protected double x_legend_height = 3;
|
protected double x_legend_height = 6;
|
||||||
|
|
||||||
protected double x_unit_width = 1.0;
|
protected double x_unit_width = 1.0;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
initChart();
|
initChart();
|
||||||
initCtxMenu();
|
// initCtxMenu();
|
||||||
//setCompression(60000);
|
//setCompression(60000);
|
||||||
if (Globals.se == null) {
|
if (Globals.se == null) {
|
||||||
return;
|
return;
|
||||||
@ -78,7 +78,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
// scrollPane.setViewportView(this);
|
// scrollPane.setViewportView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] ctxMenuCompressionText = {
|
/* private String[] ctxMenuCompressionText = {
|
||||||
"5 s", "10 s", "15 s", "30 s",
|
"5 s", "10 s", "15 s", "30 s",
|
||||||
"1 m", "2 m", "5 m", "10 m", "15 m", "30 m",
|
"1 m", "2 m", "5 m", "10 m", "15 m", "30 m",
|
||||||
"1 h", "2 h", "4 h",
|
"1 h", "2 h", "4 h",
|
||||||
@ -112,7 +112,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
OHLCData data;
|
OHLCData data;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,9 +142,8 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
class XLegendDef {
|
class XLegendDef {
|
||||||
|
|
||||||
int big_tick = 10;
|
//int big_tick = 10;
|
||||||
long start;
|
// long start;
|
||||||
|
|
||||||
XLegendDef() {
|
XLegendDef() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -158,13 +157,23 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// height of xlegend in em
|
|
||||||
private int xlegend_height=9;
|
|
||||||
|
|
||||||
protected void setXLegendHeight(int h) {
|
protected void setXLegendHeight(int h) {
|
||||||
this.x_legend_height = h;
|
this.x_legend_height = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Color of X-legend
|
||||||
|
*/
|
||||||
|
protected Color xl_color = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Background color of X-legend
|
||||||
|
*/
|
||||||
|
protected Color xl_bgcolor = null;
|
||||||
|
/**
|
||||||
|
* Height of X-legend
|
||||||
|
*/
|
||||||
|
protected int xl_height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the one and only one X legend
|
* Draw the one and only one X legend
|
||||||
@ -180,10 +189,20 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
g.setClip(clip_bounds.x, clip_bounds.y, clip_bounds.width - yw, clip_bounds.height);
|
g.setClip(clip_bounds.x, clip_bounds.y, clip_bounds.width - yw, clip_bounds.height);
|
||||||
|
|
||||||
Dimension dim = getSize();
|
Dimension dim = getSize();
|
||||||
int y = dim.height - em_height * 3;
|
int y = dim.height - em_height * xl_height;
|
||||||
|
|
||||||
g.drawLine(0, y, dim.width, y);
|
g.drawLine(0, y, dim.width, y);
|
||||||
|
|
||||||
|
// Set background color
|
||||||
|
if (this.xl_bgcolor != null) {
|
||||||
|
Color cur = g.getColor();
|
||||||
|
g.setColor(xl_bgcolor);
|
||||||
|
g.fillRect(0, y, dim.width, em_height * xl_height);
|
||||||
|
g.drawRect(0, y, dim.width, em_height * xl_height);
|
||||||
|
g.setColor(cur);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
double x;
|
double x;
|
||||||
|
|
||||||
@ -415,8 +434,6 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
c_yscaling = c_rect.height / c_mm.getDiff();
|
c_yscaling = c_rect.height / c_mm.getDiff();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ctx.g.setClip(null);
|
ctx.g.setClip(null);
|
||||||
// ctx.g.setColor(Color.ORANGE);
|
// ctx.g.setColor(Color.ORANGE);
|
||||||
// ctx.g.setClip(ctx.rect.x, ctx.rect.y, ctx.rect.width, ctx.rect.height);
|
// ctx.g.setClip(ctx.rect.x, ctx.rect.y, ctx.rect.width, ctx.rect.height);
|
||||||
@ -453,8 +470,6 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
Color bgcolor = null;
|
Color bgcolor = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<ChartDef> charts = new ArrayList<>();
|
ArrayList<ChartDef> charts = new ArrayList<>();
|
||||||
@ -487,16 +502,12 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
this.setPreferredSize(new Dimension(pwidth, gdim.height));
|
this.setPreferredSize(new Dimension(pwidth, gdim.height));
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int h1 = 0;
|
int h1 = 0;
|
||||||
|
|
||||||
int loops = 0;
|
int loops = 0;
|
||||||
|
|
||||||
for (ChartDef d : charts) {
|
for (ChartDef d : charts) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (d.type) {
|
switch (d.type) {
|
||||||
case VOL:
|
case VOL:
|
||||||
c_mm = d.data.getVolMinMax(first_bar, last_bar);
|
c_mm = d.data.getVolMinMax(first_bar, last_bar);
|
||||||
@ -507,7 +518,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cheight = gdim.height - 6 * em_width;
|
int cheight = gdim.height - (xl_height * 2) * em_width;
|
||||||
|
|
||||||
int h = (int) (cheight * d.height);
|
int h = (int) (cheight * d.height);
|
||||||
|
|
||||||
@ -527,7 +538,6 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
logs = false;
|
logs = false;
|
||||||
c_mm.setLog(false);
|
c_mm.setLog(false);
|
||||||
|
|
||||||
|
|
||||||
if (d.bgcolor != null) {
|
if (d.bgcolor != null) {
|
||||||
Color cur = g.getColor();
|
Color cur = g.getColor();
|
||||||
ctx.g.setColor(d.bgcolor);
|
ctx.g.setColor(d.bgcolor);
|
||||||
@ -536,7 +546,6 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
ctx.g.setColor(cur);
|
ctx.g.setColor(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
drawChart(ctx);
|
drawChart(ctx);
|
||||||
|
|
||||||
h1 = h + em_width;
|
h1 = h + em_width;
|
||||||
@ -562,7 +571,6 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
// if (c_mm == null) {
|
// if (c_mm == null) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
em_height = g.getFontMetrics().getHeight();
|
em_height = g.getFontMetrics().getHeight();
|
||||||
em_width = g.getFontMetrics().stringWidth("M");
|
em_width = g.getFontMetrics().stringWidth("M");
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,6 +21,9 @@ public class MainChart extends chart.Chart {
|
|||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
initCtxMenu();
|
initCtxMenu();
|
||||||
|
|
||||||
|
this.xl_bgcolor=Color.ORANGE;
|
||||||
|
this.xl_height=3;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCtxMenu(java.awt.event.MouseEvent evt) {
|
private void showCtxMenu(java.awt.event.MouseEvent evt) {
|
||||||
|
Loading…
Reference in New Issue
Block a user