switched to ant build
This commit is contained in:
84
src/gui/AboutDialog.form
Normal file
84
src/gui/AboutDialog.form
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[400, 300]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="603" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="466" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" pref="27" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextPane" name="jTextPane1">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||
<FontInfo relative="true">
|
||||
<Font component="jTextPane1" property="font" relativeSize="true" size="0"/>
|
||||
</FontInfo>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="/*
 * 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.
 */"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Close"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
149
src/gui/AboutDialog.java
Normal file
149
src/gui/AboutDialog.java
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class AboutDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form aboutDialog
|
||||
*/
|
||||
public AboutDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(MainWin.instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jTextPane1 = new javax.swing.JTextPane();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(400, 300));
|
||||
|
||||
jTextPane1.setEditable(false);
|
||||
jTextPane1.setFont(jTextPane1.getFont());
|
||||
jTextPane1.setText("/*\n * Copyright (c) 2017, 7u83 <7u83@mail.ru>\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */");
|
||||
jScrollPane1.setViewportView(jTextPane1);
|
||||
|
||||
jButton1.setText("Close");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 603, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(jButton1)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(AboutDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(AboutDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(AboutDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(AboutDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
AboutDialog dialog = new AboutDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JTextPane jTextPane1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
55
src/gui/AskBook.java
Normal file
55
src/gui/AskBook.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import sesim.Exchange.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class AskBook extends OrderBook {
|
||||
|
||||
@Override
|
||||
ArrayList <Order> getOrderBook() {
|
||||
return Globals.se.getOrderBook(OrderType.SELLLIMIT,40);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean getDesc(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public AskBook(){
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
Globals.se.addBookReceiver(OrderType.SELLLIMIT, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
48
src/gui/BidBook.java
Normal file
48
src/gui/BidBook.java
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import sesim.Exchange.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class BidBook extends OrderBook {
|
||||
|
||||
@Override
|
||||
ArrayList<Order> getOrderBook() {
|
||||
return Globals.se.getOrderBook(OrderType.BUYLIMIT, 40);
|
||||
}
|
||||
|
||||
public BidBook() {
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
Globals.se.addBookReceiver(OrderType.BUYLIMIT, this);
|
||||
}
|
||||
}
|
28
src/gui/ChartPanel.form
Normal file
28
src/gui/ChartPanel.form
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
46
src/gui/ChartPanel.java
Normal file
46
src/gui/ChartPanel.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package gui;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ChartPanel extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form ChartPanel
|
||||
*/
|
||||
public ChartPanel() {
|
||||
initComponents();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
49
src/gui/Clock.form
Normal file
49
src/gui/Clock.form
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" pref="153" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||
<FontInfo relative="true">
|
||||
<Font bold="true" component="jLabel1" property="font" relativeSize="true" size="6"/>
|
||||
</FontInfo>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="text" type="java.lang.String" value="00:00:00"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
134
src/gui/Clock.java
Normal file
134
src/gui/Clock.java
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import sesim.Exchange.Statistics;
|
||||
import sesim.Scheduler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class Clock extends javax.swing.JPanel {
|
||||
|
||||
protected final Timer timer;
|
||||
TimerTask clockUpdater;
|
||||
|
||||
|
||||
class ClockUpdater implements sesim.Scheduler.TimerTaskRunner{
|
||||
|
||||
@Override
|
||||
public long timerTask() {
|
||||
long t = Globals.se.timer.currentTimeMillis();
|
||||
jLabel1.setText(Scheduler.formatTimeMillis(t));
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getID() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form Clock
|
||||
*/
|
||||
public Clock() {
|
||||
initComponents();
|
||||
|
||||
|
||||
this.timer = new Timer();
|
||||
|
||||
if(Globals.se==null)
|
||||
return;
|
||||
|
||||
|
||||
clockUpdater = new TimerTask () {
|
||||
@Override
|
||||
public void run() {
|
||||
long t = Globals.se.timer.currentTimeMillis();
|
||||
|
||||
|
||||
Statistics s = Globals.se.getStatistics();
|
||||
jLabel1.setText(Scheduler.formatTimeMillis(t));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
timer.schedule(clockUpdater, 0, 1000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b){
|
||||
System.out.printf("Visible: %s\n",Boolean.toString(b));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD, jLabel1.getFont().getSize()+6));
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel1.setText("00:00:00");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
58
src/gui/ClockDialog.form
Normal file
58
src/gui/ClockDialog.form
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="Clock"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="clock1" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="clock1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="gui.Clock" name="clock1">
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
144
src/gui/ClockDialog.java
Normal file
144
src/gui/ClockDialog.java
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2017, tobias
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tobias
|
||||
*/
|
||||
public class ClockDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form ClockDialog
|
||||
*/
|
||||
public ClockDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
clock1 = new gui.Clock();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Clock");
|
||||
|
||||
jButton1.setText("Ok");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(clock1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(jButton1)
|
||||
.addGap(59, 59, 59))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(clock1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton1)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
ClockDialog dialog = new ClockDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
super.dispose();
|
||||
this.clock1.timer.cancel();
|
||||
System.out.print("Disposed\n");
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.Clock clock1;
|
||||
private javax.swing.JButton jButton1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
107
src/gui/ControlPanel.form
Normal file
107
src/gui/ControlPanel.form
Normal file
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" pref="63" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" pref="50" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jTextField2" max="32767" attributes="0"/>
|
||||
<Component id="jTextField1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace pref="37" max="32767" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" pref="65" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" pref="70" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jTextField1" max="32767" attributes="0"/>
|
||||
<Component id="jLabel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" pref="25" max="-2" attributes="0"/>
|
||||
<Component id="jTextField2" alignment="0" min="-2" pref="27" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="358" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Byu"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Sell"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="325"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Shares:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Limit:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="127.00"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
145
src/gui/ControlPanel.java
Normal file
145
src/gui/ControlPanel.java
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ControlPanel extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form ControlPanel
|
||||
*/
|
||||
public ControlPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
jTextField1 = new javax.swing.JTextField();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jTextField2 = new javax.swing.JTextField();
|
||||
|
||||
jButton1.setText("Byu");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setText("Sell");
|
||||
|
||||
jTextField1.setText("325");
|
||||
jTextField1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jTextField1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText("Shares:");
|
||||
|
||||
jLabel2.setText("Limit:");
|
||||
|
||||
jTextField2.setText("127.00");
|
||||
jTextField2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jTextField2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jTextField2)
|
||||
.addComponent(jTextField1)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap(37, Short.MAX_VALUE)
|
||||
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jTextField1)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(jButton2))
|
||||
.addContainerGap(358, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jTextField2ActionPerformed
|
||||
|
||||
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jTextField1ActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JTextField jTextField1;
|
||||
private javax.swing.JTextField jTextField2;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
93
src/gui/EditAutoTraderList.form
Normal file
93
src/gui/EditAutoTraderList.form
Normal file
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="446" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="summary" min="-2" pref="264" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" min="-2" pref="257" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="summary" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="16" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="list">
|
||||
<Properties>
|
||||
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||
<Table columnCount="6" rowCount="2">
|
||||
<Column editable="true" title="Name" type="java.lang.String">
|
||||
<Data value="Alice"/>
|
||||
<Data value="Bob"/>
|
||||
</Column>
|
||||
<Column editable="true" title="Count" type="java.lang.Integer">
|
||||
<Data value="1"/>
|
||||
<Data value="1"/>
|
||||
</Column>
|
||||
<Column editable="true" title="Strategy" type="java.lang.Object">
|
||||
<Data value=""/>
|
||||
<Data value="null"/>
|
||||
</Column>
|
||||
<Column editable="true" title="Money" type="java.lang.Double">
|
||||
<Data value="10000.0"/>
|
||||
<Data value="1000.0"/>
|
||||
</Column>
|
||||
<Column editable="true" title="Shares" type="java.lang.Double">
|
||||
<Data value="100.0"/>
|
||||
<Data value="100.0"/>
|
||||
</Column>
|
||||
<Column editable="true" title="Enabled" type="java.lang.Boolean">
|
||||
<Data value="true"/>
|
||||
<Data value="true"/>
|
||||
</Column>
|
||||
</Table>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="summary">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jLabel1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
253
src/gui/EditAutoTraderList.java
Normal file
253
src/gui/EditAutoTraderList.java
Normal file
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import sesim.AutoTraderConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
|
||||
private String getColumnHeader(int i) {
|
||||
JTableHeader th = list.getTableHeader();
|
||||
return (String) th.getColumnModel().getColumn(i).getHeaderValue();
|
||||
|
||||
}
|
||||
|
||||
void save() {
|
||||
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||
JTableHeader th = list.getTableHeader();
|
||||
/*
|
||||
for (int i = 0; i < model.getColumnCount(); i++) {
|
||||
String hw = (String) th.getColumnModel().getColumn(i).getHeaderValue();
|
||||
}
|
||||
*/
|
||||
JSONArray ja = new JSONArray();
|
||||
|
||||
for (int i = 0; i < model.getRowCount(); i++) {
|
||||
JSONObject jo = new JSONObject();
|
||||
for (int x = 0; x < model.getColumnCount(); x++) {
|
||||
Object cw = model.getValueAt(i, x);
|
||||
|
||||
//System.out.printf("CWSaver: %s\n",cw.getClass().toString());
|
||||
if (cw != null) {
|
||||
jo.put((String) th.getColumnModel().getColumn(x).getHeaderValue(), cw.toString());
|
||||
}
|
||||
|
||||
}
|
||||
ja.put(jo);
|
||||
}
|
||||
|
||||
Globals.prefs.put("Traders", ja.toString());
|
||||
|
||||
}
|
||||
|
||||
final void load() {
|
||||
|
||||
JSONArray traders = Globals.getTraders();
|
||||
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||
model.setRowCount(traders.length());
|
||||
|
||||
for (int row = 0; row < traders.length(); row++) {
|
||||
JSONObject rowobj = traders.getJSONObject(row);
|
||||
for (int col = 0; col < list.getColumnCount(); col++) {
|
||||
String h = this.getColumnHeader(col);
|
||||
// System.out.printf("Doing stuff for %s\n", h);
|
||||
|
||||
String val = null;
|
||||
try {
|
||||
val = rowobj.getString(h);
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.printf("Want to set (%d,%d): %s\n", row, col, val);
|
||||
|
||||
//list.getModel().setValueAt(val, row, col);
|
||||
Class cl = list.getModel().getColumnClass(col);
|
||||
System.out.printf("The Class is: %s\n", cl.getName());
|
||||
Object cv = new Object();
|
||||
if (cl == Double.class) {
|
||||
cv = rowobj.getDouble(h);
|
||||
}
|
||||
if (cl == String.class) {
|
||||
cv = rowobj.getString(h);
|
||||
}
|
||||
if (cl == Integer.class) {
|
||||
cv = rowobj.getInt(h);
|
||||
}
|
||||
if (cl == Boolean.class) {
|
||||
cv = rowobj.getBoolean(h);
|
||||
}
|
||||
if (cl == Object.class) {
|
||||
cv = rowobj.getString(h);
|
||||
}
|
||||
list.getModel().setValueAt(cv, row, col);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DefaultTableModel model;
|
||||
|
||||
private double getFairValue() {
|
||||
Double money = 0.0;
|
||||
Double shares = 0.0;
|
||||
|
||||
for (int r = 0; r < model.getRowCount(); r++) {
|
||||
Boolean e = (Boolean) list.getValueAt(r, list.getColumn("Enabled").getModelIndex());
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
money += (Double) list.getValueAt(r, list.getColumn("Money").getModelIndex());
|
||||
shares += (Double) list.getValueAt(r, list.getColumn("Shares").getModelIndex());
|
||||
System.out.printf("Row: %d %f %f\n", r, money, shares);
|
||||
}
|
||||
return money / shares;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form NewJPanel
|
||||
*/
|
||||
public EditAutoTraderList() {
|
||||
initComponents();
|
||||
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.load();
|
||||
|
||||
JComboBox comboBox = new JComboBox();
|
||||
|
||||
Globals.getStrategiesIntoComboBox(comboBox);
|
||||
|
||||
model = (DefaultTableModel) list.getModel();
|
||||
list.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(comboBox));
|
||||
// list.getColumnModel().getColumn(2).setCellRenderer(new javax.swing.table.DefaultTableCellRenderer());
|
||||
// model.setRowCount(3);
|
||||
|
||||
list.setRowHeight(30);
|
||||
|
||||
list.getModel().addTableModelListener((TableModelEvent e) -> {
|
||||
this.summary.setText(String.format("Fair Value: %.5f", this.getFairValue()));
|
||||
|
||||
});
|
||||
this.summary.setText(String.format("Fair Value: %.5f", this.getFairValue()));
|
||||
}
|
||||
|
||||
void add() {
|
||||
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||
model.setRowCount(model.getRowCount() + 1);
|
||||
}
|
||||
|
||||
// JLabel summary = null;
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
list = new javax.swing.JTable();
|
||||
summary = new javax.swing.JLabel();
|
||||
|
||||
list.setAutoCreateRowSorter(true);
|
||||
list.setModel(new javax.swing.table.DefaultTableModel(
|
||||
new Object [][] {
|
||||
{"Alice", new Integer(1), "", new Double(10000.0), new Double(100.0), new Boolean(true)},
|
||||
{"Bob", new Integer(1), null, new Double(1000.0), new Double(100.0), new Boolean(true)}
|
||||
},
|
||||
new String [] {
|
||||
"Name", "Count", "Strategy", "Money", "Shares", "Enabled"
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.String.class, java.lang.Integer.class, java.lang.Object.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types [columnIndex];
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(list);
|
||||
|
||||
summary.setText("jLabel1");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(summary, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(summary)
|
||||
.addContainerGap(16, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JTable list;
|
||||
private javax.swing.JLabel summary;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
90
src/gui/EditAutoTraderListDialog.form
Normal file
90
src/gui/EditAutoTraderListDialog.form
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="editAutoTraderList1" pref="529" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jOkButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="editAutoTraderList1" pref="331" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jOkButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jOkButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jOkButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Add"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="gui.EditAutoTraderList" name="editAutoTraderList1">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
181
src/gui/EditAutoTraderListDialog.java
Normal file
181
src/gui/EditAutoTraderListDialog.java
Normal file
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class EditAutoTraderListDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form EditAutoTraderListDialog
|
||||
*/
|
||||
public EditAutoTraderListDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setTitle("Edit Auto Traders");
|
||||
this.setLocationRelativeTo(this.getParent());
|
||||
// this.editAutoTraderList1.summary=this.jLabelSummary;
|
||||
//this.setLocationRelativeTo(MainWin.instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jOkButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
editAutoTraderList1 = new gui.EditAutoTraderList();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
jButton1.setMnemonic('c');
|
||||
jButton1.setText("Cancel");
|
||||
jButton1.setToolTipText("");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jOkButton.setMnemonic('o');
|
||||
jOkButton.setText("Ok");
|
||||
jOkButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jOkButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setText("Add");
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(editAutoTraderList1, javax.swing.GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(jButton2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jOkButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton1)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(editAutoTraderList1, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(jOkButton)
|
||||
.addComponent(jButton2))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jOkButtonActionPerformed
|
||||
// TODO add your handling code here:
|
||||
this.editAutoTraderList1.save();
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_jOkButtonActionPerformed
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
this.editAutoTraderList1.add();
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(EditAutoTraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(EditAutoTraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(EditAutoTraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(EditAutoTraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
EditAutoTraderListDialog dialog = new EditAutoTraderListDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.EditAutoTraderList editAutoTraderList1;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JButton jOkButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
123
src/gui/EditExchangeDialog.form
Normal file
123
src/gui/EditExchangeDialog.form
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="SeSim ExchangeSettings"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[300, 142]"/>
|
||||
</Property>
|
||||
<Property name="modal" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="jLabel1" pref="212" max="32767" attributes="0"/>
|
||||
<Component id="jLabel2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="moneyDecimalsSpinner" alignment="1" min="-2" pref="70" max="-2" attributes="0"/>
|
||||
<Component id="sharesDecimalsSpinner" alignment="1" min="-2" pref="70" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="sharesDecimalsSpinner" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="moneyDecimalsSpinner" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="32" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JSpinner" name="sharesDecimalsSpinner">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Number of decimals for shares:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="moneyDecimalsSpinner">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="2" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Number of decimals for money:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="okButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
207
src/gui/EditExchangeDialog.java
Normal file
207
src/gui/EditExchangeDialog.java
Normal file
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class EditExchangeDialog extends EscDialog /*javax.swing.JDialog*/ {
|
||||
|
||||
/**
|
||||
* Creates new form EditExchnageDialog
|
||||
*/
|
||||
public EditExchangeDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(parent);
|
||||
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", Globals.DEFAULT_EXCHANGE_CFG));
|
||||
|
||||
this.moneyDecimalsSpinner.setValue(jo.getInt(Globals.se.CFG_MONEY_DECIMALS));
|
||||
this.sharesDecimalsSpinner.setValue(jo.getInt(Globals.se.CFG_SHARES_DECIMALS));
|
||||
this.setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
int showdialog() {
|
||||
this.setVisible(true);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
sharesDecimalsSpinner = new javax.swing.JSpinner();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
moneyDecimalsSpinner = new javax.swing.JSpinner();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
okButton = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("SeSim ExchangeSettings");
|
||||
setMinimumSize(new java.awt.Dimension(300, 142));
|
||||
setModal(true);
|
||||
|
||||
sharesDecimalsSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 10, 1));
|
||||
|
||||
jLabel1.setText("Number of decimals for shares:");
|
||||
|
||||
moneyDecimalsSpinner.setModel(new javax.swing.SpinnerNumberModel(2, 0, 10, 1));
|
||||
|
||||
jLabel2.setText("Number of decimals for money:");
|
||||
|
||||
jButton1.setMnemonic('c');
|
||||
jButton1.setText("Cancel");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
okButton.setMnemonic('o');
|
||||
okButton.setText("Ok");
|
||||
okButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
okButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton1))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(moneyDecimalsSpinner, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(sharesDecimalsSpinner, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(15, 15, 15)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(sharesDecimalsSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel1))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(moneyDecimalsSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(okButton))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put(Globals.se.CFG_MONEY_DECIMALS, (Integer) this.moneyDecimalsSpinner.getValue());
|
||||
jo.put(Globals.se.CFG_SHARES_DECIMALS, (Integer) this.sharesDecimalsSpinner.getValue());
|
||||
System.out.printf("EC: %s\n", jo.toString(3));
|
||||
Globals.prefs.put("Exchange", jo.toString());
|
||||
dispose();
|
||||
}//GEN-LAST:event_okButtonActionPerformed
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
dispose();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(EditExchangeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(EditExchangeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(EditExchangeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(EditExchangeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
EditExchangeDialog dialog = new EditExchangeDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JSpinner moneyDecimalsSpinner;
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JSpinner sharesDecimalsSpinner;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
139
src/gui/EditPreferencesDialog.form
Normal file
139
src/gui/EditPreferencesDialog.form
Normal file
@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<Component id="lafComboBox" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="201" max="32767" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="applyButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="godmodeCheckBox" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jDevleopmentFeaturesCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lafComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="godmodeCheckBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jDevleopmentFeaturesCheckBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="188" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JComboBox" name="lafComboBox">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lafComboBoxActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="cancelButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="applyButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="Apply"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="applyButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="okButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Look and Feel:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jDevleopmentFeaturesCheckBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Develeopment"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="godmodeCheckBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Godmode"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
280
src/gui/EditPreferencesDialog.java
Normal file
280
src/gui/EditPreferencesDialog.java
Normal file
@ -0,0 +1,280 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Window;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class EditPreferencesDialog extends javax.swing.JDialog {
|
||||
|
||||
UIManager.LookAndFeelInfo[] lafInfo;
|
||||
|
||||
LookAndFeel old_laf;
|
||||
LookAndFeel new_laf;
|
||||
|
||||
/**
|
||||
* Creates new form EditPreferencesDialog
|
||||
*/
|
||||
public EditPreferencesDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(this.getParent());
|
||||
|
||||
old_laf = UIManager.getLookAndFeel();
|
||||
|
||||
lafInfo = UIManager.getInstalledLookAndFeels();
|
||||
lafComboBox.removeAllItems();
|
||||
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
|
||||
lafComboBox.addItem(lafInfo1.getName());
|
||||
}
|
||||
lafComboBox.setSelectedItem(Globals.prefs.get("laf", "Nimbus"));
|
||||
|
||||
String selstr;
|
||||
selstr = Globals.prefs.get(Globals.DEVELSTATUS, "false");
|
||||
this.jDevleopmentFeaturesCheckBox.setSelected(selstr.equals("true"));
|
||||
|
||||
selstr = Globals.prefs.get(Globals.GODMODE, "false");
|
||||
this.godmodeCheckBox.setSelected(selstr.equals("true"));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
lafComboBox = new javax.swing.JComboBox<>();
|
||||
cancelButton = new javax.swing.JButton();
|
||||
applyButton = new javax.swing.JButton();
|
||||
okButton = new javax.swing.JButton();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jDevleopmentFeaturesCheckBox = new javax.swing.JCheckBox();
|
||||
godmodeCheckBox = new javax.swing.JCheckBox();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
lafComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
lafComboBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
lafComboBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setMnemonic('c');
|
||||
cancelButton.setText("Cancel");
|
||||
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cancelButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
applyButton.setMnemonic('a');
|
||||
applyButton.setText("Apply");
|
||||
applyButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
applyButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
okButton.setMnemonic('o');
|
||||
okButton.setText("Ok");
|
||||
okButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
okButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText("Look and Feel:");
|
||||
|
||||
jDevleopmentFeaturesCheckBox.setText("Develeopment");
|
||||
|
||||
godmodeCheckBox.setText("Godmode");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addGap(80, 80, 80)
|
||||
.addComponent(lafComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 201, Short.MAX_VALUE)
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(applyButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(godmodeCheckBox)
|
||||
.addComponent(jDevleopmentFeaturesCheckBox))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel1))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(godmodeCheckBox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jDevleopmentFeaturesCheckBox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 188, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancelButton)
|
||||
.addComponent(applyButton)
|
||||
.addComponent(okButton))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void lafComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lafComboBoxActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_lafComboBoxActionPerformed
|
||||
|
||||
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
||||
if (old_laf != new_laf) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(old_laf);
|
||||
} catch (UnsupportedLookAndFeelException ex) {
|
||||
Logger.getLogger(EditPreferencesDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
resetUI();
|
||||
}
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_cancelButtonActionPerformed
|
||||
|
||||
void resetUI() {
|
||||
for (Window w : Window.getWindows()) {
|
||||
System.out.print("Setting frame\n");
|
||||
SwingUtilities.updateComponentTreeUI(w);
|
||||
w.pack();
|
||||
}
|
||||
}
|
||||
|
||||
private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
|
||||
|
||||
|
||||
String selected = (String) this.lafComboBox.getSelectedItem();
|
||||
|
||||
Globals.setLookAndFeel(selected);
|
||||
new_laf = UIManager.getLookAndFeel();
|
||||
resetUI();
|
||||
|
||||
|
||||
|
||||
}//GEN-LAST:event_applyButtonActionPerformed
|
||||
|
||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||
this.applyButtonActionPerformed(evt);
|
||||
String selected = (String) this.lafComboBox.getSelectedItem();
|
||||
Globals.prefs.put("laf", selected);
|
||||
String sel;
|
||||
sel = this.jDevleopmentFeaturesCheckBox.isSelected() == true ? "true" : "false";
|
||||
Globals.prefs.put(Globals.DEVELSTATUS, sel);
|
||||
sel = this.godmodeCheckBox.isSelected() == true ? "true" : "false";
|
||||
Globals.prefs.put(Globals.GODMODE, sel);
|
||||
Globals.notifyCfgListeners();
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_okButtonActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(EditPreferencesDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(EditPreferencesDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(EditPreferencesDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(EditPreferencesDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
EditPreferencesDialog dialog = new EditPreferencesDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton applyButton;
|
||||
private javax.swing.JButton cancelButton;
|
||||
private javax.swing.JCheckBox godmodeCheckBox;
|
||||
private javax.swing.JCheckBox jDevleopmentFeaturesCheckBox;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JComboBox<String> lafComboBox;
|
||||
private javax.swing.JButton okButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
201
src/gui/EditStrategies.form
Normal file
201
src/gui/EditStrategies.form
Normal file
@ -0,0 +1,201 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="No config available"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="jNewButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jRemoveButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jSaveButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jBaseLabel" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jComboBoxStrategySelector" min="-2" pref="361" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jComboBoxStrategySelector" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jBaseLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jSaveButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jRemoveButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jNewButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JComboBox" name="jComboBoxStrategySelector">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBoxStrategySelectorActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="guiPanel">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="defaultGuiPanel">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" pref="612" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" pref="407" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="No config available"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="jSaveButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<Property name="text" type="java.lang.String" value="Save"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jSaveButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Close"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="Save as ..."/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jRemoveButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="114"/>
|
||||
<Property name="text" type="java.lang.String" value="Remove"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jRemoveButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jNewButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="110"/>
|
||||
<Property name="text" type="java.lang.String" value="New"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jNewButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jBaseLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="base"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
459
src/gui/EditStrategies.java
Normal file
459
src/gui/EditStrategies.java
Normal file
@ -0,0 +1,459 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JPanel;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import sesim.AutoTraderConfig;
|
||||
import sesim.AutoTraderGui;
|
||||
import sesim.AutoTraderInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
|
||||
TreeMap<String, JSONObject> strategies = new TreeMap();
|
||||
|
||||
void initComboBox() {
|
||||
|
||||
this.reloadStrategyConfigs();
|
||||
|
||||
this.jComboBoxStrategySelector.removeAllItems();
|
||||
|
||||
/*
|
||||
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
|
||||
*/
|
||||
Iterator<String> i = strategies.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
|
||||
this.jComboBoxStrategySelector.addItem(i.next());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form EditTradingStrategies
|
||||
*/
|
||||
public EditStrategies(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(this.getParent());
|
||||
|
||||
initComboBox();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
final String STRATEGYPREFS = "Strategies";
|
||||
|
||||
void reloadStrategyConfigs() {
|
||||
|
||||
strategies = new TreeMap();
|
||||
JSONObject cfgs = Globals.getStrategies();
|
||||
|
||||
Iterator<String> i = cfgs.keys();
|
||||
while (i.hasNext()) {
|
||||
String k = i.next();
|
||||
JSONObject o = cfgs.getJSONObject(k);
|
||||
strategies.put(k, o);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jComboBoxStrategySelector = new javax.swing.JComboBox<>();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
guiPanel = new javax.swing.JPanel();
|
||||
defaultGuiPanel = new javax.swing.JPanel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jSaveButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jRemoveButton = new javax.swing.JButton();
|
||||
jNewButton = new javax.swing.JButton();
|
||||
jBaseLabel = new javax.swing.JLabel();
|
||||
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel1.setText("No config available");
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
jComboBoxStrategySelector.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
jComboBoxStrategySelector.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jComboBoxStrategySelectorActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
guiPanel.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel2.setText("No config available");
|
||||
jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
|
||||
javax.swing.GroupLayout defaultGuiPanelLayout = new javax.swing.GroupLayout(defaultGuiPanel);
|
||||
defaultGuiPanel.setLayout(defaultGuiPanelLayout);
|
||||
defaultGuiPanelLayout.setHorizontalGroup(
|
||||
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, defaultGuiPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 612, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
defaultGuiPanelLayout.setVerticalGroup(
|
||||
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jScrollPane1.setViewportView(guiPanel);
|
||||
|
||||
jSaveButton.setMnemonic('s');
|
||||
jSaveButton.setText("Save");
|
||||
jSaveButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jSaveButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setMnemonic('c');
|
||||
jButton2.setText("Close");
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton1.setMnemonic('a');
|
||||
jButton1.setText("Save as ...");
|
||||
|
||||
jRemoveButton.setMnemonic('r');
|
||||
jRemoveButton.setText("Remove");
|
||||
jRemoveButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jRemoveButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jNewButton.setMnemonic('n');
|
||||
jNewButton.setText("New");
|
||||
jNewButton.setToolTipText("");
|
||||
jNewButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jNewButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jBaseLabel.setText("base");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(jNewButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jRemoveButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jSaveButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2)
|
||||
.addGap(9, 9, 9))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(jBaseLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jBaseLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE)
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jSaveButton)
|
||||
.addComponent(jButton2)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(jRemoveButton)
|
||||
.addComponent(jNewButton))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
AutoTraderGui acgui;
|
||||
AutoTraderInterface ac;
|
||||
|
||||
private void jComboBoxStrategySelectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStrategySelectorActionPerformed
|
||||
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
|
||||
|
||||
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String base = null;
|
||||
JSONObject o = null;
|
||||
try {
|
||||
o = (JSONObject) cfgs.get(item);
|
||||
System.out.printf("Have got a jason obj %s\n", o.toString(9));
|
||||
System.out.print("--------------------------------------\n");
|
||||
base = o.getString("base");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.printf("Exception return\n", "");
|
||||
base = item;
|
||||
|
||||
}
|
||||
|
||||
System.out.printf("Base %s\n", base);
|
||||
|
||||
ac = Globals.tloader.getStrategyBase(base);
|
||||
if (ac == null) {
|
||||
System.out.print("BASE IST NULL\n");
|
||||
Globals.LOGGER.info(String.format("Can't load: %s\n", base));
|
||||
//System.exit(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ac.putConfig(o);
|
||||
this.jBaseLabel.setText(base);
|
||||
|
||||
acgui = ac.getGui();
|
||||
guiPanel.removeAll();
|
||||
if (acgui != null) {
|
||||
|
||||
guiPanel.add(acgui, java.awt.BorderLayout.CENTER);
|
||||
acgui.setVisible(true);
|
||||
|
||||
} else {
|
||||
System.out.printf("Adding default gui panel\n");
|
||||
guiPanel.add(this.defaultGuiPanel, java.awt.BorderLayout.CENTER);
|
||||
}
|
||||
this.revalidate();
|
||||
System.out.printf("Setted the dings\n", "");
|
||||
JSONObject jo = ac.getConfig();
|
||||
if (jo != null) {
|
||||
System.out.printf("%s\n", jo.toString(2));
|
||||
// jo = new JSONObject(jo.toString());
|
||||
|
||||
}
|
||||
|
||||
// System.out.print("Crete auto trader afeter select\n");
|
||||
// AutoTrader at = ac.createTrader(Globals.se, jo, 100, 100);
|
||||
|
||||
this.repaint();
|
||||
}//GEN-LAST:event_jComboBoxStrategySelectorActionPerformed
|
||||
|
||||
private void jSaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSaveButtonActionPerformed
|
||||
|
||||
if (acgui!=null)
|
||||
acgui.save();
|
||||
|
||||
JSONObject o = ac.getConfig();
|
||||
|
||||
String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
|
||||
|
||||
// o.put("base", ac.getDisplayName());
|
||||
o.put("base", ac.getClass().getCanonicalName());
|
||||
|
||||
System.out.printf("The big name: %s\n", ac.getClass().getCanonicalName());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JSONObject o0 = strategies.get(item);
|
||||
|
||||
if (o0 == null) {
|
||||
StrategySaveDialog d = new StrategySaveDialog((Frame) this.getParent(), true);
|
||||
d.setLabelAndName(item, "");
|
||||
d.setVisible(true);
|
||||
if (d.getName().equals("")) {
|
||||
return;
|
||||
}
|
||||
item = item + " - " + d.getName();
|
||||
}
|
||||
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
|
||||
cfgs.put(item, o);
|
||||
|
||||
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
|
||||
|
||||
//this.reloadStrategyConfigs();
|
||||
this.initComboBox();
|
||||
this.jComboBoxStrategySelector.setSelectedItem(item);
|
||||
//this.jComboBoxStrategySelector.
|
||||
|
||||
System.out.printf("Saving item: %s\nJSON %s\n", item, o.toString(3));
|
||||
|
||||
}//GEN-LAST:event_jSaveButtonActionPerformed
|
||||
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
private void jRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRemoveButtonActionPerformed
|
||||
|
||||
System.out.print("Hello - remove button\n");
|
||||
|
||||
String selected = (String) this.jComboBoxStrategySelector.getSelectedItem();
|
||||
System.out.printf("Selected: %s\n", selected);
|
||||
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
|
||||
//System.out.printf("CFG vorher: %s\n", cfgs.toString(3));
|
||||
cfgs.remove(selected);
|
||||
|
||||
// System.out.printf("Neue nachher: %s\n", cfgs.toString(3));
|
||||
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
|
||||
|
||||
this.initComboBox();
|
||||
|
||||
|
||||
|
||||
}//GEN-LAST:event_jRemoveButtonActionPerformed
|
||||
|
||||
private void jNewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNewButtonActionPerformed
|
||||
NewStrategyDialog sd = new NewStrategyDialog((Frame) this.getParent(),true);
|
||||
sd.setVisible(true);
|
||||
|
||||
if (sd.result==null)
|
||||
return;
|
||||
|
||||
AutoTraderInterface ac = Globals.tloader.getStrategyBase(sd.result.base);
|
||||
JSONObject cfg = ac.getConfig();
|
||||
System.out.printf("Initial cfg %s\n", cfg.toString(2));
|
||||
cfg.put("base", ac.getClass().getCanonicalName());
|
||||
|
||||
Globals.saveStrategy(sd.result.name, cfg);
|
||||
this.initComboBox();
|
||||
}//GEN-LAST:event_jNewButtonActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
EditStrategies dialog = new EditStrategies(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel defaultGuiPanel;
|
||||
private javax.swing.JPanel guiPanel;
|
||||
private javax.swing.JLabel jBaseLabel;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JComboBox<String> jComboBoxStrategySelector;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JButton jNewButton;
|
||||
private javax.swing.JButton jRemoveButton;
|
||||
private javax.swing.JButton jSaveButton;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
38
src/gui/EscDialog.form
Normal file
38
src/gui/EscDialog.form
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="formKeyReleased"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
127
src/gui/EscDialog.java
Normal file
127
src/gui/EscDialog.java
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class EscDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form EscDialog
|
||||
*/
|
||||
public EscDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
System.out.printf("Adding Key Listener\n", "");
|
||||
addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyReleased(java.awt.event.KeyEvent evt) {
|
||||
formKeyReleased(evt);
|
||||
}
|
||||
});
|
||||
this.setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyReleased(java.awt.event.KeyEvent evt) {
|
||||
formKeyReleased(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void formKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyReleased
|
||||
dispose();
|
||||
}//GEN-LAST:event_formKeyReleased
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
EscDialog dialog = new EscDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
183
src/gui/Globals.java
Normal file
183
src/gui/Globals.java
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.UIManager;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import sesim.AutoTraderLoader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class Globals {
|
||||
|
||||
public interface CfgListener{
|
||||
void cfgChanged();
|
||||
}
|
||||
|
||||
static ArrayList <CfgListener> cfg_listeners = new ArrayList<>();
|
||||
public static void notifyCfgListeners(){
|
||||
for (CfgListener l : cfg_listeners){
|
||||
l.cfgChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCfgListener(CfgListener l){
|
||||
cfg_listeners.add(l);
|
||||
}
|
||||
|
||||
public static JFrame frame;
|
||||
|
||||
static final String STRATEGYPREFS = "Strategies";
|
||||
static final String TRADERPREFS = "Traders";
|
||||
|
||||
static final String DEVELSTATUS = "devel_status";
|
||||
public static final String GODMODE = "godmode";
|
||||
|
||||
static public sesim.Exchange se;
|
||||
|
||||
static public Preferences prefs;
|
||||
|
||||
|
||||
public static class CfgStrings{
|
||||
public static final String GODMODE = "godmode";
|
||||
}
|
||||
|
||||
|
||||
public static String DEFAULT_EXCHANGE_CFG =
|
||||
"{"
|
||||
+ " money_decimals: 2,"
|
||||
+ " shares_decimals: 0"
|
||||
+ "}";
|
||||
|
||||
//CfgStrings
|
||||
|
||||
|
||||
static void setLookAndFeel(String selected) {
|
||||
|
||||
try {
|
||||
String look = "com.seaglasslookandfeel.SeaGlassLookAndFeel";
|
||||
Class.forName(look);
|
||||
UIManager.installLookAndFeel("Sea Glass", look);
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
|
||||
UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
|
||||
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
|
||||
if (lafInfo1.getName().equals(selected)) {
|
||||
String lafClassName = lafInfo1.getClassName();
|
||||
try {
|
||||
UIManager.setLookAndFeel(lafClassName);
|
||||
// UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static AutoTraderLoader tloader = new AutoTraderLoader();
|
||||
|
||||
static final Logger LOGGER = Logger.getLogger("com.cauwersin.sesim");
|
||||
|
||||
static public final JSONArray getTraders() {
|
||||
String traders_json = Globals.prefs.get(TRADERPREFS, "[]");
|
||||
JSONArray traders = new JSONArray(traders_json);
|
||||
return traders;
|
||||
}
|
||||
|
||||
static public final JSONObject getStrategies() {
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
return cfgs;
|
||||
}
|
||||
|
||||
static public JSONObject getStrategy(String name) {
|
||||
return getStrategies().getJSONObject(name);
|
||||
}
|
||||
|
||||
static public void getStrategiesIntoComboBox(JComboBox comboBox) {
|
||||
TreeMap stm = getStrategiesAsTreeMap();
|
||||
comboBox.removeAllItems();
|
||||
|
||||
Iterator<String> i = stm.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
comboBox.addItem(i.next());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static public TreeMap getStrategiesAsTreeMap() {
|
||||
TreeMap strategies = new TreeMap();
|
||||
JSONObject cfgs = Globals.getStrategies();
|
||||
|
||||
Iterator<String> i = cfgs.keys();
|
||||
while (i.hasNext()) {
|
||||
String k = i.next();
|
||||
JSONObject o = cfgs.getJSONObject(k);
|
||||
strategies.put(k, o);
|
||||
}
|
||||
return strategies;
|
||||
}
|
||||
|
||||
static public final void saveStrategy(String name, JSONObject cfg) {
|
||||
JSONObject cfgs = getStrategies();
|
||||
cfgs.put(name, cfg);
|
||||
prefs.put(STRATEGYPREFS, cfgs.toString());
|
||||
}
|
||||
|
||||
static void saveFile(File f) {
|
||||
|
||||
JSONObject sobj = new JSONObject();
|
||||
JSONArray traders = getTraders();
|
||||
JSONObject strategies = getStrategies();
|
||||
sobj.put("strategies", strategies);
|
||||
sobj.put("traders", traders);
|
||||
try {
|
||||
PrintWriter out = new PrintWriter(f.getAbsolutePath());
|
||||
out.print(sobj.toString(4));
|
||||
out.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(Globals.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
65
src/gui/LoggerDialog.form
Normal file
65
src/gui/LoggerDialog.form
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="586" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="63" max="-2" attributes="0"/>
|
||||
<Component id="orderBookNew1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" min="-2" pref="160" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="orderBookNew1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="9" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="logArea">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="gui.orderbook.OrderBook" name="orderBookNew1">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
166
src/gui/LoggerDialog.java
Normal file
166
src/gui/LoggerDialog.java
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class LoggerDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form LoggerDialog
|
||||
*/
|
||||
public LoggerDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
|
||||
this.setTitle("Logger Window");
|
||||
|
||||
class LogHandler extends Handler {
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
String str = record.getMessage();
|
||||
logArea.append(str);
|
||||
logArea.append("\n");
|
||||
|
||||
// System.out.printf("SRTR WAS: %s",str);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
LogHandler handler = new LogHandler();
|
||||
Globals.LOGGER.addHandler(handler);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
logArea = new javax.swing.JTextArea();
|
||||
orderBookNew1 = new gui.orderbook.OrderBook();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
logArea.setEditable(false);
|
||||
logArea.setColumns(20);
|
||||
logArea.setRows(5);
|
||||
jScrollPane1.setViewportView(logArea);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(63, 63, 63)
|
||||
.addComponent(orderBookNew1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(orderBookNew1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 9, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
LoggerDialog dialog = new LoggerDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JTextArea logArea;
|
||||
private gui.orderbook.OrderBook orderBookNew1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
152
src/gui/MainWin.form
Normal file
152
src/gui/MainWin.form
Normal file
@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JMenuItem" name="jMenuItem1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jMenuItem1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Menu class="javax.swing.JMenuBar" name="MainMenu">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="FileMenu">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="1" green="cb" red="fe" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="FileNew">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="New"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="FileNewActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="FileRun">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Run"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="FileRunActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="editjMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="101"/>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="editPrefernces">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="112"/>
|
||||
<Property name="text" type="java.lang.String" value="Preferences"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="editPreferncesActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="viewMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="118"/>
|
||||
<Property name="text" type="java.lang.String" value="View"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="traderList">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="116"/>
|
||||
<Property name="text" type="java.lang.String" value="Traders"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="traderListActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="helpMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Help"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="helpAbout">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="About"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="About this Software"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="helpAboutActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[640, 480]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="MainMenu"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,93,0,0,3,-30"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="gui.ControlPanel" name="controlPanel2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="After"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="gui.OrderBookPanel" name="orderBookPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Before"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="chart.FullChart" name="fullChart2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
335
src/gui/MainWin.java
Normal file
335
src/gui/MainWin.java
Normal file
@ -0,0 +1,335 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import sesim.Exchange;
|
||||
import traders.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class MainWin extends javax.swing.JFrame {
|
||||
|
||||
static MainWin instance;
|
||||
//static public sesim.Exchange se;
|
||||
//static sesim.Account_old myAccount;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form MainWin
|
||||
*/
|
||||
public MainWin() {
|
||||
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(this);
|
||||
|
||||
|
||||
double aid1 = Globals.se.createAccount(100, 100);
|
||||
double aid2 = Globals.se.createAccount(1000, 100);
|
||||
|
||||
/* AccountData a1 = se.getAccountData(aid1);
|
||||
AccountData a2 = se.getAccountData(aid2);
|
||||
se.createOrder(aid2, Exchange.OrderType.ASK, 20, 11.9);
|
||||
se.createOrder(aid2, Exchange.OrderType.ASK, 20, 11);
|
||||
se.createOrder(aid2, Exchange.OrderType.ASK, 10, 10);
|
||||
se.createOrder(aid2, Exchange.OrderType.ASK, 10, 9);
|
||||
se.createOrder(aid1, Exchange.OrderType.BID, 50, 11);
|
||||
*/
|
||||
|
||||
/*
|
||||
System.out.print("Exec Orders\n");
|
||||
se.executeOrders();
|
||||
System.out.print("Executed Orders\n");
|
||||
|
||||
a1 = se.getAccountData(aid1);
|
||||
a2 = se.getAccountData(aid2);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
AutoTraderLIst at = new AutoTraderLIst();
|
||||
// RandomTraderConfig_old rcfg = new RandomTraderConfig_old();
|
||||
SwitchingTraderConfig rcfg = new SwitchingTraderConfig();
|
||||
at.add(1000, rcfg, se, 100, 0);
|
||||
at.add(1000, rcfg, se, 0, 10000);
|
||||
|
||||
|
||||
SwitchingTraderConfig scfg = new SwitchingTraderConfig();
|
||||
at.add(1, scfg, se, 1000000, 0);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jMenuItem1 = new javax.swing.JMenuItem();
|
||||
controlPanel2 = new gui.ControlPanel();
|
||||
orderBookPanel1 = new gui.OrderBookPanel();
|
||||
fullChart2 = new chart.FullChart();
|
||||
MainMenu = new javax.swing.JMenuBar();
|
||||
FileMenu = new javax.swing.JMenu();
|
||||
FileNew = new javax.swing.JMenuItem();
|
||||
FileRun = new javax.swing.JMenuItem();
|
||||
editjMenu = new javax.swing.JMenu();
|
||||
editPrefernces = new javax.swing.JMenuItem();
|
||||
viewMenu = new javax.swing.JMenu();
|
||||
traderList = new javax.swing.JMenuItem();
|
||||
helpMenu = new javax.swing.JMenu();
|
||||
helpAbout = new javax.swing.JMenuItem();
|
||||
|
||||
jButton1.setText("jButton1");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jMenuItem1.setText("jMenuItem1");
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||
getContentPane().add(controlPanel2, java.awt.BorderLayout.LINE_END);
|
||||
getContentPane().add(orderBookPanel1, java.awt.BorderLayout.LINE_START);
|
||||
getContentPane().add(fullChart2, java.awt.BorderLayout.CENTER);
|
||||
|
||||
FileMenu.setBackground(new java.awt.Color(254, 203, 1));
|
||||
FileMenu.setText("File");
|
||||
|
||||
FileNew.setText("New");
|
||||
FileNew.setBorder(null);
|
||||
FileNew.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
FileNewActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
FileMenu.add(FileNew);
|
||||
|
||||
FileRun.setText("Run");
|
||||
FileRun.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
FileRunActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
FileMenu.add(FileRun);
|
||||
|
||||
MainMenu.add(FileMenu);
|
||||
|
||||
editjMenu.setMnemonic('e');
|
||||
editjMenu.setText("Edit");
|
||||
|
||||
editPrefernces.setMnemonic('p');
|
||||
editPrefernces.setText("Preferences");
|
||||
editPrefernces.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
editPreferncesActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
editjMenu.add(editPrefernces);
|
||||
|
||||
MainMenu.add(editjMenu);
|
||||
|
||||
viewMenu.setMnemonic('v');
|
||||
viewMenu.setText("View");
|
||||
|
||||
traderList.setMnemonic('t');
|
||||
traderList.setText("Traders");
|
||||
traderList.setToolTipText("");
|
||||
traderList.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
traderListActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
viewMenu.add(traderList);
|
||||
|
||||
MainMenu.add(viewMenu);
|
||||
|
||||
helpMenu.setText("Help");
|
||||
|
||||
helpAbout.setMnemonic('a');
|
||||
helpAbout.setText("About");
|
||||
helpAbout.setToolTipText("About this Software");
|
||||
helpAbout.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
helpAboutActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
helpMenu.add(helpAbout);
|
||||
|
||||
MainMenu.add(helpMenu);
|
||||
|
||||
setJMenuBar(MainMenu);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void FileNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FileNewActionPerformed
|
||||
|
||||
|
||||
}//GEN-LAST:event_FileNewActionPerformed
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
private void FileRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FileRunActionPerformed
|
||||
Globals.se.timer.start();
|
||||
}//GEN-LAST:event_FileRunActionPerformed
|
||||
|
||||
private void helpAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpAboutActionPerformed
|
||||
AboutDialog d=new AboutDialog(this,true);
|
||||
d.show();
|
||||
}//GEN-LAST:event_helpAboutActionPerformed
|
||||
|
||||
private void traderListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_traderListActionPerformed
|
||||
TraderListDialog tl = new TraderListDialog(this,false);
|
||||
tl.setVisible(true);
|
||||
}//GEN-LAST:event_traderListActionPerformed
|
||||
|
||||
private void editPreferncesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editPreferncesActionPerformed
|
||||
EditPreferencesDialog d = new EditPreferencesDialog(this,true);
|
||||
d.setVisible(true);
|
||||
}//GEN-LAST:event_editPreferncesActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
|
||||
Globals.se = new Exchange();
|
||||
//se.timer.start();
|
||||
|
||||
|
||||
//RandomTraderConfig rcfg = new RandomTraderConfig();
|
||||
//RandomTrader rt = rcfg.createTrader(se, 1000, 100);
|
||||
//rt.start();
|
||||
|
||||
// SwitchingTraderConfig rcfg1 = new SwitchingTraderConfig();
|
||||
// SwitchingTraderConfig rcfg1 = new SwitchingTraderConfig();
|
||||
RandomTraderConfig rcfg1 = new RandomTraderConfig();
|
||||
// rcfg1.sell_limit[0]=-1;
|
||||
// rcfg1.sell_limit[1]=1;
|
||||
|
||||
/*
|
||||
AutoTrader rt1 = rcfg1.createTrader(Globals.se,0,"", null, 1000000, 1000000);
|
||||
Globals.se.traders.add(rt1);
|
||||
rt1.setName("Alice");
|
||||
rt1.start();
|
||||
|
||||
|
||||
//AutoTrader rt2 = rcfg1.createTrader(se, 1, 100);
|
||||
//rt2.start();
|
||||
|
||||
|
||||
// SwitchingTraderConfig cfg = new SwitchingTraderConfig();
|
||||
RandomTraderConfig cfg= new RandomTraderConfig();
|
||||
*
|
||||
for (int i=0; i<30; i++){
|
||||
AutoTrader randt = cfg.createTrader(Globals.se,null, 100000, 100000);
|
||||
|
||||
Globals.se.traders.add(randt);
|
||||
randt.setName("Bob");
|
||||
randt.start();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// at.add(10, rcfg, se, 1000000, 0);
|
||||
|
||||
|
||||
/* try {
|
||||
// Set cross-platform Java L&F (also called "Metal")
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
|
||||
} catch (UnsupportedLookAndFeelException | ClassNotFoundException |
|
||||
InstantiationException | IllegalAccessException e) {
|
||||
}
|
||||
*/
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
/* try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Motif".equals(info.getDisplayName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
*/
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(() -> {
|
||||
MainWin.instance=new MainWin();
|
||||
MainWin.instance.setVisible(true);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenu FileMenu;
|
||||
private javax.swing.JMenuItem FileNew;
|
||||
private javax.swing.JMenuItem FileRun;
|
||||
private javax.swing.JMenuBar MainMenu;
|
||||
private gui.ControlPanel controlPanel2;
|
||||
private javax.swing.JMenuItem editPrefernces;
|
||||
private javax.swing.JMenu editjMenu;
|
||||
private chart.FullChart fullChart2;
|
||||
private javax.swing.JMenuItem helpAbout;
|
||||
private javax.swing.JMenu helpMenu;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JMenuItem jMenuItem1;
|
||||
private gui.OrderBookPanel orderBookPanel1;
|
||||
private javax.swing.JMenuItem traderList;
|
||||
private javax.swing.JMenu viewMenu;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
503
src/gui/NewMDIApplication.form
Normal file
503
src/gui/NewMDIApplication.form
Normal file
@ -0,0 +1,503 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="jTextArea1">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
<Property name="text" type="java.lang.String" value="Hakke"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
|
||||
<Properties>
|
||||
<Property name="orientation" type="int" value="0"/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="top"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="gui.orderbook.OrderBook" name="orderBookNew1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="left"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Menu class="javax.swing.JMenuBar" name="menuBar">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="fileMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="102"/>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="110"/>
|
||||
<Property name="text" type="java.lang.String" value="New"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="openMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Open"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<Property name="text" type="java.lang.String" value="Save"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveAsMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="Save As ..."/>
|
||||
<Property name="displayedMnemonicIndex" type="int" value="5"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveAsMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="120"/>
|
||||
<Property name="text" type="java.lang.String" value="Exit"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="editMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="101"/>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="editExchangeMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="121"/>
|
||||
<Property name="text" type="java.lang.String" value="Exchange ..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="editExchangeMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator1">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="pasteMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<Property name="text" type="java.lang.String" value="Strategies ..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pasteMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="deleteMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="100"/>
|
||||
<Property name="text" type="java.lang.String" value="Traders ..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator2">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="editPreferences">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="112"/>
|
||||
<Property name="text" type="java.lang.String" value="Preferences ..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="editPreferencesActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="simMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<Property name="text" type="java.lang.String" value="Sim"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="simMenuStart">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<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="simMenuStartActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="simMenuPause">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="112"/>
|
||||
<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="simMenuStop">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="116"/>
|
||||
<Property name="text" type="java.lang.String" value="Stop"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="simMenuStopActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator3">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Point Zero"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem4ActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jMenuItem5"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="viewMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="118"/>
|
||||
<Property name="text" type="java.lang.String" value="View"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="viewTraderListCheckBox">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="116"/>
|
||||
<Property name="text" type="java.lang.String" value="Traders"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewTraderListCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="viewClock">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Clock"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewClockActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="LogWindow"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxMenuItem1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Orderbook"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBoxMenuItem1ActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="helpMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="104"/>
|
||||
<Property name="text" type="java.lang.String" value="Help"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="contentMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Contents"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="aboutMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="About"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="aboutMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[640, 480]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="menuBar"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-122,0,0,3,29"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="First"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="runButton" min="-2" pref="86" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" pref="67" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="stopButton" min="-2" pref="63" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="375" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="clock" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="accelSpinner" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="runButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="jButton2" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="stopButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
|
||||
<Component id="clock" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="accelSpinner" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="5" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="stopButton">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/resources/icons/stop.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Stop"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="stopButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="runButton">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||
<FontInfo relative="true">
|
||||
<Font component="runButton" property="font" relativeSize="true" size="0"/>
|
||||
</FontInfo>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/resources/icons/run.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Run sim!"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Run the simmulation"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="runButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/resources/icons/pause.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Pause"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="accelSpinner">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="1.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="accelSpinnerStateChanged"/>
|
||||
<EventHandler event="propertyChange" listener="java.beans.PropertyChangeListener" parameters="java.beans.PropertyChangeEvent" handler="accelSpinnerPropertyChange"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="NewMDIApplication_accelSpinner"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="gui.Clock" name="clock">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Acceleration:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane3">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane4">
|
||||
<Properties>
|
||||
<Property name="orientation" type="int" value="0"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="right"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="gui.orderbook.OrderBooksHorizontal" name="orderBooksHorizontal1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="bottom"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jChartScrollPane">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="left"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="chart.Chart" name="chart">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[892, 410]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="892" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="410" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="gui.orderbook.QuoteVertical" name="quoteVertical1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="left"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane5">
|
||||
<Properties>
|
||||
<Property name="orientation" type="int" value="0"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="left"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="gui.Statistics" name="statistics1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="top"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
813
src/gui/NewMDIApplication.java
Normal file
813
src/gui/NewMDIApplication.java
Normal file
@ -0,0 +1,813 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import sesim.AutoTraderConfig;
|
||||
import sesim.AutoTraderInterface;
|
||||
import sesim.Exchange;
|
||||
import sesim.Scheduler;
|
||||
import traders.RandomTraderConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
/**
|
||||
* Creates new form NewMDIApplication
|
||||
*/
|
||||
public NewMDIApplication() {
|
||||
initComponents();
|
||||
Globals.frame = this;
|
||||
this.setLocationRelativeTo(this);
|
||||
this.setTitle("SeSim - Stock Exchange Simmulator");
|
||||
}
|
||||
|
||||
AutoTraderInterface createTraderNew(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
|
||||
|
||||
String base = cfg.getString("base");
|
||||
AutoTraderInterface ac = Globals.tloader.getStrategyBase(base);
|
||||
if (ac == null) {
|
||||
return null;
|
||||
}
|
||||
ac.putConfig(cfg);
|
||||
ac.init(se, id, name, money, shares, cfg);
|
||||
|
||||
return ac;
|
||||
}
|
||||
|
||||
public void startTraders() {
|
||||
|
||||
WaitBox wb = new WaitBox();
|
||||
|
||||
// Globals.se.setMoneyDecimals(8);
|
||||
// Globals.se.setSharesDecimals(0);
|
||||
JSONArray tlist = Globals.getTraders();
|
||||
|
||||
Double moneyTotal = 0.0;
|
||||
Double sharesTotal = 0.0;
|
||||
long id = 0;
|
||||
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");
|
||||
AutoTraderInterface 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");
|
||||
|
||||
Boolean enabled = t.getBoolean("Enabled");
|
||||
if (!enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.printf("Count: %d Shares: %f Money %f\n", count, shares, money);
|
||||
|
||||
for (int i1 = 0; i1 < count; i1++) {
|
||||
AutoTraderInterface trader;
|
||||
|
||||
trader = this.createTraderNew(Globals.se, id, t.getString("Name") + i1, money, shares, strategy);
|
||||
|
||||
Globals.se.traders.add(trader);
|
||||
|
||||
moneyTotal += money;
|
||||
sharesTotal += shares;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Globals.se.fairValue = moneyTotal / sharesTotal;
|
||||
|
||||
// Globals.se.fairValue = 1.0;
|
||||
System.out.printf("Failr Value is %f\n", Globals.se.fairValue);
|
||||
|
||||
|
||||
for (int i = 0; i < Globals.se.traders.size(); i++) {
|
||||
Globals.se.traders.get(i).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jScrollPane2 = new javax.swing.JScrollPane();
|
||||
jTextArea1 = new javax.swing.JTextArea();
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
jSplitPane2 = new javax.swing.JSplitPane();
|
||||
orderBookNew1 = new gui.orderbook.OrderBook();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
stopButton = new javax.swing.JButton();
|
||||
runButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
accelSpinner = new javax.swing.JSpinner();
|
||||
clock = new gui.Clock();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jSplitPane3 = new javax.swing.JSplitPane();
|
||||
jSplitPane4 = new javax.swing.JSplitPane();
|
||||
orderBooksHorizontal1 = new gui.orderbook.OrderBooksHorizontal();
|
||||
jChartScrollPane = new javax.swing.JScrollPane();
|
||||
chart = new chart.Chart();
|
||||
quoteVertical1 = new gui.orderbook.QuoteVertical();
|
||||
jSplitPane5 = new javax.swing.JSplitPane();
|
||||
statistics1 = new gui.Statistics();
|
||||
menuBar = new javax.swing.JMenuBar();
|
||||
fileMenu = new javax.swing.JMenu();
|
||||
jMenuItem1 = new javax.swing.JMenuItem();
|
||||
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();
|
||||
editExchangeMenuItem = new javax.swing.JMenuItem();
|
||||
jSeparator1 = new javax.swing.JPopupMenu.Separator();
|
||||
pasteMenuItem = new javax.swing.JMenuItem();
|
||||
deleteMenuItem = new javax.swing.JMenuItem();
|
||||
jSeparator2 = new javax.swing.JPopupMenu.Separator();
|
||||
editPreferences = new javax.swing.JMenuItem();
|
||||
simMenu = new javax.swing.JMenu();
|
||||
simMenuStart = new javax.swing.JMenuItem();
|
||||
simMenuPause = new javax.swing.JMenuItem();
|
||||
simMenuStop = new javax.swing.JMenuItem();
|
||||
jSeparator3 = new javax.swing.JPopupMenu.Separator();
|
||||
jMenuItem4 = new javax.swing.JMenuItem();
|
||||
jMenuItem5 = new javax.swing.JMenuItem();
|
||||
viewMenu = new javax.swing.JMenu();
|
||||
viewTraderListCheckBox = new javax.swing.JCheckBoxMenuItem();
|
||||
viewClock = new javax.swing.JMenuItem();
|
||||
jMenuItem3 = new javax.swing.JMenuItem();
|
||||
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
|
||||
helpMenu = new javax.swing.JMenu();
|
||||
contentMenuItem = new javax.swing.JMenuItem();
|
||||
aboutMenuItem = new javax.swing.JMenuItem();
|
||||
|
||||
jTextArea1.setColumns(20);
|
||||
jTextArea1.setRows(5);
|
||||
jTextArea1.setText("Hakke");
|
||||
jScrollPane2.setViewportView(jTextArea1);
|
||||
|
||||
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
|
||||
jSplitPane2.setLeftComponent(orderBookNew1);
|
||||
|
||||
jSplitPane1.setTopComponent(jSplitPane2);
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||
|
||||
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/stop.gif"))); // NOI18N
|
||||
stopButton.setText("Stop");
|
||||
stopButton.setFocusable(false);
|
||||
stopButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
stopButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
stopButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
stopButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
runButton.setFont(runButton.getFont());
|
||||
runButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/run.gif"))); // NOI18N
|
||||
runButton.setText("Run sim!");
|
||||
runButton.setToolTipText("Run the simmulation");
|
||||
runButton.setFocusable(false);
|
||||
runButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
runButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
runButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
runButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/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);
|
||||
}
|
||||
});
|
||||
|
||||
accelSpinner.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.0d, null, 1.0d));
|
||||
accelSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
accelSpinnerStateChanged(evt);
|
||||
}
|
||||
});
|
||||
accelSpinner.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
|
||||
public void propertyChange(java.beans.PropertyChangeEvent evt) {
|
||||
accelSpinnerPropertyChange(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText("Acceleration:");
|
||||
|
||||
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(runButton, 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(stopButton, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 375, Short.MAX_VALUE)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(clock, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(accelSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(runButton, 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(stopButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addGap(3, 3, 3)
|
||||
.addComponent(clock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(accelSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel1))
|
||||
.addGap(0, 5, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_START);
|
||||
|
||||
jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
jSplitPane4.setBottomComponent(orderBooksHorizontal1);
|
||||
|
||||
chart.setPreferredSize(new java.awt.Dimension(892, 410));
|
||||
|
||||
javax.swing.GroupLayout chartLayout = new javax.swing.GroupLayout(chart);
|
||||
chart.setLayout(chartLayout);
|
||||
chartLayout.setHorizontalGroup(
|
||||
chartLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 892, Short.MAX_VALUE)
|
||||
);
|
||||
chartLayout.setVerticalGroup(
|
||||
chartLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 410, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
jChartScrollPane.setViewportView(chart);
|
||||
|
||||
jSplitPane4.setLeftComponent(jChartScrollPane);
|
||||
|
||||
jSplitPane3.setRightComponent(jSplitPane4);
|
||||
jSplitPane3.setLeftComponent(quoteVertical1);
|
||||
|
||||
jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
jSplitPane5.setTopComponent(statistics1);
|
||||
|
||||
jSplitPane3.setLeftComponent(jSplitPane5);
|
||||
|
||||
getContentPane().add(jSplitPane3, java.awt.BorderLayout.CENTER);
|
||||
|
||||
fileMenu.setMnemonic('f');
|
||||
fileMenu.setText("File");
|
||||
|
||||
jMenuItem1.setMnemonic('n');
|
||||
jMenuItem1.setText("New");
|
||||
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(jMenuItem1);
|
||||
|
||||
openMenuItem.setMnemonic('o');
|
||||
openMenuItem.setText("Open");
|
||||
openMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
openMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(openMenuItem);
|
||||
|
||||
saveMenuItem.setMnemonic('s');
|
||||
saveMenuItem.setText("Save");
|
||||
fileMenu.add(saveMenuItem);
|
||||
|
||||
saveAsMenuItem.setMnemonic('a');
|
||||
saveAsMenuItem.setText("Save As ...");
|
||||
saveAsMenuItem.setDisplayedMnemonicIndex(5);
|
||||
saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
saveAsMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
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");
|
||||
|
||||
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);
|
||||
editMenu.add(jSeparator1);
|
||||
|
||||
pasteMenuItem.setMnemonic('s');
|
||||
pasteMenuItem.setText("Strategies ...");
|
||||
pasteMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
pasteMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
});
|
||||
editMenu.add(deleteMenuItem);
|
||||
editMenu.add(jSeparator2);
|
||||
|
||||
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);
|
||||
|
||||
menuBar.add(editMenu);
|
||||
|
||||
simMenu.setMnemonic('s');
|
||||
simMenu.setText("Sim");
|
||||
|
||||
simMenuStart.setMnemonic('s');
|
||||
simMenuStart.setText("Start");
|
||||
simMenuStart.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
simMenuStartActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
simMenu.add(simMenuStart);
|
||||
|
||||
simMenuPause.setMnemonic('p');
|
||||
simMenuPause.setText("Pause");
|
||||
simMenuPause.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
simMenuPauseActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
simMenu.add(simMenuPause);
|
||||
|
||||
simMenuStop.setMnemonic('t');
|
||||
simMenuStop.setText("Stop");
|
||||
simMenuStop.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
simMenuStopActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
simMenu.add(simMenuStop);
|
||||
simMenu.add(jSeparator3);
|
||||
|
||||
jMenuItem4.setText("Point Zero");
|
||||
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem4ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
simMenu.add(jMenuItem4);
|
||||
|
||||
jMenuItem5.setText("jMenuItem5");
|
||||
simMenu.add(jMenuItem5);
|
||||
|
||||
menuBar.add(simMenu);
|
||||
|
||||
viewMenu.setMnemonic('v');
|
||||
viewMenu.setText("View");
|
||||
|
||||
viewTraderListCheckBox.setMnemonic('t');
|
||||
viewTraderListCheckBox.setText("Traders");
|
||||
viewTraderListCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
viewTraderListCheckBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
viewMenu.add(viewTraderListCheckBox);
|
||||
|
||||
viewClock.setText("Clock");
|
||||
viewClock.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
viewClockActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
viewMenu.add(viewClock);
|
||||
|
||||
jMenuItem3.setText("LogWindow");
|
||||
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem3ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
viewMenu.add(jMenuItem3);
|
||||
|
||||
jCheckBoxMenuItem1.setText("Orderbook");
|
||||
jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jCheckBoxMenuItem1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
viewMenu.add(jCheckBoxMenuItem1);
|
||||
|
||||
menuBar.add(viewMenu);
|
||||
|
||||
helpMenu.setMnemonic('h');
|
||||
helpMenu.setText("Help");
|
||||
|
||||
contentMenuItem.setMnemonic('c');
|
||||
contentMenuItem.setText("Contents");
|
||||
helpMenu.add(contentMenuItem);
|
||||
|
||||
aboutMenuItem.setMnemonic('a');
|
||||
aboutMenuItem.setText("About");
|
||||
aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
aboutMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
helpMenu.add(aboutMenuItem);
|
||||
|
||||
menuBar.add(helpMenu);
|
||||
|
||||
setJMenuBar(menuBar);
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
void pauseSim() {
|
||||
Globals.se.timer.pause();
|
||||
}
|
||||
|
||||
void startSim() {
|
||||
|
||||
resetSim();
|
||||
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
|
||||
Globals.se.putConfig(jo);
|
||||
|
||||
this.stopButton.setEnabled(true);
|
||||
|
||||
// this.orderBookPanel.invalidate();
|
||||
// this.orderBookPanel.repaint();
|
||||
this.clock.invalidate();
|
||||
this.clock.repaint();
|
||||
|
||||
this.startTraders();
|
||||
|
||||
Globals.se.timer.setPause(false);
|
||||
Globals.se.timer.start();
|
||||
Globals.se.timer.setAcceleration((Double) this.accelSpinner.getValue());
|
||||
|
||||
Scheduler.TimerTaskRunner tt = new Scheduler.TimerTaskRunner() {
|
||||
@Override
|
||||
public long timerTask() {
|
||||
System.out.printf("Hello i will inject money\n");
|
||||
// Globals.se.injectMoney();
|
||||
return 1000 * 60 * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getID() {
|
||||
return 7L;
|
||||
}
|
||||
|
||||
};
|
||||
// Globals.se.timer.startTimerTask(tt, 0);
|
||||
|
||||
}
|
||||
|
||||
void stopSim() {
|
||||
Globals.se.timer.terminate();
|
||||
this.stopButton.setEnabled(false);
|
||||
}
|
||||
|
||||
void resetSim() {
|
||||
Globals.se.terminate();
|
||||
Globals.se.reset();
|
||||
chart.initChart();
|
||||
chart.invalidate();
|
||||
chart.repaint();
|
||||
// this.orderBookPanel.invalidate();
|
||||
// this.orderBookPanel.repaint();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void editPreferencesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editPreferencesActionPerformed
|
||||
Globals.LOGGER.info("Edit prefs...");
|
||||
|
||||
Dialog d = new gui.EditPreferencesDialog(this, rootPaneCheckingEnabled);
|
||||
d.setVisible(rootPaneCheckingEnabled);
|
||||
}//GEN-LAST:event_editPreferencesActionPerformed
|
||||
|
||||
|
||||
private void deleteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMenuItemActionPerformed
|
||||
EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this, true);
|
||||
ed.setVisible(rootPaneCheckingEnabled);
|
||||
|
||||
|
||||
}//GEN-LAST:event_deleteMenuItemActionPerformed
|
||||
|
||||
private void pasteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pasteMenuItemActionPerformed
|
||||
EditStrategies s = new EditStrategies(this, true);
|
||||
s.setVisible(rootPaneCheckingEnabled);
|
||||
|
||||
|
||||
}//GEN-LAST:event_pasteMenuItemActionPerformed
|
||||
|
||||
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
|
||||
|
||||
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);
|
||||
|
||||
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jMenuItem1ActionPerformed
|
||||
|
||||
private void simMenuStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simMenuStartActionPerformed
|
||||
startSim();
|
||||
}//GEN-LAST:event_simMenuStartActionPerformed
|
||||
|
||||
private void simMenuPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simMenuPauseActionPerformed
|
||||
pauseSim();
|
||||
}//GEN-LAST:event_simMenuPauseActionPerformed
|
||||
|
||||
private void simMenuStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simMenuStopActionPerformed
|
||||
stopSim();
|
||||
}//GEN-LAST:event_simMenuStopActionPerformed
|
||||
|
||||
private void accelSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_accelSpinnerStateChanged
|
||||
Double val = (Double) this.accelSpinner.getValue();
|
||||
Globals.se.timer.setAcceleration(val);
|
||||
}//GEN-LAST:event_accelSpinnerStateChanged
|
||||
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
Globals.se.timer.pause();
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runButtonActionPerformed
|
||||
startSim();
|
||||
}//GEN-LAST:event_runButtonActionPerformed
|
||||
|
||||
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
|
||||
stopSim();
|
||||
}//GEN-LAST:event_stopButtonActionPerformed
|
||||
|
||||
private void jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem1ActionPerformed
|
||||
JDialog jd = new gui.orderbook.OrderBookDialog(this, false);
|
||||
jd.setVisible(rootPaneCheckingEnabled);
|
||||
}//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed
|
||||
|
||||
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
|
||||
Globals.se.pointZero();
|
||||
}//GEN-LAST:event_jMenuItem4ActionPerformed
|
||||
|
||||
TraderListDialog tld = null;
|
||||
private void viewTraderListCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewTraderListCheckBoxActionPerformed
|
||||
System.out.printf("Trwindow: %s\n", Boolean.toString(this.viewTraderListCheckBox.getState()));
|
||||
if (this.viewTraderListCheckBox.getState()) {
|
||||
if (tld == null) {
|
||||
tld = new TraderListDialog(this, false);
|
||||
tld.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
super.windowClosing(e);
|
||||
viewTraderListCheckBox.setState(false);
|
||||
System.out.printf("Set menu false\n");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
tld.setVisible(true);
|
||||
} else if (tld != null) {
|
||||
System.out.printf("Set visible = false\n");
|
||||
tld.setVisible(false);
|
||||
}
|
||||
}//GEN-LAST:event_viewTraderListCheckBoxActionPerformed
|
||||
|
||||
private void accelSpinnerPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_accelSpinnerPropertyChange
|
||||
System.out.printf("Accel Spinner PRop Change\n");
|
||||
}//GEN-LAST:event_accelSpinnerPropertyChange
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
* @throws java.lang.IllegalAccessException
|
||||
* @throws java.lang.InstantiationException
|
||||
*/
|
||||
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
|
||||
|
||||
sesim.AutoTraderLoader tl = new sesim.AutoTraderLoader();
|
||||
tl.getTraders();
|
||||
|
||||
//System.exit(0);
|
||||
Globals.se = new Exchange();
|
||||
|
||||
Class<?> c = sesim.Exchange.class;
|
||||
Globals.prefs = Preferences.userNodeForPackage(c);
|
||||
|
||||
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
|
||||
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new NewMDIApplication().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem aboutMenuItem;
|
||||
private javax.swing.JSpinner accelSpinner;
|
||||
private chart.Chart chart;
|
||||
private gui.Clock clock;
|
||||
private javax.swing.JMenuItem contentMenuItem;
|
||||
private javax.swing.JMenuItem deleteMenuItem;
|
||||
private javax.swing.JMenuItem editExchangeMenuItem;
|
||||
private javax.swing.JMenu editMenu;
|
||||
private javax.swing.JMenuItem editPreferences;
|
||||
private javax.swing.JMenuItem exitMenuItem;
|
||||
private javax.swing.JMenu fileMenu;
|
||||
private javax.swing.JMenu helpMenu;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JScrollPane jChartScrollPane;
|
||||
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JMenuItem jMenuItem1;
|
||||
private javax.swing.JMenuItem jMenuItem3;
|
||||
private javax.swing.JMenuItem jMenuItem4;
|
||||
private javax.swing.JMenuItem jMenuItem5;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator1;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator2;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator3;
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JSplitPane jSplitPane2;
|
||||
private javax.swing.JSplitPane jSplitPane3;
|
||||
private javax.swing.JSplitPane jSplitPane4;
|
||||
private javax.swing.JSplitPane jSplitPane5;
|
||||
private javax.swing.JTextArea jTextArea1;
|
||||
private javax.swing.JMenuBar menuBar;
|
||||
private javax.swing.JMenuItem openMenuItem;
|
||||
private gui.orderbook.OrderBook orderBookNew1;
|
||||
private gui.orderbook.OrderBooksHorizontal orderBooksHorizontal1;
|
||||
private javax.swing.JMenuItem pasteMenuItem;
|
||||
private gui.orderbook.QuoteVertical quoteVertical1;
|
||||
private javax.swing.JButton runButton;
|
||||
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 simMenuStop;
|
||||
private gui.Statistics statistics1;
|
||||
private javax.swing.JButton stopButton;
|
||||
private javax.swing.JMenuItem viewClock;
|
||||
private javax.swing.JMenu viewMenu;
|
||||
private javax.swing.JCheckBoxMenuItem viewTraderListCheckBox;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
125
src/gui/NewStrategyDialog.form
Normal file
125
src/gui/NewStrategyDialog.form
Normal file
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="Create Strategy"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="268" max="32767" attributes="0"/>
|
||||
<Component id="jOkButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jStrategyComboBox" max="32767" attributes="0"/>
|
||||
<Component id="jTextField1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jStrategyComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="23" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jOkButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JComboBox" name="jStrategyComboBox">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jOkButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jOkButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Base:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField1">
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Name:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
224
src/gui/NewStrategyDialog.java
Normal file
224
src/gui/NewStrategyDialog.java
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
//public class NewStrategyDialog extends javax.swing.JDialog {
|
||||
public class NewStrategyDialog extends EscDialog {
|
||||
|
||||
/**
|
||||
* Creates new form NewStrategyDialog
|
||||
*/
|
||||
public NewStrategyDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(this.getParent());
|
||||
boolean devel = Globals.prefs.get(Globals.DEVELSTATUS, "false").equals("true");
|
||||
ArrayList <String> names = Globals.tloader.getDefaultStrategyNames(devel);
|
||||
this.jStrategyComboBox.removeAllItems();
|
||||
names.stream().forEach((s) -> {
|
||||
this.jStrategyComboBox.addItem(s);
|
||||
});
|
||||
}
|
||||
|
||||
class Result{
|
||||
String base;
|
||||
String name;
|
||||
}
|
||||
|
||||
Result result=null;
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jStrategyComboBox = new javax.swing.JComboBox<>();
|
||||
jOkButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jTextField1 = new javax.swing.JTextField();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Create Strategy");
|
||||
|
||||
jStrategyComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
|
||||
jOkButton.setText("Ok");
|
||||
jOkButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jOkButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setMnemonic('c');
|
||||
jButton2.setText("Cancel");
|
||||
jButton2.setToolTipText("");
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText("Base:");
|
||||
|
||||
jTextField1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jTextField1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel2.setText("Name:");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 268, Short.MAX_VALUE)
|
||||
.addComponent(jOkButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(jLabel2))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jStrategyComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jTextField1))))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jStrategyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel1))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jOkButton)
|
||||
.addComponent(jButton2))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jTextField1ActionPerformed
|
||||
|
||||
private void saveResult(){
|
||||
String name = this.jTextField1.getText();
|
||||
if (name.equals("")){
|
||||
return;
|
||||
}
|
||||
|
||||
this.result = new Result();
|
||||
this.result.base = (String) this.jStrategyComboBox.getSelectedItem();
|
||||
this.result.name = name;
|
||||
this.dispose();
|
||||
|
||||
}
|
||||
|
||||
private void jOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jOkButtonActionPerformed
|
||||
this.saveResult();
|
||||
}//GEN-LAST:event_jOkButtonActionPerformed
|
||||
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
NewStrategyDialog dialog = new NewStrategyDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JButton jOkButton;
|
||||
private javax.swing.JComboBox<String> jStrategyComboBox;
|
||||
private javax.swing.JTextField jTextField1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
74
src/gui/OderBookPanelNew.form
Normal file
74
src/gui/OderBookPanelNew.form
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="filler1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="quotePanel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="orderBookNew3" alignment="1" pref="585" max="32767" attributes="0"/>
|
||||
<Component id="orderBookNew4" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="orderBookNew3" min="-2" pref="156" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="70" max="-2" attributes="0"/>
|
||||
<Component id="filler1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
|
||||
<Component id="quotePanel1" min="-2" pref="91" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="orderBookNew4" min="-2" pref="176" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="gui.QuotePanel" name="quotePanel1">
|
||||
</Component>
|
||||
<Component class="gui.orderbook.OrderBook" name="orderBookNew3">
|
||||
</Component>
|
||||
<Component class="gui.orderbook.OrderBook" name="orderBookNew4">
|
||||
</Component>
|
||||
<Component class="javax.swing.Box$Filler" name="filler1">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 32767]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalGlue"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
95
src/gui/OderBookPanelNew.java
Normal file
95
src/gui/OderBookPanelNew.java
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class OderBookPanelNew extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form OderBookPanelNew
|
||||
*/
|
||||
public OderBookPanelNew() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
quotePanel1 = new gui.QuotePanel();
|
||||
orderBookNew3 = new gui.orderbook.OrderBook();
|
||||
orderBookNew4 = new gui.orderbook.OrderBook();
|
||||
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(quotePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(orderBookNew3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)
|
||||
.addComponent(orderBookNew4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(orderBookNew3, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(70, 70, 70)
|
||||
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(30, 30, 30)
|
||||
.addComponent(quotePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(orderBookNew4, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.Box.Filler filler1;
|
||||
private gui.orderbook.OrderBook orderBookNew3;
|
||||
private gui.orderbook.OrderBook orderBookNew4;
|
||||
private gui.QuotePanel quotePanel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
100
src/gui/OpenOrdersList.form
Normal file
100
src/gui/OpenOrdersList.form
Normal file
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.6" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Container class="javax.swing.JPopupMenu" name="ctxMenu">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="ctxMenuCreateBuyOrder">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Create Buy Order"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ctxMenuCreateBuyOrderActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="ctxMenuCreateSellOrder">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Create Sell Order"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ctxMenuCreateSellOrderActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="ctxMenuCancelOrder">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Cancel Order"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ctxMenuCancelOrderActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="ctxMenuModifyOder">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Modify Oder"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</NonVisualComponents>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="221" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="table">
|
||||
<Properties>
|
||||
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||
<Table columnCount="7" rowCount="3">
|
||||
<Column editable="false" title="ID" type="java.lang.Long"/>
|
||||
<Column editable="false" title="Type" type="java.lang.String"/>
|
||||
<Column editable="false" title="Limit" type="java.lang.Double"/>
|
||||
<Column editable="false" title="Vol. Executed" type="java.lang.Double"/>
|
||||
<Column editable="false" title="Av. Price" type="java.lang.Double"/>
|
||||
<Column editable="false" title="Volume" type="java.lang.Double"/>
|
||||
<Column editable="false" title="Status" type="java.lang.String"/>
|
||||
</Table>
|
||||
</Property>
|
||||
<Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
|
||||
<JTableSelectionModel selectionMode="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="tableMousePressed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
249
src/gui/OpenOrdersList.java
Normal file
249
src/gui/OpenOrdersList.java
Normal file
@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright (c) 2017, tobias
|
||||
* 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;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.MouseInfo;
|
||||
import java.awt.Point;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import sesim.Exchange;
|
||||
import sesim.Exchange.Account;
|
||||
import sesim.Exchange.Order;
|
||||
import sesim.Exchange.OrderType;
|
||||
import traders.ManTrader.CreateOrderDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tobias
|
||||
*/
|
||||
public class OpenOrdersList extends javax.swing.JPanel {
|
||||
|
||||
private Account account;
|
||||
DefaultTableModel model;
|
||||
|
||||
public final void updateModel() {
|
||||
System.out.printf("Update Model\n");
|
||||
if (null == account) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.printf("Now updateing\n");
|
||||
|
||||
int row = 0;
|
||||
|
||||
Iterator<Map.Entry<Long, Order>> it = account.getOrders().entrySet().iterator();
|
||||
model.setRowCount(account.getOrders().size());
|
||||
while (it.hasNext()) {
|
||||
Map.Entry e = it.next();
|
||||
Long k = (Long) e.getKey();
|
||||
Order o = (Order) e.getValue();
|
||||
|
||||
model.setValueAt(k, row, 0);
|
||||
|
||||
model.setValueAt(((Order) o).getType().toString(), row, 1);
|
||||
|
||||
model.setValueAt(((Order) o).getLimit(), row, 2);
|
||||
model.setValueAt(((Order) o).getExecuted(), row, 3);
|
||||
model.setValueAt(((Order) o).getAvaragePrice(), row, 4);
|
||||
model.setValueAt(((Order) o).getInitialVolume(), row, 5);
|
||||
model.setValueAt(((Order) o).getOrderStatus().toString(), row, 6);
|
||||
row++;
|
||||
}
|
||||
this.table.getRowSorter().allRowsChanged();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form OrdersList
|
||||
*/
|
||||
public OpenOrdersList() {
|
||||
initComponents();
|
||||
model = (DefaultTableModel) table.getModel();
|
||||
model.setRowCount(0);
|
||||
table.setFillsViewportHeight(true);
|
||||
updateModel();
|
||||
}
|
||||
|
||||
public void initOrderList(Account account) {
|
||||
this.account = account;
|
||||
updateModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
ctxMenu = new javax.swing.JPopupMenu();
|
||||
ctxMenuCreateBuyOrder = new javax.swing.JMenuItem();
|
||||
ctxMenuCreateSellOrder = new javax.swing.JMenuItem();
|
||||
ctxMenuCancelOrder = new javax.swing.JMenuItem();
|
||||
ctxMenuModifyOder = new javax.swing.JMenuItem();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
table = new javax.swing.JTable();
|
||||
|
||||
ctxMenuCreateBuyOrder.setText("Create Buy Order");
|
||||
ctxMenuCreateBuyOrder.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
ctxMenuCreateBuyOrderActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
ctxMenu.add(ctxMenuCreateBuyOrder);
|
||||
|
||||
ctxMenuCreateSellOrder.setText("Create Sell Order");
|
||||
ctxMenuCreateSellOrder.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
ctxMenuCreateSellOrderActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
ctxMenu.add(ctxMenuCreateSellOrder);
|
||||
|
||||
ctxMenuCancelOrder.setText("Cancel Order");
|
||||
ctxMenuCancelOrder.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
ctxMenuCancelOrderActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
ctxMenu.add(ctxMenuCancelOrder);
|
||||
|
||||
ctxMenuModifyOder.setText("Modify Oder");
|
||||
ctxMenu.add(ctxMenuModifyOder);
|
||||
|
||||
table.setAutoCreateRowSorter(true);
|
||||
table.setModel(new javax.swing.table.DefaultTableModel(
|
||||
new Object [][] {
|
||||
{null, null, null, null, null, null, null},
|
||||
{null, null, null, null, null, null, null},
|
||||
{null, null, null, null, null, null, null}
|
||||
},
|
||||
new String [] {
|
||||
"ID", "Type", "Limit", "Vol. Executed", "Av. Price", "Volume", "Status"
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.String.class
|
||||
};
|
||||
boolean[] canEdit = new boolean [] {
|
||||
false, false, false, false, false, false, false
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types [columnIndex];
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit [columnIndex];
|
||||
}
|
||||
});
|
||||
table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
table.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
tableMousePressed(evt);
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(table);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void tableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMousePressed
|
||||
|
||||
Point point = evt.getPoint();
|
||||
int currentRow = table.rowAtPoint(point);
|
||||
if (currentRow == -1) {
|
||||
|
||||
} else {
|
||||
|
||||
table.setRowSelectionInterval(currentRow, currentRow);
|
||||
}
|
||||
|
||||
int nbuttons = MouseInfo.getNumberOfButtons();
|
||||
int button = evt.getButton();
|
||||
if (!evt.isPopupTrigger()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.ctxMenu.show(this, evt.getX(), evt.getY());
|
||||
|
||||
System.out.printf("Button %d %d \n", nbuttons, button);
|
||||
|
||||
}//GEN-LAST:event_tableMousePressed
|
||||
|
||||
private void createOrder(OrderType t) {
|
||||
CreateOrderDialog cd = new CreateOrderDialog(Globals.frame, true, account, t);
|
||||
//cd.initDialog(account);
|
||||
cd.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ctxMenuCreateSellOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ctxMenuCreateSellOrderActionPerformed
|
||||
createOrder(OrderType.SELLLIMIT);
|
||||
|
||||
}//GEN-LAST:event_ctxMenuCreateSellOrderActionPerformed
|
||||
|
||||
private void ctxMenuCreateBuyOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ctxMenuCreateBuyOrderActionPerformed
|
||||
createOrder(OrderType.BUYLIMIT);
|
||||
}//GEN-LAST:event_ctxMenuCreateBuyOrderActionPerformed
|
||||
|
||||
private void ctxMenuCancelOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ctxMenuCancelOrderActionPerformed
|
||||
int r = table.getSelectedRow();
|
||||
Long id = (Long) model.getValueAt(r, 0);
|
||||
|
||||
System.out.printf("Should cancel %d\n", id);
|
||||
Globals.se.cancelOrder(account.getID(), id);
|
||||
|
||||
}//GEN-LAST:event_ctxMenuCancelOrderActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPopupMenu ctxMenu;
|
||||
private javax.swing.JMenuItem ctxMenuCancelOrder;
|
||||
private javax.swing.JMenuItem ctxMenuCreateBuyOrder;
|
||||
private javax.swing.JMenuItem ctxMenuCreateSellOrder;
|
||||
private javax.swing.JMenuItem ctxMenuModifyOder;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JTable table;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
89
src/gui/OrderBook.form
Normal file
89
src/gui/OrderBook.form
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="orderBookScroller" alignment="1" pref="162" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="orderBookScroller" alignment="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="orderBookScroller">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="orderBookList">
|
||||
<Properties>
|
||||
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo">
|
||||
<MatteColorBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||
<Table columnCount="3" rowCount="30">
|
||||
<Column editable="false" title="id" type="java.lang.Object">
|
||||
<Data value="1"/>
|
||||
<Data value="2"/>
|
||||
<Data value="3"/>
|
||||
<Data value="4"/>
|
||||
<Data value="5"/>
|
||||
<Data value="7"/>
|
||||
<Data value="4"/>
|
||||
<Data value="null"/>
|
||||
<Data value="3"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
<Data value="null"/>
|
||||
</Column>
|
||||
<Column editable="false" title="Title 2pri" type="java.lang.Object"/>
|
||||
<Column editable="false" title="Title 3" type="java.lang.Object"/>
|
||||
</Table>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
304
src/gui/OrderBook.java
Normal file
304
src/gui/OrderBook.java
Normal file
@ -0,0 +1,304 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
import sesim.Exchange;
|
||||
import sesim.Exchange.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Formatter;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.SwingUtilities;
|
||||
import java.awt.*;
|
||||
import java.text.DecimalFormat;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
/**
|
||||
* OderBook Class
|
||||
*/
|
||||
public abstract class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiver {
|
||||
|
||||
|
||||
OrderBookListModel model;
|
||||
|
||||
abstract ArrayList <Order> getOrderBook();
|
||||
|
||||
// private Color hdr_color = Color.LIGHT_GRAY;
|
||||
|
||||
private class OrderBookCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
/* @Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus,
|
||||
int row, int column) {
|
||||
DefaultTableCellRenderer renderer
|
||||
= (DefaultTableCellRenderer) super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column);
|
||||
// renderer.setBackground(hdr_color);
|
||||
return renderer;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void UpdateOrderBook() {
|
||||
|
||||
class Updater implements Runnable{
|
||||
OrderBookListModel model;
|
||||
ArrayList <Order> newlist;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
model.update(this.newlist);
|
||||
}
|
||||
|
||||
Updater(OrderBookListModel model, ArrayList newlist){
|
||||
this.model = model;
|
||||
this.newlist = newlist;
|
||||
}
|
||||
|
||||
}
|
||||
ArrayList newlist = getOrderBook();
|
||||
//this.orderBookScroller.scrollRectToVisible(this.orderBookList.getCellRect(this.orderBookList.getRowCount()-1, 0, true));
|
||||
SwingUtilities.invokeLater(new Updater(this.model,newlist));
|
||||
|
||||
//this.scrollRectToVisible(this.getCellRect(rowIndex, vColIndex, false));
|
||||
|
||||
|
||||
}
|
||||
|
||||
boolean getDesc() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// protected OrderBookListModel model;
|
||||
|
||||
protected class OrderBookListModel extends AbstractTableModel {
|
||||
|
||||
private ArrayList <Order> list;
|
||||
//private final boolean desc = false;
|
||||
|
||||
public OrderBookListModel() {
|
||||
// System.out.print("CREATING A NEW MODEL\n");
|
||||
// update();
|
||||
list = getOrderBook();
|
||||
}
|
||||
|
||||
// int update_calls = 0;
|
||||
int colcount_calls = 0;
|
||||
|
||||
public void update(ArrayList newlist) {
|
||||
list = newlist; //getOrderBook();
|
||||
this.fireTableDataChanged();
|
||||
|
||||
// this.update_calls++;
|
||||
// int hc = this.hashCode();
|
||||
//System.out.print("Update/ColCalls = " + update_calls + "/" + colcount_calls + " HC: " + hc + "\n");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getColumnName(int c) {
|
||||
switch (c) {
|
||||
case 0:
|
||||
return "ID";
|
||||
case 1:
|
||||
return "Price";
|
||||
case 2:
|
||||
return "Vol.";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
colcount_calls++;
|
||||
// System.out.print("Update/ColCalls = " + update_calls + "/" + colcount_calls + "\n");
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
DecimalFormat dfm = new DecimalFormat("0.00#");
|
||||
DecimalFormat dfv = new DecimalFormat("0.#");
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int r, int c) {
|
||||
|
||||
|
||||
Order o;
|
||||
|
||||
int s = list.size();
|
||||
//System.out.print("Looking for Value at" + r + ":" + c + " w size:" + s + "\n");
|
||||
|
||||
if (!getDesc()) {
|
||||
o = list.get(r);
|
||||
} else {
|
||||
o = list.get(list.size() - r - 1);
|
||||
}
|
||||
// Formatter f = new Formatter();
|
||||
switch (c) {
|
||||
case 0:
|
||||
// o.getAccount().getID();
|
||||
|
||||
return o.getAccount().getOwner().getName();
|
||||
|
||||
//return String.format("#%06x", o.getID());
|
||||
|
||||
case 1:
|
||||
//return String.format("%.f",o.getLimit());
|
||||
return dfm.format((double)o.getLimit());
|
||||
|
||||
case 2:
|
||||
double v = o.getVolume();
|
||||
if(v<=0){
|
||||
// System.out.printf("Order: %s %f %f\n",o.getType().toString(),o.getVolume(),o.getLimit());
|
||||
// System.exit(0);
|
||||
}
|
||||
|
||||
return dfv.format((double)o.getVolume());
|
||||
//return String.format("%f", o.getVolume());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form OrderBook
|
||||
*/
|
||||
public OrderBook() {
|
||||
//System.out.print("init Orderbook]\n");
|
||||
initComponents();
|
||||
|
||||
// this.setBorder(BorderFactory.createEmptyBorder());
|
||||
// this.orderBookScroller.setBorder(BorderFactory.createBevelBorder(0));
|
||||
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.model = new OrderBookListModel();
|
||||
this.orderBookList.setModel(model);
|
||||
|
||||
// orderBookList.setBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
JTableHeader h = this.orderBookList.getTableHeader();
|
||||
// h.setBackground(hdr_color);
|
||||
// h.setForeground(Color.green);
|
||||
// h.setDefaultRenderer(new OrderBookCellRenderer());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
orderBookScroller = new javax.swing.JScrollPane();
|
||||
orderBookList = new javax.swing.JTable();
|
||||
|
||||
orderBookList.setAutoCreateRowSorter(true);
|
||||
orderBookList.setBorder(new javax.swing.border.MatteBorder(null));
|
||||
orderBookList.setModel(new javax.swing.table.DefaultTableModel(
|
||||
new Object [][] {
|
||||
{"1", null, null},
|
||||
{"2", null, null},
|
||||
{"3", null, null},
|
||||
{"4", null, null},
|
||||
{"5", null, null},
|
||||
{"7", null, null},
|
||||
{"4", null, null},
|
||||
{null, null, null},
|
||||
{"3", null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null}
|
||||
},
|
||||
new String [] {
|
||||
"id", "Title 2pri", "Title 3"
|
||||
}
|
||||
) {
|
||||
boolean[] canEdit = new boolean [] {
|
||||
false, false, false
|
||||
};
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit [columnIndex];
|
||||
}
|
||||
});
|
||||
orderBookList.setFocusable(false);
|
||||
orderBookList.setOpaque(false);
|
||||
orderBookScroller.setViewportView(orderBookList);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(orderBookScroller, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(orderBookScroller, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JTable orderBookList;
|
||||
private javax.swing.JScrollPane orderBookScroller;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
33
src/gui/OrderBookDialog.form
Normal file
33
src/gui/OrderBookDialog.form
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-118,0,0,1,-80"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="gui.orderbook.OrderBook" name="orderBookNew1">
|
||||
</Component>
|
||||
<Component class="gui.QuotePanel" name="quotePanel1">
|
||||
</Component>
|
||||
<Component class="gui.orderbook.OrderBook" name="orderBookNew2">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
111
src/gui/OrderBookDialog.java
Normal file
111
src/gui/OrderBookDialog.java
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class OrderBookDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form OrderBookDialog
|
||||
*/
|
||||
public OrderBookDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
orderBookNew1 = new gui.orderbook.OrderBook();
|
||||
quotePanel1 = new gui.QuotePanel();
|
||||
orderBookNew2 = new gui.orderbook.OrderBook();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
getContentPane().setLayout(new java.awt.FlowLayout());
|
||||
getContentPane().add(orderBookNew1);
|
||||
getContentPane().add(quotePanel1);
|
||||
getContentPane().add(orderBookNew2);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
OrderBookDialog dialog = new OrderBookDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.orderbook.OrderBook orderBookNew1;
|
||||
private gui.orderbook.OrderBook orderBookNew2;
|
||||
private gui.QuotePanel quotePanel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
459
src/gui/OrderBookPanel.form
Normal file
459
src/gui/OrderBookPanel.form
Normal file
@ -0,0 +1,459 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[220, 262]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,41,0,0,2,75"/>
|
||||
</AuxValues>
|
||||
<SubComponents>
|
||||
<Component class="gui.AskBook" name="askBook1">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[200, 200]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="gui.BidBook" name="bidBook1">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[200, 200]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Container class="gui.QuotePanel" name="quotePanel2">
|
||||
<Properties>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[587, 200]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.5" weightY="0.5"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
<LayoutCode>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="1_quotePanel2Layout">
|
||||
<CodeVariable name="quotePanel2Layout" type="4096" declaredType="java.awt.GridBagLayout"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="1_quotePanel2Layout"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="1_quotePanel2Layout"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="columnWidths" class="java.awt.GridBagLayout"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="2">
|
||||
<ExpressionOrigin>
|
||||
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
|
||||
<PropertyValue value="[0, 5, 0, 5, 0]"/>
|
||||
</Value>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="1_quotePanel2Layout"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="3">
|
||||
<ExpressionOrigin>
|
||||
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
|
||||
<PropertyValue value="[0]"/>
|
||||
</Value>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="4_quotePanel2">
|
||||
<CodeVariable name="quotePanel2" type="8194" declaredType="gui.QuotePanel"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="quotePanel2"/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="1_quotePanel2Layout"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
</LayoutCode>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
<LayoutCode>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="5_layout">
|
||||
<CodeVariable name="layout" type="4096" declaredType="java.awt.GridBagLayout"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="5_layout"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="5_layout"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="columnWidths" class="java.awt.GridBagLayout"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="6">
|
||||
<ExpressionOrigin>
|
||||
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
|
||||
<PropertyValue value="[0]"/>
|
||||
</Value>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="5_layout"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="7">
|
||||
<ExpressionOrigin>
|
||||
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
|
||||
<PropertyValue value="[0, 5, 0, 5, 0]"/>
|
||||
</Value>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="8">
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="."/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="5_layout"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints">
|
||||
<CodeVariable name="gridBagConstraints" type="20480" declaredType="java.awt.GridBagConstraints"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="10">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="11">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="fill" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="12">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="1"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weightx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="13">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="1.0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weighty" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="14">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="1.0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="8"/>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="15_askBook1">
|
||||
<CodeVariable name="askBook1" type="8194" declaredType="gui.AskBook"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="askBook1"/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints">
|
||||
<CodeVariable name="gridBagConstraints"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="17">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="18">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="4"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="fill" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="19">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="1"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weightx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="20">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="1.0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weighty" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="21">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="1.0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="8"/>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="22_bidBook1">
|
||||
<CodeVariable name="bidBook1" type="8194" declaredType="gui.BidBook"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="bidBook1"/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="23_gridBagConstraints">
|
||||
<CodeVariable name="gridBagConstraints"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="23_gridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="23_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="24">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="23_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="25">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="2"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="23_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="fill" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="26">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="1"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="23_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weightx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="27">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="0.5"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="23_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weighty" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="28">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="0.5"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="8"/>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="4_quotePanel2"/>
|
||||
<CodeExpression id="23_gridBagConstraints"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
</LayoutCode>
|
||||
</Form>
|
111
src/gui/OrderBookPanel.java
Normal file
111
src/gui/OrderBookPanel.java
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
//import SeSim.*;
|
||||
import static java.lang.Thread.sleep;
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Formatter;
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class OrderBookPanel extends javax.swing.JPanel {
|
||||
|
||||
sesim.Exchange se;
|
||||
|
||||
public OrderBookPanel() {
|
||||
this.se = Globals.se;
|
||||
|
||||
initComponents();
|
||||
|
||||
if (this.se == null) {
|
||||
return;
|
||||
}
|
||||
// System.out.print("Order boo init\n");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
java.awt.GridBagConstraints gridBagConstraints;
|
||||
|
||||
askBook1 = new gui.AskBook();
|
||||
bidBook1 = new gui.BidBook();
|
||||
quotePanel2 = new gui.QuotePanel();
|
||||
|
||||
setPreferredSize(new java.awt.Dimension(220, 262));
|
||||
java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
|
||||
layout.columnWidths = new int[] {0};
|
||||
layout.rowHeights = new int[] {0, 5, 0, 5, 0};
|
||||
setLayout(layout);
|
||||
|
||||
askBook1.setPreferredSize(new java.awt.Dimension(200, 200));
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 0;
|
||||
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
||||
gridBagConstraints.weightx = 1.0;
|
||||
gridBagConstraints.weighty = 1.0;
|
||||
add(askBook1, gridBagConstraints);
|
||||
|
||||
bidBook1.setPreferredSize(new java.awt.Dimension(200, 200));
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 4;
|
||||
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
||||
gridBagConstraints.weightx = 1.0;
|
||||
gridBagConstraints.weighty = 1.0;
|
||||
add(bidBook1, gridBagConstraints);
|
||||
|
||||
quotePanel2.setOpaque(false);
|
||||
quotePanel2.setPreferredSize(new java.awt.Dimension(587, 200));
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 2;
|
||||
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
||||
gridBagConstraints.weightx = 0.5;
|
||||
gridBagConstraints.weighty = 0.5;
|
||||
add(quotePanel2, gridBagConstraints);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.AskBook askBook1;
|
||||
private gui.BidBook bidBook1;
|
||||
private gui.QuotePanel quotePanel2;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
326
src/gui/QuotePanel.form
Normal file
326
src/gui/QuotePanel.form
Normal file
@ -0,0 +1,326 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,66,0,0,1,99"/>
|
||||
</AuxValues>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lastPrice">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||
<FontInfo relative="true">
|
||||
<Font bold="true" component="lastPrice" property="font" relativeSize="true" size="4"/>
|
||||
</FontInfo>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="0.00"/>
|
||||
<Property name="opaque" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.9" weightY="0.9"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 18]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
<LayoutCode>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="1_layout">
|
||||
<CodeVariable name="layout" type="4096" declaredType="java.awt.GridBagLayout"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="1_layout"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="1_layout"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="columnWidths" class="java.awt.GridBagLayout"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="2">
|
||||
<ExpressionOrigin>
|
||||
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
|
||||
<PropertyValue value="[0, 5, 0, 5, 0]"/>
|
||||
</Value>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="1_layout"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="3">
|
||||
<ExpressionOrigin>
|
||||
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
|
||||
<PropertyValue value="[0]"/>
|
||||
</Value>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="4">
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="."/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="1_layout"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="5_gridBagConstraints">
|
||||
<CodeVariable name="gridBagConstraints" type="20480" declaredType="java.awt.GridBagConstraints"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="5_gridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="5_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="6">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="5_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="7">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="4"/>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="8_jLabel2">
|
||||
<CodeVariable name="jLabel2" type="8194" declaredType="javax.swing.JLabel"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="jLabel2"/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<CodeExpression id="5_gridBagConstraints"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints">
|
||||
<CodeVariable name="gridBagConstraints"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="10">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="2"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="11">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="fill" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="12">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="1"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weightx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="13">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="0.9"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="weighty" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="14">
|
||||
<ExpressionOrigin>
|
||||
<Value type="double" value="0.9"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="4"/>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="15_lastPrice">
|
||||
<CodeVariable name="lastPrice" type="8194" declaredType="javax.swing.JLabel"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="lastPrice"/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<CodeExpression id="9_gridBagConstraints"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints">
|
||||
<CodeVariable name="gridBagConstraints"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeExpression">
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridx" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="17">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="4"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
<StatementProvider type="CodeField">
|
||||
<CodeField name="gridy" class="java.awt.GridBagConstraints"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="18">
|
||||
<ExpressionOrigin>
|
||||
<Value type="int" value="0"/>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="4"/>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="19_jLabel3">
|
||||
<CodeVariable name="jLabel3" type="8194" declaredType="javax.swing.JLabel"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="jLabel3"/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<CodeExpression id="16_gridBagConstraints"/>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
</LayoutCode>
|
||||
</Form>
|
142
src/gui/QuotePanel.java
Normal file
142
src/gui/QuotePanel.java
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
import sesim.Quote;
|
||||
import java.awt.Color;
|
||||
import javax.swing.SwingUtilities;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class QuotePanel extends javax.swing.JPanel implements sesim.Exchange.QuoteReceiver{
|
||||
|
||||
/**
|
||||
* Creates new form QuotePanel
|
||||
*/
|
||||
public QuotePanel() {
|
||||
initComponents();
|
||||
if (Globals.se==null)
|
||||
return;
|
||||
Globals.se.addQuoteReceiver(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
java.awt.GridBagConstraints gridBagConstraints;
|
||||
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
lastPrice = new javax.swing.JLabel();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
|
||||
setBorder(null);
|
||||
java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
|
||||
layout.columnWidths = new int[] {0, 5, 0, 5, 0};
|
||||
layout.rowHeights = new int[] {0};
|
||||
setLayout(layout);
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 0;
|
||||
add(jLabel2, gridBagConstraints);
|
||||
|
||||
lastPrice.setFont(lastPrice.getFont().deriveFont(lastPrice.getFont().getStyle() | java.awt.Font.BOLD, lastPrice.getFont().getSize()+4));
|
||||
lastPrice.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
lastPrice.setText("0.00");
|
||||
lastPrice.setOpaque(true);
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 2;
|
||||
gridBagConstraints.gridy = 0;
|
||||
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
||||
gridBagConstraints.weightx = 0.9;
|
||||
gridBagConstraints.weighty = 0.9;
|
||||
add(lastPrice, gridBagConstraints);
|
||||
|
||||
jLabel3.setPreferredSize(new java.awt.Dimension(30, 18));
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 4;
|
||||
gridBagConstraints.gridy = 0;
|
||||
add(jLabel3, gridBagConstraints);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel lastPrice;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void UpdateQuote(Quote q) {
|
||||
class Updater implements Runnable {
|
||||
QuotePanel qp;
|
||||
String text="";
|
||||
Color color = Color.BLUE;
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
qp.lastPrice.setText(text);
|
||||
qp.lastPrice.setForeground(color);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Updater u= new Updater();
|
||||
u.qp=this;
|
||||
|
||||
if (q.price==q.bid){
|
||||
u.color=new Color(172,0,0);
|
||||
}
|
||||
if (q.price==q.ask){
|
||||
u.color=new Color(0,120,0); //.; //new Color(30,0,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
u.text = String.format("%.8f\n(%.0f)", q.price,q.volume);
|
||||
|
||||
SwingUtilities.invokeLater(u);
|
||||
|
||||
// SortedSet s = MainWin.se.getQuoteHistory(5);
|
||||
|
||||
// System.out.print(
|
||||
// "SortedSet size:"
|
||||
// +s.size()
|
||||
// +"\n"
|
||||
// );
|
||||
|
||||
//this.lastPrice.setText(lp);
|
||||
}
|
||||
}
|
35
src/gui/Statistics.form
Normal file
35
src/gui/Statistics.form
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="380" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="280" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
67
src/gui/Statistics.java
Normal file
67
src/gui/Statistics.java
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class Statistics extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form Statistics
|
||||
*/
|
||||
public Statistics() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
setBorder(javax.swing.BorderFactory.createTitledBorder(""));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 380, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 280, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
60
src/gui/StatisticsDialog.form
Normal file
60
src/gui/StatisticsDialog.form
Normal file
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="statisticsPanel1" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="statisticsPanel1" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="gui.StatisticsPanel" name="statisticsPanel1">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="388" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="288" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
131
src/gui/StatisticsDialog.java
Normal file
131
src/gui/StatisticsDialog.java
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class StatisticsDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form StatisticsDialog
|
||||
*/
|
||||
public StatisticsDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
statisticsPanel1 = new gui.StatisticsPanel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
javax.swing.GroupLayout statisticsPanel1Layout = new javax.swing.GroupLayout(statisticsPanel1);
|
||||
statisticsPanel1.setLayout(statisticsPanel1Layout);
|
||||
statisticsPanel1Layout.setHorizontalGroup(
|
||||
statisticsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 388, Short.MAX_VALUE)
|
||||
);
|
||||
statisticsPanel1Layout.setVerticalGroup(
|
||||
statisticsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 288, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(statisticsPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(statisticsPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
StatisticsDialog dialog = new StatisticsDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.StatisticsPanel statisticsPanel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
40
src/gui/StatisticsPanel.form
Normal file
40
src/gui/StatisticsPanel.form
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" pref="216" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" pref="60" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
93
src/gui/StatisticsPanel.java
Normal file
93
src/gui/StatisticsPanel.java
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import sesim.Scheduler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class StatisticsPanel extends javax.swing.JPanel {
|
||||
|
||||
Timer timer;
|
||||
TimerTask clockUpdater;
|
||||
/**
|
||||
* Creates new form StatisticsPanel
|
||||
*/
|
||||
public StatisticsPanel() {
|
||||
initComponents();
|
||||
this.timer = new Timer();
|
||||
clockUpdater = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
long t = Globals.se.timer.currentTimeMillis();
|
||||
|
||||
System.out.printf("The Clock: %d\n", t);
|
||||
jLabel1.setText(Scheduler.formatTimeMillis(t));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
timer.schedule(clockUpdater, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
96
src/gui/StrategySaveDialog.form
Normal file
96
src/gui/StrategySaveDialog.form
Normal file
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="strategyLabel" min="-2" pref="105" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="50" max="32767" attributes="0"/>
|
||||
<Component id="displayNameField" min="-2" pref="286" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancleButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="displayNameField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="strategyLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="33" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="cancleButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="strategyLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jLabel1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="displayNameField">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jTextField1"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="displayNameFieldKeyReleased"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="cancleButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancleButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="okButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
215
src/gui/StrategySaveDialog.java
Normal file
215
src/gui/StrategySaveDialog.java
Normal file
@ -0,0 +1,215 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class StrategySaveDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form StrategySaveDialog
|
||||
*
|
||||
* @param parent
|
||||
* @param modal
|
||||
*/
|
||||
public StrategySaveDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
public void setLabelAndName(String l, String t) {
|
||||
this.strategyLabel.setText(l);
|
||||
this.displayNameField.setText(t);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.displayNameField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
strategyLabel = new javax.swing.JLabel();
|
||||
displayNameField = new javax.swing.JTextField();
|
||||
cancleButton = new javax.swing.JButton();
|
||||
okButton = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
strategyLabel.setText("jLabel1");
|
||||
|
||||
displayNameField.setText("jTextField1");
|
||||
displayNameField.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyReleased(java.awt.event.KeyEvent evt) {
|
||||
displayNameFieldKeyReleased(evt);
|
||||
}
|
||||
});
|
||||
|
||||
cancleButton.setMnemonic('c');
|
||||
cancleButton.setText("Cancel");
|
||||
cancleButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cancleButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
okButton.setMnemonic('o');
|
||||
okButton.setText("Ok");
|
||||
okButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
okButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(strategyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
|
||||
.addComponent(displayNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancleButton)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(15, 15, 15)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(displayNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(strategyLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancleButton)
|
||||
.addComponent(okButton))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
void myCancelButton(){
|
||||
this.displayNameField.setText("");
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
|
||||
private void cancleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancleButtonActionPerformed
|
||||
this.myCancelButton();
|
||||
}//GEN-LAST:event_cancleButtonActionPerformed
|
||||
|
||||
void myOkButton() {
|
||||
if (getName().equals("")) {
|
||||
return;
|
||||
}
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||
this.myOkButton();
|
||||
}//GEN-LAST:event_okButtonActionPerformed
|
||||
|
||||
private void displayNameFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_displayNameFieldKeyReleased
|
||||
|
||||
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
this.myOkButton();
|
||||
}
|
||||
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
this.myCancelButton();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//GEN-LAST:event_displayNameFieldKeyReleased
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(StrategySaveDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(StrategySaveDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(StrategySaveDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(StrategySaveDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
StrategySaveDialog dialog = new StrategySaveDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton cancleButton;
|
||||
private javax.swing.JTextField displayNameField;
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JLabel strategyLabel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
40
src/gui/TraderListDialog.form
Normal file
40
src/gui/TraderListDialog.form
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="Trader List"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="traderListPanel22" alignment="0" pref="922" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="traderListPanel22" alignment="0" pref="312" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="gui.TraderListPanel" name="traderListPanel22">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
120
src/gui/TraderListDialog.java
Normal file
120
src/gui/TraderListDialog.java
Normal file
@ -0,0 +1,120 @@
|
||||
package gui;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class TraderListDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form TraderList
|
||||
*
|
||||
* @param parent
|
||||
* @param modal
|
||||
*/
|
||||
public TraderListDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(MainWin.instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
traderListPanel22 = new gui.TraderListPanel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Trader List");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(traderListPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, 922, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(traderListPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(TraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(TraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(TraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(TraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
TraderListDialog dialog = new TraderListDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.TraderListPanel traderListPanel22;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
51
src/gui/TraderListPanel.form
Normal file
51
src/gui/TraderListPanel.form
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="537" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="list">
|
||||
<Properties>
|
||||
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new MyModel(
 new Object [][] {
 {null, null, null, null, null},
 {null, null, null, null, null},
 {null, null, null, null, null},
 {null, null, null, null, null},
 {null, null, null, null, null}
 },
 new String [] {
 "ID", "Name", "Money", "Shares", "Wealth"
 }
 ) {
 Class[] types = new Class [] {
 java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
 };
 boolean[] canEdit = new boolean [] {
 false, false, false, false, false
 };

 public Class getColumnClass(int columnIndex) {
 return types [columnIndex];
 }

 public boolean isCellEditable(int rowIndex, int columnIndex) {
 return canEdit [columnIndex];
 }
 }" type="code"/>
|
||||
</Property>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="listMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
259
src/gui/TraderListPanel.java
Normal file
259
src/gui/TraderListPanel.java
Normal file
@ -0,0 +1,259 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import gui.tools.NummericCellRenderer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
|
||||
import sesim.AutoTraderInterface;
|
||||
import sesim.Exchange;
|
||||
import sesim.Exchange.Account;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class TraderListPanel extends javax.swing.JPanel {
|
||||
|
||||
DefaultTableModel model;
|
||||
|
||||
final void updateModel() {
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Globals.se.traders == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
sesim.Quote q = Globals.se.getLastQuoete();
|
||||
double price = q == null ? 0 : q.price;
|
||||
|
||||
|
||||
int size = Globals.se.traders.size();
|
||||
model.setRowCount(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
AutoTraderInterface at = Globals.se.traders.get(i);
|
||||
Account a = at.getAccount();
|
||||
model.setValueAt(i, i, 0);
|
||||
model.setValueAt(at.getName(), i, 1);
|
||||
model.setValueAt(a.getMoney(), i, 2);
|
||||
model.setValueAt(a.getShares(), i, 3);
|
||||
|
||||
double wealth = a.getShares() * price + a.getMoney();
|
||||
model.setValueAt(wealth, i, 4);
|
||||
}
|
||||
List l = list.getRowSorter().getSortKeys();
|
||||
if (l.size() > 0) {
|
||||
list.getRowSorter().allRowsChanged();
|
||||
} else {
|
||||
model.fireTableDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TimerTask updater;
|
||||
|
||||
/**
|
||||
* Creates new form TraderListPanel2
|
||||
*/
|
||||
public TraderListPanel() {
|
||||
|
||||
initComponents();
|
||||
model = (DefaultTableModel) list.getModel();
|
||||
// updateModel();
|
||||
|
||||
Timer timer = new Timer();
|
||||
updater = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
updateModel();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(3));
|
||||
list.getColumnModel().getColumn(3).setCellRenderer(new NummericCellRenderer(0));
|
||||
list.getColumnModel().getColumn(4).setCellRenderer(new NummericCellRenderer(3));
|
||||
timer.schedule(updater, 0, 1000);
|
||||
|
||||
}
|
||||
|
||||
class MyModel extends DefaultTableModel {
|
||||
|
||||
MyModel(Object arg0[][], Object arg1[]) {
|
||||
super(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireTableDataChanged() {
|
||||
super.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireTableStructureChanged() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireTableRowsUpdated(int firstRow, int lastRow) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireTableCellUpdated(int row, int column) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ZZtest() {
|
||||
|
||||
// new javax.swing.table.DefaultTableModel
|
||||
MyModel m = new MyModel(
|
||||
new Object[][]{
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null}
|
||||
},
|
||||
new String[]{
|
||||
"ID", "Name", "Money", "Shares", "Wealth"
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class[]{
|
||||
java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
|
||||
};
|
||||
boolean[] canEdit = new boolean[]{
|
||||
false, false, false, false, false
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types[columnIndex];
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit[columnIndex];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
list = new javax.swing.JTable();
|
||||
|
||||
list.setAutoCreateRowSorter(true);
|
||||
list.setModel(new MyModel(
|
||||
new Object [][] {
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null},
|
||||
{null, null, null, null, null}
|
||||
},
|
||||
new String [] {
|
||||
"ID", "Name", "Money", "Shares", "Wealth"
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
|
||||
};
|
||||
boolean[] canEdit = new boolean [] {
|
||||
false, false, false, false, false
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types [columnIndex];
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit [columnIndex];
|
||||
}
|
||||
});
|
||||
list.setDoubleBuffered(true);
|
||||
list.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
listMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(list);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void listMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listMouseClicked
|
||||
if (evt.getClickCount() == 2) {
|
||||
int index = list.rowAtPoint(evt.getPoint());
|
||||
|
||||
index = list.getRowSorter().convertRowIndexToModel(index);
|
||||
Integer tid = (Integer) model.getValueAt(index, 0);
|
||||
// System.out.printf("Trader ID %d\n", tid);
|
||||
|
||||
JDialog console = Globals.se.traders.get(tid).getGuiConsole();
|
||||
if (console == null) {
|
||||
return;
|
||||
}
|
||||
console.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_listMouseClicked
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JTable list;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
40
src/gui/WaitBox.form
Normal file
40
src/gui/WaitBox.form
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="progressBar" pref="388" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="progressBar" min="-2" pref="39" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JProgressBar" name="progressBar">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
74
src/gui/WaitBox.java
Normal file
74
src/gui/WaitBox.java
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class WaitBox extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form WaitBox
|
||||
*/
|
||||
public WaitBox() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
progressBar = new javax.swing.JProgressBar();
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JProgressBar progressBar;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
35
src/gui/ZZZ.form
Normal file
35
src/gui/ZZZ.form
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
111
src/gui/ZZZ.java
Normal file
111
src/gui/ZZZ.java
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2017, tobias
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tobias
|
||||
*/
|
||||
public class ZZZ extends EscDialog {
|
||||
|
||||
/**
|
||||
* Creates new form ZZZ
|
||||
*/
|
||||
public ZZZ(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(ZZZ.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(ZZZ.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(ZZZ.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(ZZZ.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
ZZZ dialog = new ZZZ(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
50
src/gui/orderbook/OrderBook.form
Normal file
50
src/gui/orderbook/OrderBook.form
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="389" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="284" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="list">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||
<Table columnCount="3" rowCount="0">
|
||||
<Column editable="false" title="Trader" type="java.lang.String"/>
|
||||
<Column editable="false" title="Price" type="java.lang.Double"/>
|
||||
<Column editable="false" title="Volume" type="java.lang.Double"/>
|
||||
</Table>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
220
src/gui/orderbook/OrderBook.java
Normal file
220
src/gui/orderbook/OrderBook.java
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* 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.orderbook;
|
||||
|
||||
import gui.Globals;
|
||||
import gui.Globals.CfgListener;
|
||||
import gui.tools.NummericCellRenderer;
|
||||
import java.awt.Component;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import sesim.Exchange;
|
||||
import sesim.Exchange.Order;
|
||||
import sesim.Exchange.OrderType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiver, CfgListener {
|
||||
|
||||
DefaultTableModel model;
|
||||
TableColumn trader_column = null;
|
||||
|
||||
class Renderer extends DefaultTableCellRenderer {
|
||||
|
||||
private final DecimalFormat formatter = new DecimalFormat("#.0000");
|
||||
|
||||
Renderer() {
|
||||
super();
|
||||
this.setHorizontalAlignment(RIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(
|
||||
JTable table, Object value, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
|
||||
// First format the cell value as required
|
||||
value = formatter.format((Number) value);
|
||||
|
||||
// And pass it on to parent class
|
||||
return super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column);
|
||||
}
|
||||
}
|
||||
|
||||
OrderType type = OrderType.BUYLIMIT;
|
||||
int depth = 40;
|
||||
|
||||
public void setGodMode(boolean on) {
|
||||
TableColumnModel tcm = list.getColumnModel();
|
||||
if (on) {
|
||||
if (list.getColumnCount() == 3) {
|
||||
return;
|
||||
}
|
||||
tcm.addColumn(trader_column);
|
||||
tcm.moveColumn(2, 0);
|
||||
|
||||
} else {
|
||||
if (list.getColumnCount() == 2) {
|
||||
return;
|
||||
}
|
||||
tcm.removeColumn(tcm.getColumn(0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bla
|
||||
*/
|
||||
@Override
|
||||
public final void cfgChanged() {
|
||||
boolean gm = Globals.prefs.get(Globals.CfgStrings.GODMODE, "false").equals("true");
|
||||
setGodMode(gm);
|
||||
list.invalidate();
|
||||
list.repaint();
|
||||
}
|
||||
|
||||
public void setType(OrderType type) {
|
||||
this.type = type;
|
||||
Globals.se.addBookReceiver(type, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form OrderBookNew
|
||||
*/
|
||||
public OrderBook() {
|
||||
initComponents();
|
||||
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
model = (DefaultTableModel) this.list.getModel();
|
||||
trader_column = list.getColumnModel().getColumn(0);
|
||||
list.getColumnModel().getColumn(1).setCellRenderer(new NummericCellRenderer(3));
|
||||
list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(0));
|
||||
cfgChanged();
|
||||
// Globals.se.addBookReceiver(Exchange.OrderType.BUYLIMIT, this);
|
||||
Globals.addCfgListener(this);
|
||||
}
|
||||
|
||||
boolean oupdate = false;
|
||||
boolean new_oupdate = false;
|
||||
|
||||
void oupdater() {
|
||||
ArrayList<Order> ob = Globals.se.getOrderBook(type, depth);
|
||||
model.setRowCount(ob.size());
|
||||
int row = 0;
|
||||
for (Order ob1 : ob) {
|
||||
model.setValueAt(ob1.getAccount().getOwner().getName(), row, 0);
|
||||
model.setValueAt(ob1.getLimit(), row, 1);
|
||||
model.setValueAt(ob1.getVolume(), row, 2);
|
||||
row++;
|
||||
}
|
||||
|
||||
oupdate = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void UpdateOrderBook() {
|
||||
|
||||
if (oupdate) {
|
||||
new_oupdate=true;
|
||||
return;
|
||||
}
|
||||
|
||||
oupdate = true;
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
oupdater();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
list = new javax.swing.JTable();
|
||||
|
||||
list.setModel(new javax.swing.table.DefaultTableModel(
|
||||
new Object [][] {
|
||||
|
||||
},
|
||||
new String [] {
|
||||
"Trader", "Price", "Volume"
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.String.class, java.lang.Double.class, java.lang.Double.class
|
||||
};
|
||||
boolean[] canEdit = new boolean [] {
|
||||
false, false, false
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types [columnIndex];
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit [columnIndex];
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(list);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JTable list;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
47
src/gui/orderbook/OrderBookDialog.form
Normal file
47
src/gui/orderbook/OrderBookDialog.form
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="books" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="books" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="gui.orderbook.OrderBooksHorizontal" name="books">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
121
src/gui/orderbook/OrderBookDialog.java
Normal file
121
src/gui/orderbook/OrderBookDialog.java
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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.orderbook;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class OrderBookDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form OrderBookDialog
|
||||
*/
|
||||
public OrderBookDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
books.setDepth(1000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
books = new gui.orderbook.OrderBooksHorizontal();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(books, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(books, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(OrderBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
OrderBookDialog dialog = new OrderBookDialog(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.orderbook.OrderBooksHorizontal books;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
112
src/gui/orderbook/OrderBooksHorizontal.form
Normal file
112
src/gui/orderbook/OrderBooksHorizontal.form
Normal file
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,40,0,0,3,-60"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="bidBookPanel">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[320, 296]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="bidBook" pref="244" max="32767" attributes="0"/>
|
||||
<Component id="jLabel2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="bidBook" pref="269" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="gui.orderbook.OrderBook" name="bidBook">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="DejaVu Sans" size="12" style="1"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="Bid"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="gui.orderbook.QuoteVertical" name="quoteVertical2">
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="askBookPanel">
|
||||
<Properties>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[320, 296]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="askBook" pref="244" max="32767" attributes="0"/>
|
||||
<Component id="jLabel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="askBook" pref="269" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="gui.orderbook.OrderBook" name="askBook">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="DejaVu Sans" size="12" style="1"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="Ask"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
141
src/gui/orderbook/OrderBooksHorizontal.java
Normal file
141
src/gui/orderbook/OrderBooksHorizontal.java
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2017, tobias
|
||||
* 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.orderbook;
|
||||
|
||||
import gui.Globals;
|
||||
import sesim.Exchange;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tobias
|
||||
*/
|
||||
public class OrderBooksHorizontal extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form OrderBooksHorizontal
|
||||
*/
|
||||
public OrderBooksHorizontal() {
|
||||
initComponents();
|
||||
if (Globals.se==null)
|
||||
return;
|
||||
|
||||
bidBook.setType(Exchange.OrderType.BUYLIMIT);
|
||||
askBook.setType(Exchange.OrderType.SELLLIMIT);
|
||||
}
|
||||
|
||||
public void setDepth(int depth){
|
||||
bidBook.depth=depth;
|
||||
askBook.depth=depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
bidBookPanel = new javax.swing.JPanel();
|
||||
bidBook = new gui.orderbook.OrderBook();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
quoteVertical2 = new gui.orderbook.QuoteVertical();
|
||||
askBookPanel = new javax.swing.JPanel();
|
||||
askBook = new gui.orderbook.OrderBook();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
bidBookPanel.setPreferredSize(new java.awt.Dimension(320, 296));
|
||||
|
||||
jLabel2.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
|
||||
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel2.setText("Bid");
|
||||
|
||||
javax.swing.GroupLayout bidBookPanelLayout = new javax.swing.GroupLayout(bidBookPanel);
|
||||
bidBookPanel.setLayout(bidBookPanelLayout);
|
||||
bidBookPanelLayout.setHorizontalGroup(
|
||||
bidBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(bidBookPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(bidBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(bidBook, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
bidBookPanelLayout.setVerticalGroup(
|
||||
bidBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bidBookPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(bidBook, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
add(bidBookPanel);
|
||||
add(quoteVertical2);
|
||||
|
||||
askBookPanel.setPreferredSize(new java.awt.Dimension(320, 296));
|
||||
|
||||
jLabel1.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel1.setText("Ask");
|
||||
|
||||
javax.swing.GroupLayout askBookPanelLayout = new javax.swing.GroupLayout(askBookPanel);
|
||||
askBookPanel.setLayout(askBookPanelLayout);
|
||||
askBookPanelLayout.setHorizontalGroup(
|
||||
askBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(askBookPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(askBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(askBook, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
askBookPanelLayout.setVerticalGroup(
|
||||
askBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, askBookPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(askBook, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
add(askBookPanel);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.orderbook.OrderBook askBook;
|
||||
private javax.swing.JPanel askBookPanel;
|
||||
private gui.orderbook.OrderBook bidBook;
|
||||
private javax.swing.JPanel bidBookPanel;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private gui.orderbook.QuoteVertical quoteVertical2;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
77
src/gui/orderbook/QuoteVertical.form
Normal file
77
src/gui/orderbook/QuoteVertical.form
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 32767]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" pref="118" max="32767" attributes="0"/>
|
||||
<Component id="quoteLabel" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="volumeLabel" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="quoteLabel" min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="volumeLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="<html><b>Price</b> (Vol)"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="quoteLabel">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="DejaVu Sans" size="12" style="1"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="--" noResource="true"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="volumeLabel">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="(--)"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
141
src/gui/orderbook/QuoteVertical.java
Normal file
141
src/gui/orderbook/QuoteVertical.java
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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.orderbook;
|
||||
|
||||
import gui.Globals;
|
||||
import java.text.DecimalFormat;
|
||||
import sesim.Exchange.QuoteReceiver;
|
||||
import sesim.Quote;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class QuoteVertical extends javax.swing.JPanel implements QuoteReceiver {
|
||||
|
||||
DecimalFormat dfm = new DecimalFormat("0.00#");
|
||||
DecimalFormat dfv = new DecimalFormat("0.#");
|
||||
|
||||
/**
|
||||
* Creates new form QuoteVertical
|
||||
*/
|
||||
public QuoteVertical() {
|
||||
initComponents();
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
Globals.se.addQuoteReceiver(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
quoteLabel = new javax.swing.JLabel();
|
||||
volumeLabel = new javax.swing.JLabel();
|
||||
|
||||
setMaximumSize(new java.awt.Dimension(130, 32767));
|
||||
setMinimumSize(new java.awt.Dimension(130, 0));
|
||||
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel1.setText("<html><b>Price</b> (Vol)");
|
||||
|
||||
quoteLabel.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
|
||||
quoteLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
quoteLabel.setText("--"); // NOI18N
|
||||
quoteLabel.setFocusable(false);
|
||||
quoteLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
|
||||
volumeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
volumeLabel.setText("(--)");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
|
||||
.addComponent(quoteLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(volumeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(quoteLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(volumeLabel)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel quoteLabel;
|
||||
private javax.swing.JLabel volumeLabel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
double last_price = -1;
|
||||
|
||||
@Override
|
||||
public void UpdateQuote(Quote q) {
|
||||
|
||||
|
||||
|
||||
// javax.swing.SwingUtilities.invokeLater(() -> {
|
||||
String text, vtext;
|
||||
text = dfm.format(q.price);
|
||||
vtext = dfv.format(q.volume);
|
||||
|
||||
if (last_price == -1) {
|
||||
text = "--";
|
||||
} else if (q.price >= last_price) {
|
||||
text = "<html>" + text + "<font color=\"green\">↑</color></html>";
|
||||
} else if (q.price < last_price) {
|
||||
text = "<html>" + text + "<font color=\"red\">↓</color></html>";
|
||||
}
|
||||
last_price = q.price;
|
||||
this.quoteLabel.setText(text);
|
||||
this.volumeLabel.setText("(" + vtext + ")");
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
44
src/gui/orderbook/QutoesHorizontal.form
Normal file
44
src/gui/orderbook/QutoesHorizontal.form
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" pref="140" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="110" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="175" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="Price: 200.123"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
77
src/gui/orderbook/QutoesHorizontal.java
Normal file
77
src/gui/orderbook/QutoesHorizontal.java
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2017, tobias
|
||||
* 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.orderbook;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tobias
|
||||
*/
|
||||
public class QutoesHorizontal extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form QutoesHorizontal
|
||||
*/
|
||||
public QutoesHorizontal() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel1.setText("Price: 200.123");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(110, 110, 110)
|
||||
.addComponent(jLabel1)
|
||||
.addContainerGap(175, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
152
src/gui/test.java
Normal file
152
src/gui/test.java
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2017, tobias
|
||||
* 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;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tobias
|
||||
*/
|
||||
public class test {
|
||||
|
||||
static class Problem {
|
||||
|
||||
class Elem implements Comparable {
|
||||
|
||||
public int id;
|
||||
|
||||
public Elem(int id) {
|
||||
this.id = id;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
Elem e = (Elem) o;
|
||||
return id - e.id;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
SortedSet<Elem> s = new TreeSet<>();
|
||||
s.add(new Elem(1));
|
||||
s.add(new Elem(7));
|
||||
s.add(new Elem(12));
|
||||
Elem e = new Elem(5);
|
||||
|
||||
SortedSet<Elem> ts = exclusiveTailSet(s, e);
|
||||
|
||||
Elem e2 = new Elem(0);
|
||||
|
||||
// SortedSet<Elem> ts2 = exclusiveTailSet(ts,e);
|
||||
SortedSet<Elem> ts2 = ts.tailSet(e2);
|
||||
|
||||
e.id = 99;
|
||||
|
||||
System.out.print(String.format("First: %s\n", ts.first().id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static class NoProblem {
|
||||
public void run(){
|
||||
SortedSet<Integer> s=new TreeSet<>();
|
||||
|
||||
s.add(10);
|
||||
s.add(20);
|
||||
s.add(30);
|
||||
s.add(40);
|
||||
s.add(50);
|
||||
s.add(60);
|
||||
|
||||
int e1 = 15;
|
||||
SortedSet l1 = s.tailSet(e1);
|
||||
|
||||
int e2 = -1;
|
||||
|
||||
SortedSet l2 = l1.tailSet(e2);
|
||||
|
||||
System.out.print("First:"+l2.first()+"\n");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static <Ta> SortedSet<Ta> exclusiveTailSet(SortedSet<Ta> ts, Ta elem) {
|
||||
Iterator<Ta> iter = ts.tailSet(elem).iterator();
|
||||
|
||||
return ts.tailSet(iter.next());
|
||||
}
|
||||
|
||||
|
||||
static abstract interface Rc {
|
||||
public abstract int inc(int x);
|
||||
// public abstract int dec(int x);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
// NoProblem p = new NoProblem();
|
||||
// p.run();
|
||||
|
||||
Rc a = new Rc(){
|
||||
@Override
|
||||
public int inc(int x) {
|
||||
return x+1;
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public int dec(int x) {
|
||||
return x+1;
|
||||
}
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
Rc l = (x) -> x+1;
|
||||
|
||||
|
||||
System.out.print("A:"
|
||||
+a.inc(17)
|
||||
+" "
|
||||
+l.inc(4)
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
74
src/gui/tools/NummericCellRenderer.java
Normal file
74
src/gui/tools/NummericCellRenderer.java
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.tools;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.text.DecimalFormat;
|
||||
import javax.swing.JTable;
|
||||
import static javax.swing.SwingConstants.RIGHT;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class NummericCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
private final DecimalFormat formatter;
|
||||
|
||||
public NummericCellRenderer(int decimals) {
|
||||
super();
|
||||
String s = "#0.";
|
||||
if (decimals == 0) {
|
||||
s = "#";
|
||||
} else {
|
||||
for (int i = 0; i < decimals; i++) {
|
||||
s = s + "0";
|
||||
}
|
||||
}
|
||||
formatter = new DecimalFormat(s);
|
||||
this.setHorizontalAlignment(RIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(
|
||||
JTable table, Object value, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
|
||||
|
||||
if (!(value instanceof Double)) {
|
||||
return super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column);
|
||||
}
|
||||
|
||||
// Format the cell value as required
|
||||
value = formatter.format((Number) value);
|
||||
|
||||
// And pass it on to parent class
|
||||
return super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user