Working stop button
This commit is contained in:
parent
98965eed43
commit
efba812190
@ -119,17 +119,25 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu class="javax.swing.JMenu" name="jMenu1">
|
<Menu class="javax.swing.JMenu" name="simMenu">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Sim"/>
|
<Property name="text" type="java.lang.String" value="Sim"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem4">
|
<MenuItem class="javax.swing.JMenuItem" name="simMenuStart">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Start"/>
|
<Property name="text" type="java.lang.String" value="Start"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem4ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="simMenuStartActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="simMenuPause">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Pause"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="simMenuPauseActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
|
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
|
||||||
|
@ -141,8 +141,9 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
deleteMenuItem = new javax.swing.JMenuItem();
|
deleteMenuItem = new javax.swing.JMenuItem();
|
||||||
jSeparator2 = new javax.swing.JPopupMenu.Separator();
|
jSeparator2 = new javax.swing.JPopupMenu.Separator();
|
||||||
editPreferences = new javax.swing.JMenuItem();
|
editPreferences = new javax.swing.JMenuItem();
|
||||||
jMenu1 = new javax.swing.JMenu();
|
simMenu = new javax.swing.JMenu();
|
||||||
jMenuItem4 = new javax.swing.JMenuItem();
|
simMenuStart = new javax.swing.JMenuItem();
|
||||||
|
simMenuPause = new javax.swing.JMenuItem();
|
||||||
jMenuItem5 = new javax.swing.JMenuItem();
|
jMenuItem5 = new javax.swing.JMenuItem();
|
||||||
jMenuItem6 = new javax.swing.JMenuItem();
|
jMenuItem6 = new javax.swing.JMenuItem();
|
||||||
viewMenu = new javax.swing.JMenu();
|
viewMenu = new javax.swing.JMenu();
|
||||||
@ -337,18 +338,26 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
menuBar.add(editMenu);
|
menuBar.add(editMenu);
|
||||||
|
|
||||||
jMenu1.setText("Sim");
|
simMenu.setText("Sim");
|
||||||
|
|
||||||
jMenuItem4.setText("Start");
|
simMenuStart.setText("Start");
|
||||||
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
|
simMenuStart.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
jMenuItem4ActionPerformed(evt);
|
simMenuStartActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
jMenu1.add(jMenuItem4);
|
simMenu.add(simMenuStart);
|
||||||
|
|
||||||
|
simMenuPause.setText("Pause");
|
||||||
|
simMenuPause.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
simMenuPauseActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
simMenu.add(simMenuPause);
|
||||||
|
|
||||||
jMenuItem5.setText("Stop");
|
jMenuItem5.setText("Stop");
|
||||||
jMenu1.add(jMenuItem5);
|
simMenu.add(jMenuItem5);
|
||||||
|
|
||||||
jMenuItem6.setText("Reset");
|
jMenuItem6.setText("Reset");
|
||||||
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
|
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
|
||||||
@ -356,9 +365,9 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
jMenuItem6ActionPerformed(evt);
|
jMenuItem6ActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
jMenu1.add(jMenuItem6);
|
simMenu.add(jMenuItem6);
|
||||||
|
|
||||||
menuBar.add(jMenu1);
|
menuBar.add(simMenu);
|
||||||
|
|
||||||
viewMenu.setText("View");
|
viewMenu.setText("View");
|
||||||
|
|
||||||
@ -448,6 +457,10 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
}//GEN-LAST:event_aboutMenuItemActionPerformed
|
}//GEN-LAST:event_aboutMenuItemActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
void pauseSim(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void startSim(){
|
void startSim(){
|
||||||
resetSim();
|
resetSim();
|
||||||
this.startTraders();
|
this.startTraders();
|
||||||
@ -577,9 +590,9 @@ startSim();
|
|||||||
// TODO add your handling code here:
|
// TODO add your handling code here:
|
||||||
}//GEN-LAST:event_jMenuItem1ActionPerformed
|
}//GEN-LAST:event_jMenuItem1ActionPerformed
|
||||||
|
|
||||||
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
|
private void simMenuStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simMenuStartActionPerformed
|
||||||
startSim();
|
startSim();
|
||||||
}//GEN-LAST:event_jMenuItem4ActionPerformed
|
}//GEN-LAST:event_simMenuStartActionPerformed
|
||||||
|
|
||||||
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
|
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
|
||||||
resetSim();
|
resetSim();
|
||||||
@ -592,6 +605,10 @@ startSim();
|
|||||||
stopSim();
|
stopSim();
|
||||||
}//GEN-LAST:event_jButton1ActionPerformed
|
}//GEN-LAST:event_jButton1ActionPerformed
|
||||||
|
|
||||||
|
private void simMenuPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simMenuPauseActionPerformed
|
||||||
|
// TODO add your handling code here:
|
||||||
|
}//GEN-LAST:event_simMenuPauseActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
* @throws java.lang.IllegalAccessException
|
* @throws java.lang.IllegalAccessException
|
||||||
@ -661,11 +678,9 @@ startSim();
|
|||||||
private javax.swing.JButton jButton1;
|
private javax.swing.JButton jButton1;
|
||||||
private javax.swing.JButton jButton2;
|
private javax.swing.JButton jButton2;
|
||||||
private javax.swing.JScrollPane jChartScrollPane;
|
private javax.swing.JScrollPane jChartScrollPane;
|
||||||
private javax.swing.JMenu jMenu1;
|
|
||||||
private javax.swing.JMenuItem jMenuItem1;
|
private javax.swing.JMenuItem jMenuItem1;
|
||||||
private javax.swing.JMenuItem jMenuItem2;
|
private javax.swing.JMenuItem jMenuItem2;
|
||||||
private javax.swing.JMenuItem jMenuItem3;
|
private javax.swing.JMenuItem jMenuItem3;
|
||||||
private javax.swing.JMenuItem jMenuItem4;
|
|
||||||
private javax.swing.JMenuItem jMenuItem5;
|
private javax.swing.JMenuItem jMenuItem5;
|
||||||
private javax.swing.JMenuItem jMenuItem6;
|
private javax.swing.JMenuItem jMenuItem6;
|
||||||
private javax.swing.JPanel jPanel2;
|
private javax.swing.JPanel jPanel2;
|
||||||
@ -681,6 +696,9 @@ startSim();
|
|||||||
private javax.swing.JMenuItem pasteMenuItem;
|
private javax.swing.JMenuItem pasteMenuItem;
|
||||||
private javax.swing.JMenuItem saveAsMenuItem;
|
private javax.swing.JMenuItem saveAsMenuItem;
|
||||||
private javax.swing.JMenuItem saveMenuItem;
|
private javax.swing.JMenuItem saveMenuItem;
|
||||||
|
private javax.swing.JMenu simMenu;
|
||||||
|
private javax.swing.JMenuItem simMenuPause;
|
||||||
|
private javax.swing.JMenuItem simMenuStart;
|
||||||
private javax.swing.JMenuItem viewClock;
|
private javax.swing.JMenuItem viewClock;
|
||||||
private javax.swing.JMenu viewMenu;
|
private javax.swing.JMenu viewMenu;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
@ -58,9 +58,6 @@ public class Exchange {
|
|||||||
|
|
||||||
public Scheduler timer; // = new Scheduler();
|
public Scheduler timer; // = new Scheduler();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<AutoTrader> traders;
|
public ArrayList<AutoTrader> traders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +223,6 @@ public class Exchange {
|
|||||||
*/
|
*/
|
||||||
public TreeSet<Quote> quoteHistory; // = new TreeSet<>();
|
public TreeSet<Quote> quoteHistory; // = new TreeSet<>();
|
||||||
|
|
||||||
|
|
||||||
final void initExchange() {
|
final void initExchange() {
|
||||||
timer = new Scheduler(); // timer = new Scheduler();
|
timer = new Scheduler(); // timer = new Scheduler();
|
||||||
random = new Random(12);
|
random = new Random(12);
|
||||||
@ -237,7 +233,6 @@ public class Exchange {
|
|||||||
|
|
||||||
num_trades = 0;
|
num_trades = 0;
|
||||||
|
|
||||||
|
|
||||||
// Create order books
|
// Create order books
|
||||||
order_books = new HashMap();
|
order_books = new HashMap();
|
||||||
for (OrderType type : OrderType.values()) {
|
for (OrderType type : OrderType.values()) {
|
||||||
@ -254,9 +249,6 @@ public class Exchange {
|
|||||||
|
|
||||||
initExchange();
|
initExchange();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Statistics {
|
public class Statistics {
|
||||||
@ -265,7 +257,6 @@ public class Exchange {
|
|||||||
public long orders;
|
public long orders;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Statistics statistics;
|
Statistics statistics;
|
||||||
|
|
||||||
long num_trades = 0;
|
long num_trades = 0;
|
||||||
@ -279,8 +270,6 @@ public class Exchange {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the exchange
|
* Start the exchange
|
||||||
*/
|
*/
|
||||||
@ -296,8 +285,6 @@ public class Exchange {
|
|||||||
timer.terminate();
|
timer.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
class BidBook extends TreeSet {
|
class BidBook extends TreeSet {
|
||||||
|
|
||||||
@ -309,7 +296,6 @@ public class Exchange {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public SortedSet<Quote> getQuoteHistory(long start) {
|
public SortedSet<Quote> getQuoteHistory(long start) {
|
||||||
|
|
||||||
Quote s = new Quote();
|
Quote s = new Quote();
|
||||||
@ -497,7 +483,6 @@ public class Exchange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int randNextInt(int bounds) {
|
public int randNextInt(int bounds) {
|
||||||
|
|
||||||
return random.nextInt(bounds);
|
return random.nextInt(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,8 +512,6 @@ public class Exchange {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -104,8 +104,8 @@ public class Scheduler extends Thread {
|
|||||||
*/
|
*/
|
||||||
public long currentTimeMillis1() {
|
public long currentTimeMillis1() {
|
||||||
|
|
||||||
long diff = System.currentTimeMillis() - last_time_millis;
|
long diff = System.currentTimeMillis() - last_time_millis+1;
|
||||||
// diff=121L;
|
diff=12199999L;
|
||||||
last_time_millis += diff;
|
last_time_millis += diff;
|
||||||
this.current_time_millis += diff * this.multiplier;
|
this.current_time_millis += diff * this.multiplier;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user