Drawing logarithmic charts
This commit is contained in:
parent
0603bbc0d3
commit
17e1c30c31
@ -29,7 +29,6 @@
|
|||||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||||
<Border info="null"/>
|
<Border info="null"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="doubleBuffered" type="boolean" value="false"/>
|
|
||||||
<Property name="opaque" type="boolean" value="false"/>
|
<Property name="opaque" type="boolean" value="false"/>
|
||||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
<Dimension value="[300, 300]"/>
|
<Dimension value="[300, 300]"/>
|
||||||
|
@ -176,8 +176,13 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
*/
|
*/
|
||||||
void drawXLegend(Graphics2D g, XLegendDef xld) {
|
void drawXLegend(Graphics2D g, XLegendDef xld) {
|
||||||
|
|
||||||
|
|
||||||
g = (Graphics2D) g.create();
|
g = (Graphics2D) g.create();
|
||||||
|
|
||||||
|
int yw = (int) (this.y_legend_width * this.em_size);
|
||||||
|
|
||||||
|
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 * 3;
|
||||||
|
|
||||||
@ -488,6 +493,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
ctx.iwidth = (float) ((x_unit_width * em_size) * 0.9f);
|
ctx.iwidth = (float) ((x_unit_width * em_size) * 0.9f);
|
||||||
|
|
||||||
this.ct = ChartType.CANDLESTICK;
|
this.ct = ChartType.CANDLESTICK;
|
||||||
|
logs=true;
|
||||||
drawChart(ctx);
|
drawChart(ctx);
|
||||||
|
|
||||||
c_mm = data.getVolMinMax(first_bar, last_bar);
|
c_mm = data.getVolMinMax(first_bar, last_bar);
|
||||||
@ -510,6 +516,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
ctx.g = g;
|
ctx.g = g;
|
||||||
ctx.iwidth = (float) ((x_unit_width * em_size) * 0.9f);
|
ctx.iwidth = (float) ((x_unit_width * em_size) * 0.9f);
|
||||||
|
|
||||||
|
logs=false;
|
||||||
this.ct = ChartType.VOL;
|
this.ct = ChartType.VOL;
|
||||||
drawChart(ctx);
|
drawChart(ctx);
|
||||||
|
|
||||||
@ -519,6 +526,9 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void paintComponent(Graphics g) {
|
public final void paintComponent(Graphics g) {
|
||||||
|
if (Globals.se==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
// Calculate the number of pixels for 1 em
|
// Calculate the number of pixels for 1 em
|
||||||
@ -569,7 +579,6 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
setBackground(java.awt.Color.white);
|
setBackground(java.awt.Color.white);
|
||||||
setBorder(null);
|
setBorder(null);
|
||||||
setDoubleBuffered(false);
|
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
setPreferredSize(new java.awt.Dimension(300, 300));
|
setPreferredSize(new java.awt.Dimension(300, 300));
|
||||||
setRequestFocusEnabled(false);
|
setRequestFocusEnabled(false);
|
||||||
@ -615,10 +624,9 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
private void formMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_formMouseWheelMoved
|
private void formMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_formMouseWheelMoved
|
||||||
System.out.printf("Wheel %f\n", evt.getPreciseWheelRotation());
|
System.out.printf("Wheel %f\n", evt.getPreciseWheelRotation());
|
||||||
|
|
||||||
double n = evt.getPreciseWheelRotation()*(-1.0);
|
double n = evt.getPreciseWheelRotation() * (-1.0);
|
||||||
|
|
||||||
|
System.out.printf("My n %f\n", n);
|
||||||
System.out.printf("My n %f\n",n);
|
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (this.x_unit_width > 0.3) {
|
if (this.x_unit_width > 0.3) {
|
||||||
this.x_unit_width += 0.1 * n;
|
this.x_unit_width += 0.1 * n;
|
||||||
@ -632,9 +640,12 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
}//GEN-LAST:event_formMouseWheelMoved
|
}//GEN-LAST:event_formMouseWheelMoved
|
||||||
|
|
||||||
void setCompression(int timeFrame) {
|
void setCompression(int timeFrame) {
|
||||||
data = Globals.se.getOHLCdata(timeFrame);
|
javax.swing.SwingUtilities.invokeLater(() -> {
|
||||||
invalidate();
|
data = Globals.se.getOHLCdata(timeFrame);
|
||||||
repaint();
|
invalidate();
|
||||||
|
repaint();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user