diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 06265af..61a5657 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -8,9 +8,11 @@ file:/home/tube/NetBeansProjects/SeSim/src/gui/StatisticsPanel.java file:/home/tube/NetBeansProjects/SeSim/src/gui/tools/NummericCellRenderer.java file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderInterface.java + file:/home/tube/NetBeansProjects/SeSim/src/chart/ChartTestDialog.java file:/home/tube/NetBeansProjects/SeSim/src/traders/ManTrader/ManTraderConsoleDialog.java file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderLoader.java file:/home/tube/NetBeansProjects/SeSim/src/traders/ManTrader/ManTrader.java + file:/home/tube/NetBeansProjects/SeSim/src/chart/NewPanel.java file:/home/tube/NetBeansProjects/SeSim/src/gui/SeSimApplication.java file:/home/tube/NetBeansProjects/SeSim/src/gui/Globals.java file:/home/tube/NetBeansProjects/SeSim/src/traders/RandomTraderB.java @@ -22,10 +24,16 @@ file:/home/tube/NetBeansProjects/SeSim/src/gui/EditStrategies.java file:/home/tube/NetBeansProjects/SeSim/src/gui/MainChart.java file:/home/tube/NetBeansProjects/SeSim/src/chart/Chart.java + file:/home/tube/NetBeansProjects/SeSim/src/sesim/Clock.java file:/home/tube/NetBeansProjects/SeSim/src/sesim/OHLCData.java + file:/home/tube/NetBeansProjects/SeSim/src/sesim/IDGenerator.java + file:/home/tube/NetBeansProjects/SeSim/src/sesim/MinMax.java file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderGui.java + file:/home/tube/NetBeansProjects/SeSim/src/sesim/Exchange.java file:/home/tube/NetBeansProjects/SeSim/src/gui/jp99.java + file:/home/tube/NetBeansProjects/SeSim/src/sesim/Locker.java file:/home/tube/NetBeansProjects/SeSim/src/gui/orderbook/OrderBook.java + file:/home/tube/NetBeansProjects/SeSim/src/chart/ChartPanal.java file:/home/tube/NetBeansProjects/SeSim/src/sesim/OHLCDataItem.java file:/home/tube/NetBeansProjects/SeSim/src/gui/AboutDialog.java file:/home/tube/NetBeansProjects/SeSim/src/chart/Chart1.java diff --git a/nbproject/project.properties b/nbproject/project.properties index 968e4bd..aabde50 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Sun, 10 Sep 2017 00:32:21 +0200 +#Sat, 16 Sep 2017 13:50:38 +0200 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/chart/Chart1.java b/src/chart/Chart1.java index 5e0fcf4..000f8b4 100644 --- a/src/chart/Chart1.java +++ b/src/chart/Chart1.java @@ -1,49 +1,78 @@ - package chart; import gui.Globals; +import java.awt.Color; import java.awt.Cursor; +import java.awt.Dimension; import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import javax.swing.Scrollable; import sesim.Exchange.QuoteReceiver; +import sesim.OHLCData; +import sesim.OHLCDataItem; import sesim.Quote; /** * * @author 7u83 <7u83@mail.ru> */ -public class Chart1 extends javax.swing.JPanel implements QuoteReceiver{ +public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Scrollable { /** * Creates new form Chart1 */ public Chart1() { initComponents(); - System.out.printf("Now cursor\n"); + System.out.printf("Now cursor\n"); + setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); - - if (Globals.se == null) + + if (Globals.se == null) { return; - + } + Globals.se.addQuoteReceiver(this); } - private int em_width; + private void drawChart(Graphics2D g) { + + OHLCData data = Globals.se.getOHLCdata(5000); + + int first_bar = 0; + int last_bar = data.size(); + + OHLCDataItem prev = null; + + for (int i = first_bar; i < last_bar; i++) { + OHLCDataItem di = data.get(i); + + int x_unit_width = 1; + int x = (int) (i * em_width * x_unit_width); + + g.setColor(Color.red); + g.drawLine(x, 0, x, 10); + +//em_width; + //this.drawItem(ctx, (int) (x - em_width * x_unit_width), x, prev, di); //, ctx.scaling, data.getMin()); + // myi++; + prev = di; + + } + } + @Override protected void paintComponent(Graphics g) { - super.paintComponent(g); - - + super.paintComponent(g); + // Calculate the number of pixels for 1 em em_width = g.getFontMetrics().stringWidth("M"); - - - g.drawLine(0, 0, 10, 10); + drawChart((Graphics2D)g); } - /** * 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 @@ -67,7 +96,32 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver{ @Override public void UpdateQuote(Quote q) { - System.out.printf("%s\n",q.price); + repaint(); + } + + @Override + public Dimension getPreferredScrollableViewportSize() { + return this.getPreferredSize(); + } + + @Override + public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { + return 1; + } + + @Override + public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { + return 1; + } + + @Override + public boolean getScrollableTracksViewportWidth() { + return true; + } + + @Override + public boolean getScrollableTracksViewportHeight() { + return true; } diff --git a/src/chart/ChartPanal.form b/src/chart/ChartPanal.form new file mode 100644 index 0000000..61671e9 --- /dev/null +++ b/src/chart/ChartPanal.form @@ -0,0 +1,79 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/chart/ChartPanal.java b/src/chart/ChartPanal.java new file mode 100644 index 0000000..e3df500 --- /dev/null +++ b/src/chart/ChartPanal.java @@ -0,0 +1,100 @@ +/* + * 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 chart; + +/** + * + * @author 7u83 <7u83@mail.ru> + */ +public class ChartPanal extends javax.swing.JPanel { + + /** + * Creates new form ChartPanal + */ + public ChartPanal() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jSplitPane1 = new javax.swing.JSplitPane(); + chart11 = new chart.Chart1(); + + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + jScrollPane1.setName(""); // NOI18N + + jSplitPane1.setDividerLocation(200); + jSplitPane1.setDividerSize(5); + jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + + javax.swing.GroupLayout chart11Layout = new javax.swing.GroupLayout(chart11); + chart11.setLayout(chart11Layout); + chart11Layout.setHorizontalGroup( + chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 862, Short.MAX_VALUE) + ); + chart11Layout.setVerticalGroup( + chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 199, Short.MAX_VALUE) + ); + + jSplitPane1.setTopComponent(chart11); + + jScrollPane1.setViewportView(jSplitPane1); + + 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(jScrollPane1) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private chart.Chart1 chart11; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSplitPane jSplitPane1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/chart/ChartTestDialog.form b/src/chart/ChartTestDialog.form new file mode 100644 index 0000000..8e65ce3 --- /dev/null +++ b/src/chart/ChartTestDialog.form @@ -0,0 +1,47 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/chart/ChartTestDialog.java b/src/chart/ChartTestDialog.java new file mode 100644 index 0000000..3cb1166 --- /dev/null +++ b/src/chart/ChartTestDialog.java @@ -0,0 +1,120 @@ +/* + * 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 chart; + +/** + * + * @author 7u83 <7u83@mail.ru> + */ +public class ChartTestDialog extends javax.swing.JDialog { + + /** + * Creates new form ChartTestDialog + */ + public ChartTestDialog(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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + chartPanal2 = new chart.ChartPanal(); + + 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(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(chartPanal2, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(chartPanal2, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(ChartTestDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(ChartTestDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(ChartTestDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(ChartTestDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + ChartTestDialog dialog = new ChartTestDialog(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 chart.ChartPanal chartPanal2; + // End of variables declaration//GEN-END:variables +} diff --git a/src/chart/NewPanel.form b/src/chart/NewPanel.form new file mode 100644 index 0000000..9c7729a --- /dev/null +++ b/src/chart/NewPanel.form @@ -0,0 +1,17 @@ + + +
+ + + + + + + + + + + + + + diff --git a/src/chart/NewPanel.java b/src/chart/NewPanel.java new file mode 100644 index 0000000..12f39e3 --- /dev/null +++ b/src/chart/NewPanel.java @@ -0,0 +1,55 @@ +/* + * 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 chart; + +/** + * + * @author 7u83 <7u83@mail.ru> + */ +public class NewPanel extends java.awt.Panel { + + /** + * Creates new form NewPanel + */ + public NewPanel() { + 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. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + setLayout(new java.awt.BorderLayout()); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +} diff --git a/src/gui/SeSimApplication.form b/src/gui/SeSimApplication.form index ce65759..f1a1ad1 100644 --- a/src/gui/SeSimApplication.form +++ b/src/gui/SeSimApplication.form @@ -247,6 +247,14 @@ + + + + + + + + @@ -441,12 +449,12 @@ - + - + diff --git a/src/gui/SeSimApplication.java b/src/gui/SeSimApplication.java index b6a2f91..8bd6138 100644 --- a/src/gui/SeSimApplication.java +++ b/src/gui/SeSimApplication.java @@ -25,6 +25,7 @@ */ package gui; +import chart.ChartTestDialog; import java.awt.Dialog; import java.awt.Frame; import java.awt.GraphicsDevice; @@ -220,6 +221,7 @@ public class SeSimApplication extends javax.swing.JFrame { jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem(); helpMenu = new javax.swing.JMenu(); aboutMenuItem = new javax.swing.JMenuItem(); + jMenuItem1 = new javax.swing.JMenuItem(); jTextArea1.setColumns(20); jTextArea1.setRows(5); @@ -329,11 +331,11 @@ public class SeSimApplication extends javax.swing.JFrame { chart.setLayout(chartLayout); chartLayout.setHorizontalGroup( chartLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 100, Short.MAX_VALUE) + .addGap(0, 0, Short.MAX_VALUE) ); chartLayout.setVerticalGroup( chartLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 100, Short.MAX_VALUE) + .addGap(0, 0, Short.MAX_VALUE) ); chartSrollPane.setViewportView(chart); @@ -544,6 +546,14 @@ public class SeSimApplication extends javax.swing.JFrame { }); helpMenu.add(aboutMenuItem); + jMenuItem1.setText("jMenuItem1"); + jMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem1ActionPerformed(evt); + } + }); + helpMenu.add(jMenuItem1); + menuBar.add(helpMenu); setJMenuBar(menuBar); @@ -877,6 +887,12 @@ public class SeSimApplication extends javax.swing.JFrame { Globals.clearAll(); }//GEN-LAST:event_clearMenuItemActionPerformed + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed + ChartTestDialog d = new ChartTestDialog(this,false); + d.setVisible(true); + + }//GEN-LAST:event_jMenuItem1ActionPerformed + /** * @param args the command line arguments * @throws java.lang.IllegalAccessException @@ -943,6 +959,7 @@ public class SeSimApplication extends javax.swing.JFrame { private javax.swing.JButton jButton2; private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1; private javax.swing.JLabel jLabel1; + private javax.swing.JMenuItem jMenuItem1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JPopupMenu.Separator jSeparator1;