SMA Indicator, tests ...

This commit is contained in:
7u83 2017-11-18 14:24:09 +01:00
parent db42dfd43c
commit 35a6bf4e45
3 changed files with 20 additions and 48 deletions

View File

@ -36,6 +36,7 @@
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderLoader.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderLoader.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/traders/ManTrader/ManTrader.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/traders/ManTrader/ManTrader.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/chart/painter/ChartPainter.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/chart/painter/ChartPainter.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/OHLCDataProvider.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/traders/RandomTraderB.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/traders/RandomTraderB.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/Logger.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/Logger.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/gui/EditPreferencesDialog.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/gui/EditPreferencesDialog.java</file>

View File

@ -1,7 +1,6 @@
package chart; package chart;
import chart.painter.ChartPainter; import chart.painter.ChartPainter;
import chart.painter.XLegendPainter;
import gui.Globals; import gui.Globals;
import java.awt.Cursor; import java.awt.Cursor;
@ -16,19 +15,15 @@ import java.awt.event.AdjustmentListener;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import sesim.OHLCData;
/** /**
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
*/ */
public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener { public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener {
public JScrollBar x_scrollbar=null; public JScrollBar x_scrollbar = null;
ChartDef chartDef; ChartDef chartDef;
public boolean mouseEntered=false; public boolean mouseEntered = false;
/** /**
* Creates new form Chart1 * Creates new form Chart1
@ -42,17 +37,20 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
/** /**
* Add a horizontal scrollbar * Add a horizontal scrollbar
* @param x_scrollbar *
* @param x_scrollbar
*/ */
public void setXSCrollBar(JScrollBar x_scrollbar){ public void setXSCrollBar(JScrollBar x_scrollbar) {
if (this.x_scrollbar!=null) if (this.x_scrollbar != null) {
this.x_scrollbar.removeAdjustmentListener(this); this.x_scrollbar.removeAdjustmentListener(this);
this.x_scrollbar=x_scrollbar; }
if (this.x_scrollbar!=null) this.x_scrollbar = x_scrollbar;
if (this.x_scrollbar != null) {
this.x_scrollbar.addAdjustmentListener(this); this.x_scrollbar.addAdjustmentListener(this);
}
} }
public void setChartDef(ChartDef def){ public void setChartDef(ChartDef def) {
chartDef = def; chartDef = def;
} }
@ -65,17 +63,15 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
public void addChartPainter(ChartPainter p) { public void addChartPainter(ChartPainter p) {
chartPainters.add(p); chartPainters.add(p);
} }
public void deleteAllChartPinters(){ public void deleteAllChartPinters() {
chartPainters = new ArrayList<>(); chartPainters = new ArrayList<>();
} }
public boolean delChartPainter(ChartPainter p){ public boolean delChartPainter(ChartPainter p) {
return true; return true;
} }
// OHLCData data;
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
@ -84,14 +80,6 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
return; return;
} }
//this.x_scrollbar.setMaximum(994000);
// XLegendPainter p = new XLegendPainter();
//data = Globals.se.getOHLCdata(60000 * 60);
// ChartDef def = new ChartDef();
// def.x_unit_width = 1.0;
// def.x_scrollbar = x_scrollbar;
for (ChartPainter painter : chartPainters) { for (ChartPainter painter : chartPainters) {
painter.drawChart((Graphics2D) g, this, chartDef); painter.drawChart((Graphics2D) g, this, chartDef);
} }
@ -144,12 +132,12 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
}//GEN-LAST:event_formMouseMoved }//GEN-LAST:event_formMouseMoved
private void formMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseEntered private void formMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseEntered
this.mouseEntered=true; this.mouseEntered = true;
}//GEN-LAST:event_formMouseEntered }//GEN-LAST:event_formMouseEntered
private void formMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseExited private void formMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseExited
this.mouseEntered=false; this.mouseEntered = false;
}//GEN-LAST:event_formMouseExited }//GEN-LAST:event_formMouseExited
@Override @Override
@ -158,7 +146,6 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
this.repaint(); this.repaint();
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -249,26 +249,10 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver {
@Override @Override
public void UpdateQuote(Quote q) { public void UpdateQuote(Quote q) {
// OHLCData data = this.get();
int s = data.size(); int s = data.size();
this.xScrollBar.setMaximum(s); this.xScrollBar.setMaximum(s);
repaint(); repaint();
} }
OHLCData mydata = null;
/*
public OHLCData get() {
OHLCData re = Globals.se.getOHLCdata(60000 * 10);
if (re != mydata) {
System.out.printf("re != a\n");
}
if (mydata == null) {
mydata = Globals.se.getOHLCdata(60000 * 10);
}
return mydata;
}
*/
} }