Building the new OrderBookPanel

This commit is contained in:
7u83 2018-12-24 15:12:32 +01:00
parent e2c15eff1c
commit 0397dc44a9
12 changed files with 104 additions and 191 deletions

View File

@ -18,48 +18,22 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Component id="filler1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0"> <EmptySpace pref="597" max="32767" 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>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="238" max="-2" attributes="0"/>
<Component id="orderBookNew3" min="-2" pref="156" max="-2" attributes="0"/> <Component id="filler1" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <EmptySpace pref="245" max="32767" 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>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <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"> <Component class="javax.swing.Box$Filler" name="filler1">
<Properties> <Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
@ -71,4 +45,4 @@
</AuxValues> </AuxValues>
</Component> </Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -47,9 +47,6 @@ public class OderBookPanelNew extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
quotePanel1 = new opensesim.gui.QuotePanel();
orderBookNew3 = new opensesim.gui.orderbook.OrderBook();
orderBookNew4 = new opensesim.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)); 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); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@ -58,38 +55,20 @@ public class OderBookPanelNew extends javax.swing.JPanel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(597, Short.MAX_VALUE))
.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.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addGap(238, 238, 238)
.addComponent(orderBookNew3, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addContainerGap(245, Short.MAX_VALUE))
.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 }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.Box.Filler filler1; private javax.swing.Box.Filler filler1;
private opensesim.gui.orderbook.OrderBook orderBookNew3;
private opensesim.gui.orderbook.OrderBook orderBookNew4;
private opensesim.gui.QuotePanel quotePanel1;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -22,12 +22,4 @@
</AuxValues> </AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents> </Form>
<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>

View File

@ -48,15 +48,8 @@ public class OrderBookDialog extends javax.swing.JDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
orderBookNew1 = new opensesim.gui.orderbook.OrderBook();
quotePanel1 = new opensesim.gui.QuotePanel();
orderBookNew2 = new opensesim.gui.orderbook.OrderBook();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new java.awt.FlowLayout()); getContentPane().setLayout(new java.awt.FlowLayout());
getContentPane().add(orderBookNew1);
getContentPane().add(quotePanel1);
getContentPane().add(orderBookNew2);
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@ -104,8 +97,5 @@ public class OrderBookDialog extends javax.swing.JDialog {
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private opensesim.gui.orderbook.OrderBook orderBookNew1;
private opensesim.gui.orderbook.OrderBook orderBookNew2;
private opensesim.gui.QuotePanel quotePanel1;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -33,15 +33,6 @@
</Constraints> </Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Component class="opensesim.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> </Container>
</SubComponents> </SubComponents>
</Container> </Container>
@ -464,13 +455,6 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents> <SubComponents>
<Component class="opensesim.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>
<Component class="opensesim.chart.MasterChart" name="chart"> <Component class="opensesim.chart.MasterChart" name="chart">
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
@ -480,13 +464,6 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="opensesim.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"> <Container class="javax.swing.JSplitPane" name="jSplitPane5">
<Properties> <Properties>
<Property name="orientation" type="int" value="0"/> <Property name="orientation" type="int" value="0"/>
@ -498,15 +475,6 @@
</Constraints> </Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Component class="opensesim.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> </Container>
</SubComponents> </SubComponents>
</Container> </Container>

View File

@ -200,7 +200,6 @@ public class SeSimApplication extends javax.swing.JFrame {
jTextArea1 = new javax.swing.JTextArea(); jTextArea1 = new javax.swing.JTextArea();
jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane1 = new javax.swing.JSplitPane();
jSplitPane2 = new javax.swing.JSplitPane(); jSplitPane2 = new javax.swing.JSplitPane();
orderBookNew1 = new opensesim.gui.orderbook.OrderBook();
jPanel2 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel();
stopButton = new javax.swing.JButton(); stopButton = new javax.swing.JButton();
runButton = new javax.swing.JButton(); runButton = new javax.swing.JButton();
@ -210,11 +209,8 @@ public class SeSimApplication extends javax.swing.JFrame {
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jSplitPane3 = new javax.swing.JSplitPane(); jSplitPane3 = new javax.swing.JSplitPane();
jSplitPane4 = new javax.swing.JSplitPane(); jSplitPane4 = new javax.swing.JSplitPane();
orderBooksHorizontal1 = new opensesim.gui.orderbook.OrderBooksHorizontal();
chart = new opensesim.chart.MasterChart(); chart = new opensesim.chart.MasterChart();
quoteVertical1 = new opensesim.gui.orderbook.QuoteVertical();
jSplitPane5 = new javax.swing.JSplitPane(); jSplitPane5 = new javax.swing.JSplitPane();
statistics1 = new opensesim.gui.Statistics();
menuBar = new javax.swing.JMenuBar(); menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu(); fileMenu = new javax.swing.JMenu();
openMenuItem = new javax.swing.JMenuItem(); openMenuItem = new javax.swing.JMenuItem();
@ -253,9 +249,6 @@ public class SeSimApplication extends javax.swing.JFrame {
jScrollPane2.setViewportView(jTextArea1); jScrollPane2.setViewportView(jTextArea1);
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane2.setLeftComponent(orderBookNew1);
jSplitPane1.setTopComponent(jSplitPane2); jSplitPane1.setTopComponent(jSplitPane2);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@ -353,15 +346,11 @@ public class SeSimApplication extends javax.swing.JFrame {
jSplitPane4.setDividerLocation(300); jSplitPane4.setDividerLocation(300);
jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane4.setBottomComponent(orderBooksHorizontal1);
jSplitPane4.setLeftComponent(chart); jSplitPane4.setLeftComponent(chart);
jSplitPane3.setRightComponent(jSplitPane4); jSplitPane3.setRightComponent(jSplitPane4);
jSplitPane3.setLeftComponent(quoteVertical1);
jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane5.setTopComponent(statistics1);
jSplitPane3.setLeftComponent(jSplitPane5); jSplitPane3.setLeftComponent(jSplitPane5);
getContentPane().add(jSplitPane3, java.awt.BorderLayout.CENTER); getContentPane().add(jSplitPane3, java.awt.BorderLayout.CENTER);
@ -919,8 +908,10 @@ public class SeSimApplication extends javax.swing.JFrame {
}//GEN-LAST:event_stopButtonActionPerformed }//GEN-LAST:event_stopButtonActionPerformed
private void jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem1ActionPerformed private void jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem1ActionPerformed
JDialog jd = new opensesim.gui.orderbook.OrderBookDialog(this, false); // JDialog jd = new opensesim.gui.orderbook.OrderBookDialog(this, false);
jd.setVisible(rootPaneCheckingEnabled); // jd.setVisible(rootPaneCheckingEnabled);
opensesim.gui.orderbook.OrderBookDialog.runDialog(this, godworld);
}//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed }//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed
TraderListDialog tld = null; TraderListDialog tld = null;
@ -1106,10 +1097,7 @@ public class SeSimApplication extends javax.swing.JFrame {
private javax.swing.JTextArea jTextArea1; private javax.swing.JTextArea jTextArea1;
private javax.swing.JMenuBar menuBar; private javax.swing.JMenuBar menuBar;
private javax.swing.JMenuItem openMenuItem; private javax.swing.JMenuItem openMenuItem;
private opensesim.gui.orderbook.OrderBook orderBookNew1;
private opensesim.gui.orderbook.OrderBooksHorizontal orderBooksHorizontal1;
private javax.swing.JMenuItem pasteMenuItem; private javax.swing.JMenuItem pasteMenuItem;
private opensesim.gui.orderbook.QuoteVertical quoteVertical1;
private javax.swing.JMenuItem resetToDefaultsMenuItem; private javax.swing.JMenuItem resetToDefaultsMenuItem;
private javax.swing.JButton runButton; private javax.swing.JButton runButton;
private javax.swing.JMenuItem saveAsMenuItem; private javax.swing.JMenuItem saveAsMenuItem;
@ -1118,7 +1106,6 @@ public class SeSimApplication extends javax.swing.JFrame {
private javax.swing.JMenuItem simMenuPause; private javax.swing.JMenuItem simMenuPause;
private javax.swing.JMenuItem simMenuStart; private javax.swing.JMenuItem simMenuStart;
private javax.swing.JMenuItem simMenuStop; private javax.swing.JMenuItem simMenuStop;
private opensesim.gui.Statistics statistics1;
private javax.swing.JButton stopButton; private javax.swing.JButton stopButton;
private javax.swing.JMenu viewMenu; private javax.swing.JMenu viewMenu;
private javax.swing.JCheckBoxMenuItem viewTraderListCheckBox; private javax.swing.JCheckBoxMenuItem viewTraderListCheckBox;

View File

@ -25,8 +25,8 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="books" min="-2" max="-2" attributes="0"/> <Component id="orderBookPanel1" pref="418" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -34,14 +34,17 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="books" min="-2" max="-2" attributes="0"/> <Component id="orderBookPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="gui.orderbook.OrderBooksHorizontal" name="books"> <Component class="opensesim.gui.orderbook.OrderBookPanel" name="orderBookPanel1">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new opensesim.gui.orderbook.OrderBookPanel(godworld)"/>
</AuxValues>
</Component> </Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -25,6 +25,10 @@
*/ */
package opensesim.gui.orderbook; package opensesim.gui.orderbook;
import java.awt.Frame;
import java.awt.Window;
import opensesim.world.GodWorld;
/** /**
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
@ -37,7 +41,19 @@ public class OrderBookDialog extends javax.swing.JDialog {
public OrderBookDialog(java.awt.Frame parent, boolean modal) { public OrderBookDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal); super(parent, modal);
initComponents(); initComponents();
books.setDepth(1000000); // books.setDepth(1000000);
}
GodWorld godworld;
static public void runDialog(Frame parent, GodWorld godworld){
OrderBookDialog d = new OrderBookDialog(parent,false);
d.godworld=godworld;
d.setVisible(true);
// d.dispose();
} }
/** /**
@ -49,7 +65,7 @@ public class OrderBookDialog extends javax.swing.JDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
books = new opensesim.gui.orderbook.OrderBooksHorizontal(); orderBookPanel1 = new opensesim.gui.orderbook.OrderBookPanel(godworld);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -59,14 +75,14 @@ public class OrderBookDialog extends javax.swing.JDialog {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(books, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(orderBookPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(books, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(orderBookPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
@ -116,6 +132,6 @@ public class OrderBookDialog extends javax.swing.JDialog {
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private opensesim.gui.orderbook.OrderBooksHorizontal books; private opensesim.gui.orderbook.OrderBookPanel orderBookPanel1;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -26,32 +26,53 @@
package opensesim.gui.orderbook; package opensesim.gui.orderbook;
import opensesim.gui.Globals; import opensesim.gui.Globals;
import opensesim.gui.Globals.CfgListener;
import opensesim.gui.util.NummericCellRenderer; import opensesim.gui.util.NummericCellRenderer;
import java.awt.Component; import java.awt.Component;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel; import javax.swing.table.TableColumnModel;
import opensesim.old_sesim.Exchange; import opensesim.world.GodWorld;
import opensesim.old_sesim.Order; import opensesim.world.Order;
import opensesim.old_sesim.Order.OrderType;
import opensesim.world.TradingAPI;
import opensesim.world.scheduler.Event;
import opensesim.world.scheduler.EventListener;
/** /**
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
*/ */
public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiver, CfgListener { public class OrderBookPanel extends javax.swing.JPanel implements EventListener {
DefaultTableModel model; DefaultTableModel model;
TableColumn trader_column = null; TableColumn trader_column = null;
TradingAPI api=null;
@Override
public long receive(Event task) {
synchronized (this) {
if (oupdate) {
new_oupdate = true;
return 0;
}
oupdate = true;
}
SwingUtilities.invokeLater(() -> {
oupdater();
});
return 0;
}
class Renderer extends DefaultTableCellRenderer { class Renderer extends DefaultTableCellRenderer {
@ -76,7 +97,7 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
} }
} }
OrderType type = OrderType.BUYLIMIT; // OrderType type = OrderType.BUYLIMIT;
int depth = 40; int depth = 40;
public void setGodMode(boolean on) { public void setGodMode(boolean on) {
@ -99,35 +120,42 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
/** /**
* Bla * Bla
*/ */
@Override /* @Override
public final void cfgChanged() { public final void cfgChanged() {
boolean gm = Globals.prefs.get(Globals.CfgStrings.GODMODE, "false").equals("true"); boolean gm = Globals.prefs.get(Globals.CfgStrings.GODMODE, "false").equals("true");
setGodMode(gm); setGodMode(gm);
list.invalidate(); list.invalidate();
list.repaint(); list.repaint();
} }
*/
/*
public void setType(OrderType type) { public void setType(OrderType type) {
this.type = type; this.type = type;
Globals.se.addBookReceiver(type, this); Globals.se.addBookReceiver(type, this);
} }
*/
GodWorld godworld;
/** /**
* Creates new form OrderBookNew * Creates new form OrderBookNew
*/ */
public OrderBook() { public OrderBookPanel(GodWorld godworld) {
initComponents(); initComponents();
if (Globals.se == null) { if (Globals.world == null) {
return; return;
} }
this.godworld = godworld;
model = (DefaultTableModel) this.list.getModel(); model = (DefaultTableModel) this.list.getModel();
trader_column = list.getColumnModel().getColumn(0); trader_column = list.getColumnModel().getColumn(0);
list.getColumnModel().getColumn(1).setCellRenderer(new NummericCellRenderer(3)); list.getColumnModel().getColumn(1).setCellRenderer(new NummericCellRenderer(3));
list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(0)); list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(0));
cfgChanged(); // cfgChanged();
// Globals.se.addBookReceiver(Exchange.OrderType.BUYLIMIT, this); // Globals.se.addBookReceiver(Exchange.OrderType.BUYLIMIT, this);
Globals.addCfgListener(this); // Globals.addCfgListener(this);
new Timer().schedule(new TimerTask() { new Timer().schedule(new TimerTask() {
@Override @Override
@ -145,7 +173,10 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
long ouctr = 0; long ouctr = 0;
void oupdater() { void oupdater() {
ArrayList<Order> ob = Globals.se.getOrderBook(type, depth); // ArrayList<Order> ob = Globals.se.getOrderBook(type, depth);
Collection <Order> ob = api.getOrderBook(Order.Type.BUY);
model.setRowCount(ob.size()); model.setRowCount(ob.size());
int row = 0; int row = 0;
for (Order ob1 : ob) { for (Order ob1 : ob) {
@ -168,7 +199,7 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
} }
@Override // @Override
public void UpdateOrderBook() { public void UpdateOrderBook() {
synchronized (this) { synchronized (this) {

View File

@ -11,7 +11,7 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> <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"/> <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,116,0,0,3,-60"/>
</AuxValues> </AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
@ -28,10 +28,7 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Component id="jLabel2" pref="458" max="32767" attributes="0"/>
<Component id="bidBook" pref="244" max="32767" attributes="0"/>
<Component id="jLabel2" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -41,15 +38,12 @@
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace pref="345" max="32767" attributes="0"/>
<Component id="bidBook" pref="269" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="opensesim.gui.orderbook.OrderBook" name="bidBook">
</Component>
<Component class="javax.swing.JLabel" name="jLabel2"> <Component class="javax.swing.JLabel" name="jLabel2">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
@ -61,8 +55,6 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="opensesim.gui.orderbook.QuoteVertical" name="quoteVertical2">
</Component>
<Container class="javax.swing.JPanel" name="askBookPanel"> <Container class="javax.swing.JPanel" name="askBookPanel">
<Properties> <Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
@ -75,10 +67,7 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Component id="jLabel1" pref="458" max="32767" attributes="0"/>
<Component id="askBook" pref="244" max="32767" attributes="0"/>
<Component id="jLabel1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -88,15 +77,12 @@
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace pref="345" max="32767" attributes="0"/>
<Component id="askBook" pref="269" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="opensesim.gui.orderbook.OrderBook" name="askBook">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1"> <Component class="javax.swing.JLabel" name="jLabel1">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">

View File

@ -43,13 +43,13 @@ public class OrderBooksHorizontal extends javax.swing.JPanel {
if (Globals.se==null) if (Globals.se==null)
return; return;
bidBook.setType(OrderType.BUYLIMIT); // bidBook.setType(OrderType.BUYLIMIT);
askBook.setType(OrderType.SELLLIMIT); // askBook.setType(OrderType.SELLLIMIT);
} }
public void setDepth(int depth){ public void setDepth(int depth){
bidBook.depth=depth; // bidBook.depth=depth;
askBook.depth=depth; // askBook.depth=depth;
} }
/** /**
@ -62,11 +62,8 @@ public class OrderBooksHorizontal extends javax.swing.JPanel {
private void initComponents() { private void initComponents() {
bidBookPanel = new javax.swing.JPanel(); bidBookPanel = new javax.swing.JPanel();
bidBook = new opensesim.gui.orderbook.OrderBook();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
quoteVertical2 = new opensesim.gui.orderbook.QuoteVertical();
askBookPanel = new javax.swing.JPanel(); askBookPanel = new javax.swing.JPanel();
askBook = new opensesim.gui.orderbook.OrderBook();
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS)); setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS));
@ -83,9 +80,7 @@ public class OrderBooksHorizontal extends javax.swing.JPanel {
bidBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) bidBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(bidBookPanelLayout.createSequentialGroup() .addGroup(bidBookPanelLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(bidBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE)
.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()) .addContainerGap())
); );
bidBookPanelLayout.setVerticalGroup( bidBookPanelLayout.setVerticalGroup(
@ -93,12 +88,10 @@ public class OrderBooksHorizontal extends javax.swing.JPanel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bidBookPanelLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bidBookPanelLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addContainerGap(345, Short.MAX_VALUE))
.addComponent(bidBook, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE))
); );
add(bidBookPanel); add(bidBookPanel);
add(quoteVertical2);
askBookPanel.setPreferredSize(new java.awt.Dimension(320, 296)); askBookPanel.setPreferredSize(new java.awt.Dimension(320, 296));
@ -112,9 +105,7 @@ public class OrderBooksHorizontal extends javax.swing.JPanel {
askBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) askBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(askBookPanelLayout.createSequentialGroup() .addGroup(askBookPanelLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(askBookPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE)
.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()) .addContainerGap())
); );
askBookPanelLayout.setVerticalGroup( askBookPanelLayout.setVerticalGroup(
@ -122,8 +113,7 @@ public class OrderBooksHorizontal extends javax.swing.JPanel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, askBookPanelLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, askBookPanelLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addContainerGap(345, Short.MAX_VALUE))
.addComponent(askBook, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE))
); );
add(askBookPanel); add(askBookPanel);
@ -131,12 +121,9 @@ public class OrderBooksHorizontal extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private opensesim.gui.orderbook.OrderBook askBook;
private javax.swing.JPanel askBookPanel; private javax.swing.JPanel askBookPanel;
private opensesim.gui.orderbook.OrderBook bidBook;
private javax.swing.JPanel bidBookPanel; private javax.swing.JPanel bidBookPanel;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private opensesim.gui.orderbook.QuoteVertical quoteVertical2;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }