OpenSeSim/src/main/java/gui/NewMDIApplication.java

619 lines
26 KiB
Java
Raw Normal View History

2017-01-15 18:15:22 +01:00
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
2017-01-22 21:41:45 +01:00
import java.awt.Dialog;
2017-01-31 08:04:11 +01:00
import java.awt.Frame;
import java.io.File;
2017-02-02 18:39:55 +01:00
import java.lang.reflect.Modifier;
2017-01-25 00:24:53 +01:00
import java.util.ArrayList;
2017-01-28 15:34:24 +01:00
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
2017-01-25 02:52:49 +01:00
import java.util.prefs.Preferences;
import javax.swing.JFileChooser;
2017-01-25 02:52:49 +01:00
import javax.swing.UIManager;
2017-01-31 08:04:11 +01:00
import javax.swing.filechooser.FileNameExtensionFilter;
2017-01-30 22:18:10 +01:00
import org.json.JSONArray;
import org.json.JSONObject;
2017-01-22 21:41:45 +01:00
import sesim.AutoTrader;
import sesim.AutoTraderConfig;
import sesim.Exchange;
import traders.RandomTraderConfig;
2017-01-15 18:15:22 +01:00
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewMDIApplication extends javax.swing.JFrame {
/**
* Creates new form NewMDIApplication
*/
public NewMDIApplication() {
initComponents();
2017-01-22 21:41:45 +01:00
this.setLocationRelativeTo(this);
this.setTitle("SeSim - Stock Exchange Simmulator");
}
public void startTraders() {
2017-01-30 22:18:10 +01:00
JSONArray tlist = Globals.getTraders();
2017-02-02 18:39:55 +01:00
Double moneyTotal=0.0;
Double sharesTotal=0.0;
2017-01-30 22:18:10 +01:00
for (int i=0; i<tlist.length();i++){
JSONObject t=tlist.getJSONObject(i);
String strategy_name = t.getString("Strategy");
JSONObject strategy = Globals.getStrategy(strategy_name);
String base = strategy.getString("base");
AutoTraderConfig ac = Globals.tloader.getStrategyBase(base);
System.out.printf("Load Strat: %s\n",strategy_name);
System.out.printf("Base %s\n", base);
Integer count = t.getInt("Count");
Double shares = t.getDouble("Shares");
Double money = t.getDouble("Money");
System.out.printf("Count: %d Shares: %f Money %f\n", count,shares,money);
for (int i1=0;i1<count;i1++){
AutoTrader trader = ac.createTrader(Globals.se, strategy, money, shares);
Globals.se.traders.add(trader);
2017-02-02 18:39:55 +01:00
trader.setName(t.getString("Name")+i1);
moneyTotal+=money;
sharesTotal+=shares;
// trader.start();
2017-01-30 22:18:10 +01:00
}
2017-02-02 18:39:55 +01:00
}
Globals.se.fairValue=moneyTotal/sharesTotal;
for (int i=0; i<Globals.se.traders.size(); i++){
Globals.se.traders.get(i).start();
2017-01-30 22:18:10 +01:00
}
// System.exit(0);
/*
2017-01-22 21:41:45 +01:00
AutoTraderConfig cfg1 = new RandomTraderConfig();
2017-01-28 15:34:24 +01:00
AutoTrader rt1 = cfg1.createTrader(Globals.se, null, 100000, 100000);
2017-01-22 21:41:45 +01:00
Globals.se.traders.add(rt1);
2017-01-25 02:52:49 +01:00
2017-01-22 21:41:45 +01:00
rt1.setName("Alice");
rt1.start();
AutoTraderConfig cfg2 = new RandomTraderConfig();
2017-01-25 00:24:53 +01:00
for (int i = 0; i < 700; i++) {
2017-01-28 15:34:24 +01:00
AutoTrader randt = cfg2.createTrader(Globals.se, null, 100, 100);
2017-01-22 21:41:45 +01:00
Globals.se.traders.add(randt);
randt.setName("Bob");
randt.start();
}
2017-01-30 22:18:10 +01:00
*/
2017-01-22 21:41:45 +01:00
2017-01-15 18:15:22 +01:00
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
2017-01-28 15:34:24 +01:00
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
2017-01-22 21:41:45 +01:00
orderBookPanel1 = new gui.OrderBookPanel();
2017-01-23 18:56:09 +01:00
jScrollPane1 = new javax.swing.JScrollPane();
chart1 = new chart.Chart();
2017-02-03 01:56:41 +01:00
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jRunButton = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jSpinner2 = new javax.swing.JSpinner();
clock1 = new gui.Clock();
2017-01-15 18:15:22 +01:00
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
openMenuItem = new javax.swing.JMenuItem();
saveMenuItem = new javax.swing.JMenuItem();
saveAsMenuItem = new javax.swing.JMenuItem();
exitMenuItem = new javax.swing.JMenuItem();
editMenu = new javax.swing.JMenu();
2017-01-31 08:04:11 +01:00
editExchangeMenuItem = new javax.swing.JMenuItem();
2017-01-28 15:34:24 +01:00
jSeparator1 = new javax.swing.JPopupMenu.Separator();
2017-01-15 18:15:22 +01:00
pasteMenuItem = new javax.swing.JMenuItem();
deleteMenuItem = new javax.swing.JMenuItem();
2017-01-28 15:34:24 +01:00
jSeparator2 = new javax.swing.JPopupMenu.Separator();
2017-01-22 21:41:45 +01:00
editPreferences = new javax.swing.JMenuItem();
2017-02-02 18:39:55 +01:00
viewMenu = new javax.swing.JMenu();
2017-01-22 21:41:45 +01:00
jMenuItem2 = new javax.swing.JMenuItem();
2017-01-28 15:34:24 +01:00
jMenuItem3 = new javax.swing.JMenuItem();
2017-02-02 18:39:55 +01:00
viewClock = new javax.swing.JMenuItem();
2017-01-15 18:15:22 +01:00
helpMenu = new javax.swing.JMenu();
contentMenuItem = new javax.swing.JMenuItem();
aboutMenuItem = new javax.swing.JMenuItem();
2017-01-28 15:34:24 +01:00
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jTextArea1.setText("Hakke");
jScrollPane2.setViewportView(jTextArea1);
2017-01-15 18:15:22 +01:00
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
2017-01-22 21:41:45 +01:00
setMinimumSize(new java.awt.Dimension(640, 480));
setPreferredSize(new java.awt.Dimension(800, 561));
2017-02-03 01:56:41 +01:00
javax.swing.GroupLayout chart1Layout = new javax.swing.GroupLayout(chart1);
chart1.setLayout(chart1Layout);
chart1Layout.setHorizontalGroup(
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
chart1Layout.setVerticalGroup(
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
jScrollPane1.setViewportView(chart1);
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Stop24.gif"))); // NOI18N
jButton1.setText("Stop");
jButton1.setFocusable(false);
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
2017-01-22 21:41:45 +01:00
2017-02-03 01:56:41 +01:00
jRunButton.setFont(jRunButton.getFont());
2017-01-30 16:52:55 +01:00
jRunButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/run.gif"))); // NOI18N
jRunButton.setText("Run sim!");
jRunButton.setToolTipText("Run the simmulation");
jRunButton.setFocusable(false);
jRunButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jRunButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jRunButton.addActionListener(new java.awt.event.ActionListener() {
2017-01-22 21:41:45 +01:00
public void actionPerformed(java.awt.event.ActionEvent evt) {
2017-01-30 16:52:55 +01:00
jRunButtonActionPerformed(evt);
2017-01-22 21:41:45 +01:00
}
});
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pause.gif"))); // NOI18N
jButton2.setText("Pause");
jButton2.setFocusable(false);
jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
2017-02-03 08:47:43 +01:00
jSpinner2.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 10000.0d, 0.1d));
2017-02-03 01:56:41 +01:00
jSpinner2.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
jSpinner2StateChanged(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jRunButton, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(clock1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(17, 17, 17)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
2017-01-22 21:41:45 +01:00
);
2017-02-03 01:56:41 +01:00
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRunButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(clock1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(9, Short.MAX_VALUE))
2017-01-22 21:41:45 +01:00
);
2017-01-15 18:15:22 +01:00
fileMenu.setMnemonic('f');
fileMenu.setText("File");
openMenuItem.setMnemonic('o');
openMenuItem.setText("Open");
2017-01-31 08:04:11 +01:00
openMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
openMenuItemActionPerformed(evt);
}
});
2017-01-15 18:15:22 +01:00
fileMenu.add(openMenuItem);
saveMenuItem.setMnemonic('s');
saveMenuItem.setText("Save");
fileMenu.add(saveMenuItem);
saveAsMenuItem.setMnemonic('a');
saveAsMenuItem.setText("Save As ...");
saveAsMenuItem.setDisplayedMnemonicIndex(5);
2017-01-31 08:04:11 +01:00
saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveAsMenuItemActionPerformed(evt);
}
});
2017-01-15 18:15:22 +01:00
fileMenu.add(saveAsMenuItem);
exitMenuItem.setMnemonic('x');
exitMenuItem.setText("Exit");
exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitMenuItemActionPerformed(evt);
}
});
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);
editMenu.setMnemonic('e');
editMenu.setText("Edit");
2017-01-31 08:04:11 +01:00
editExchangeMenuItem.setMnemonic('y');
editExchangeMenuItem.setText("Exchange ...");
editExchangeMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
editExchangeMenuItemActionPerformed(evt);
}
});
editMenu.add(editExchangeMenuItem);
2017-01-28 15:34:24 +01:00
editMenu.add(jSeparator1);
2017-01-15 18:15:22 +01:00
2017-01-26 01:52:03 +01:00
pasteMenuItem.setMnemonic('s');
pasteMenuItem.setText("Strategies ...");
pasteMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pasteMenuItemActionPerformed(evt);
}
});
2017-01-15 18:15:22 +01:00
editMenu.add(pasteMenuItem);
deleteMenuItem.setMnemonic('d');
deleteMenuItem.setText("Traders ...");
deleteMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
deleteMenuItemActionPerformed(evt);
}
});
2017-01-15 18:15:22 +01:00
editMenu.add(deleteMenuItem);
2017-01-28 15:34:24 +01:00
editMenu.add(jSeparator2);
2017-01-15 18:15:22 +01:00
2017-01-22 21:41:45 +01:00
editPreferences.setMnemonic('p');
editPreferences.setText("Preferences ...");
editPreferences.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
editPreferencesActionPerformed(evt);
}
});
editMenu.add(editPreferences);
2017-01-15 18:15:22 +01:00
menuBar.add(editMenu);
2017-02-02 18:39:55 +01:00
viewMenu.setText("View");
2017-01-22 21:41:45 +01:00
jMenuItem2.setText("Traders");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
2017-02-02 18:39:55 +01:00
viewMenu.add(jMenuItem2);
2017-01-22 21:41:45 +01:00
2017-01-28 15:34:24 +01:00
jMenuItem3.setText("LogWindow");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
2017-02-02 18:39:55 +01:00
viewMenu.add(jMenuItem3);
2017-01-28 15:34:24 +01:00
2017-02-02 18:39:55 +01:00
viewClock.setText("Clock");
viewClock.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
viewClockActionPerformed(evt);
}
});
viewMenu.add(viewClock);
menuBar.add(viewMenu);
2017-01-22 21:41:45 +01:00
2017-01-15 18:15:22 +01:00
helpMenu.setMnemonic('h');
helpMenu.setText("Help");
contentMenuItem.setMnemonic('c');
contentMenuItem.setText("Contents");
helpMenu.add(contentMenuItem);
aboutMenuItem.setMnemonic('a');
aboutMenuItem.setText("About");
2017-01-22 21:41:45 +01:00
aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
aboutMenuItemActionPerformed(evt);
}
});
2017-01-15 18:15:22 +01:00
helpMenu.add(aboutMenuItem);
menuBar.add(helpMenu);
setJMenuBar(menuBar);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
2017-01-22 21:41:45 +01:00
.addGroup(layout.createSequentialGroup()
2017-02-03 01:56:41 +01:00
.addContainerGap()
2017-02-02 18:39:55 +01:00
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
2017-02-03 01:56:41 +01:00
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
2017-02-02 18:39:55 +01:00
.addGroup(layout.createSequentialGroup()
.addComponent(orderBookPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
2017-02-03 01:56:41 +01:00
.addComponent(jScrollPane1)))
2017-01-29 22:21:12 +01:00
.addContainerGap())
2017-01-15 18:15:22 +01:00
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
2017-01-22 21:41:45 +01:00
.addGroup(layout.createSequentialGroup()
2017-02-03 01:56:41 +01:00
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
2017-01-22 21:41:45 +01:00
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
2017-02-03 01:56:41 +01:00
.addComponent(jScrollPane1)
.addComponent(orderBookPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
2017-01-22 21:41:45 +01:00
.addContainerGap())
2017-01-15 18:15:22 +01:00
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
System.exit(0);
}//GEN-LAST:event_exitMenuItemActionPerformed
2017-01-22 21:41:45 +01:00
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
Dialog d = new gui.AboutDialog(this, rootPaneCheckingEnabled);
d.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_aboutMenuItemActionPerformed
2017-01-30 16:52:55 +01:00
private void jRunButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRunButtonActionPerformed
2017-01-22 21:41:45 +01:00
this.startTraders();
Globals.se.timer.start();
2017-01-30 16:52:55 +01:00
}//GEN-LAST:event_jRunButtonActionPerformed
2017-01-22 21:41:45 +01:00
private void editPreferencesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editPreferencesActionPerformed
2017-01-28 15:34:24 +01:00
Globals.LOGGER.info("Edit prefs...");
2017-01-22 21:41:45 +01:00
Dialog d = new gui.EditPreferencesDialog(this, rootPaneCheckingEnabled);
d.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_editPreferencesActionPerformed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
2017-01-23 18:56:09 +01:00
TraderListDialog d = new TraderListDialog(this, false);
2017-01-22 21:41:45 +01:00
d.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
Globals.se.timer.pause();
}//GEN-LAST:event_jButton2ActionPerformed
private void deleteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMenuItemActionPerformed
2017-01-28 15:34:24 +01:00
EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this, true);
2017-01-25 00:24:53 +01:00
ed.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_deleteMenuItemActionPerformed
2017-01-26 01:52:03 +01:00
private void pasteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pasteMenuItemActionPerformed
2017-01-28 15:34:24 +01:00
EditStrategies s = new EditStrategies(this, true);
2017-01-26 01:52:03 +01:00
s.setVisible(rootPaneCheckingEnabled);
2017-01-28 15:34:24 +01:00
2017-01-26 01:52:03 +01:00
}//GEN-LAST:event_pasteMenuItemActionPerformed
2017-01-28 15:34:24 +01:00
private final LoggerDialog log_d = new LoggerDialog(this,false);
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
log_d.setVisible(!log_d.isShowing());
}//GEN-LAST:event_jMenuItem3ActionPerformed
2017-01-31 08:04:11 +01:00
private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
}//GEN-LAST:event_openMenuItemActionPerformed
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
JFileChooser fc = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("SeSim Files","sesim");
fc.setFileFilter(filter);
2017-02-02 18:39:55 +01:00
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION){
2017-01-31 08:04:11 +01:00
return;
}
File f = fc.getSelectedFile();
String [] e = ((FileNameExtensionFilter)fc.getFileFilter()).getExtensions();
System.out.printf("Abs: %s\n", f.getAbsoluteFile());
String fn=f.getAbsolutePath();
if (!f.getAbsolutePath().endsWith(e[0])){
f = new File(f.getAbsolutePath()+"."+e[0]);
}
Globals.saveFile(f);
System.out.printf("Sel File: %s \n",f.getAbsolutePath());
}//GEN-LAST:event_saveAsMenuItemActionPerformed
private void editExchangeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editExchangeMenuItemActionPerformed
EditExchangeDialog ed=new EditExchangeDialog((Frame) this.getParent(),true);
int rc = ed.showdialog();
// System.out.printf("EDRET: %d\n",rc);
}//GEN-LAST:event_editExchangeMenuItemActionPerformed
2017-02-02 18:39:55 +01:00
private void viewClockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewClockActionPerformed
ClockDialog cd = new ClockDialog(this,true);
cd.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_viewClockActionPerformed
2017-02-03 01:56:41 +01:00
private void jSpinner2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner2StateChanged
Double val = (Double)this.jSpinner2.getValue();
Globals.se.timer.setMultiply(val);
}//GEN-LAST:event_jSpinner2StateChanged
2017-01-15 18:15:22 +01:00
/**
* @param args the command line arguments
2017-01-25 00:24:53 +01:00
* @throws java.lang.IllegalAccessException
* @throws java.lang.InstantiationException
2017-01-15 18:15:22 +01:00
*/
2017-01-25 00:24:53 +01:00
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
2017-01-22 21:41:45 +01:00
Globals.se = new Exchange();
2017-01-28 15:34:24 +01:00
2017-01-25 02:52:49 +01:00
class Tube {
2017-01-28 15:34:24 +01:00
2017-01-25 02:52:49 +01:00
}
2017-01-28 15:34:24 +01:00
2017-01-25 02:52:49 +01:00
Class<?> c = sesim.Exchange.class;
2017-01-28 15:34:24 +01:00
Globals.prefs = Preferences.userNodeForPackage(c);
2017-01-25 02:52:49 +01:00
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
2017-01-28 15:34:24 +01:00
/* try {
2017-01-25 02:52:49 +01:00
// Set cross-platform Java L&F (also called "Metal")
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
} catch (UnsupportedLookAndFeelException | ClassNotFoundException |
InstantiationException | IllegalAccessException e) {
}
2017-01-28 15:34:24 +01:00
*/
2017-01-25 00:24:53 +01:00
ArrayList<Class<AutoTraderConfig>> traders;
traders = null;
2017-01-26 01:52:03 +01:00
sesim.AutoTraderLoader tl = new sesim.AutoTraderLoader();
2017-01-25 00:24:53 +01:00
try {
2017-01-26 01:52:03 +01:00
traders = tl.getTraders();
2017-01-25 00:24:53 +01:00
} catch (Exception e) {
System.out.print("Execption\n");
}
2017-01-25 00:24:53 +01:00
for (Class<AutoTraderConfig> at_class : traders) {
2017-02-02 18:39:55 +01:00
System.out.printf("Class = %s\n",at_class.getName());
if (Modifier.isAbstract(at_class.getModifiers())) {
continue;
}
2017-01-25 00:24:53 +01:00
AutoTraderConfig cfg = at_class.newInstance();
2017-01-30 22:18:10 +01:00
System.out.printf("Have a Trader with name: %s\n", cfg.getDisplayName());
2017-01-25 00:24:53 +01:00
}
//System.exit(0);
2017-01-15 18:15:22 +01:00
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
2017-01-25 02:52:49 +01:00
// Globals.prefs = Preferences.userNodeForPackage(this)
2017-01-15 18:15:22 +01:00
new NewMDIApplication().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem aboutMenuItem;
2017-01-23 18:56:09 +01:00
private chart.Chart chart1;
2017-02-03 01:56:41 +01:00
private gui.Clock clock1;
2017-01-15 18:15:22 +01:00
private javax.swing.JMenuItem contentMenuItem;
private javax.swing.JMenuItem deleteMenuItem;
2017-01-31 08:04:11 +01:00
private javax.swing.JMenuItem editExchangeMenuItem;
2017-01-15 18:15:22 +01:00
private javax.swing.JMenu editMenu;
2017-01-22 21:41:45 +01:00
private javax.swing.JMenuItem editPreferences;
2017-01-15 18:15:22 +01:00
private javax.swing.JMenuItem exitMenuItem;
private javax.swing.JMenu fileMenu;
private javax.swing.JMenu helpMenu;
2017-02-03 01:56:41 +01:00
private javax.swing.JButton jButton1;
2017-01-22 21:41:45 +01:00
private javax.swing.JButton jButton2;
private javax.swing.JMenuItem jMenuItem2;
2017-01-28 15:34:24 +01:00
private javax.swing.JMenuItem jMenuItem3;
2017-02-03 01:56:41 +01:00
private javax.swing.JPanel jPanel2;
2017-01-30 16:52:55 +01:00
private javax.swing.JButton jRunButton;
2017-01-22 21:41:45 +01:00
private javax.swing.JScrollPane jScrollPane1;
2017-01-28 15:34:24 +01:00
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
2017-02-03 01:56:41 +01:00
private javax.swing.JSpinner jSpinner2;
2017-01-28 15:34:24 +01:00
private javax.swing.JTextArea jTextArea1;
2017-01-15 18:15:22 +01:00
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenuItem openMenuItem;
2017-01-22 21:41:45 +01:00
private gui.OrderBookPanel orderBookPanel1;
2017-01-15 18:15:22 +01:00
private javax.swing.JMenuItem pasteMenuItem;
private javax.swing.JMenuItem saveAsMenuItem;
private javax.swing.JMenuItem saveMenuItem;
2017-02-02 18:39:55 +01:00
private javax.swing.JMenuItem viewClock;
private javax.swing.JMenu viewMenu;
2017-01-15 18:15:22 +01:00
// End of variables declaration//GEN-END:variables
}