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