From 92930d9417e86b5a1efd1eeb4f60d59b77c6ba8e Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiol.ru> Date: Sun, 17 Sep 2017 23:55:18 +0200 Subject: [PATCH] work on charts --- nbproject/project.properties | 2 +- src/chart/Chart1.form | 4 +- src/chart/Chart1.java | 23 +++++++++-- src/chart/ChartPanal.form | 71 ++++++++++++++++------------------ src/chart/ChartPanal.java | 38 +++++++++--------- src/chart/ChartTestDialog.form | 39 +++++++++++++++---- src/chart/ChartTestDialog.java | 35 +++++++++++++---- src/gui/SeSimApplication.form | 17 +------- src/gui/SeSimApplication.java | 18 ++------- 9 files changed, 137 insertions(+), 110 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index 7720936..17e551e 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Sat, 16 Sep 2017 18:25:29 +0200 +#Sun, 17 Sep 2017 23:52:04 +0200 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/chart/Chart1.form b/src/chart/Chart1.form index c638b68..9312e7a 100644 --- a/src/chart/Chart1.form +++ b/src/chart/Chart1.form @@ -16,12 +16,12 @@ - + - + diff --git a/src/chart/Chart1.java b/src/chart/Chart1.java index 586d212..fbeb1c7 100644 --- a/src/chart/Chart1.java +++ b/src/chart/Chart1.java @@ -32,6 +32,7 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Scrolla return; } + setSize(new Dimension(9000,500)); Globals.se.addQuoteReceiver(this); } @@ -42,7 +43,21 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Scrolla if (Globals.se==null) return; - OHLCData data = Globals.se.getOHLCdata(5000); + g.setColor(Color.red); + g.drawLine(0, 0, 7000, 610); + + Dimension d = new Dimension(8000,200); + setPreferredSize(d); + + revalidate(); + + + System.out.printf("Setting pref size\n" ); + + + + + OHLCData data = Globals.se.getOHLCdata(60000); int first_bar = 0; int last_bar = data.size(); @@ -73,6 +88,8 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Scrolla // Calculate the number of pixels for 1 em em_width = g.getFontMetrics().stringWidth("M"); + + drawChart((Graphics2D)g); } @@ -89,11 +106,11 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Scrolla this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 400, Short.MAX_VALUE) + .addGap(0, 498, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 300, Short.MAX_VALUE) + .addGap(0, 341, Short.MAX_VALUE) ); }// //GEN-END:initComponents diff --git a/src/chart/ChartPanal.form b/src/chart/ChartPanal.form index 61671e9..e4d688a 100644 --- a/src/chart/ChartPanal.form +++ b/src/chart/ChartPanal.form @@ -1,6 +1,11 @@
+ + + + + @@ -16,19 +21,25 @@ - - - - + + + + + + + - - - - + + + + + + + @@ -37,41 +48,25 @@ - + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/chart/ChartPanal.java b/src/chart/ChartPanal.java index e3df500..ff3589e 100644 --- a/src/chart/ChartPanal.java +++ b/src/chart/ChartPanal.java @@ -48,46 +48,45 @@ public class ChartPanal extends javax.swing.JPanel { 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 + setPreferredSize(new java.awt.Dimension(300, 300)); - jSplitPane1.setDividerLocation(200); - jSplitPane1.setDividerSize(5); - jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); 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) + .addGap(0, 217, Short.MAX_VALUE) ); chart11Layout.setVerticalGroup( chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 199, Short.MAX_VALUE) + .addGap(0, 241, Short.MAX_VALUE) ); - jSplitPane1.setTopComponent(chart11); - - jScrollPane1.setViewportView(jSplitPane1); + jScrollPane1.setViewportView(chart11); 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()) + .addGap(0, 300, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(71, Short.MAX_VALUE))) ); 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()) + .addGap(0, 300, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(47, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap())) ); }// //GEN-END:initComponents @@ -95,6 +94,5 @@ public class ChartPanal extends javax.swing.JPanel { // 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 index 8e65ce3..c12cc76 100644 --- a/src/chart/ChartTestDialog.form +++ b/src/chart/ChartTestDialog.form @@ -24,24 +24,47 @@ - - + + - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/chart/ChartTestDialog.java b/src/chart/ChartTestDialog.java index 3cb1166..7fcf6db 100644 --- a/src/chart/ChartTestDialog.java +++ b/src/chart/ChartTestDialog.java @@ -37,6 +37,7 @@ public class ChartTestDialog extends javax.swing.JDialog { public ChartTestDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); + setLocationRelativeTo(parent); } /** @@ -48,25 +49,42 @@ public class ChartTestDialog extends javax.swing.JDialog { // //GEN-BEGIN:initComponents private void initComponents() { - chartPanal2 = new chart.ChartPanal(); + jScrollPane1 = new javax.swing.JScrollPane(); + chart11 = new chart.Chart1(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + + javax.swing.GroupLayout chart11Layout = new javax.swing.GroupLayout(chart11); + chart11.setLayout(chart11Layout); + chart11Layout.setHorizontalGroup( + chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 102, Short.MAX_VALUE) + ); + chart11Layout.setVerticalGroup( + chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 233, Short.MAX_VALUE) + ); + + jScrollPane1.setViewportView(chart11); + 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(387, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE) .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()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(59, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(120, Short.MAX_VALUE)) ); pack(); @@ -115,6 +133,7 @@ public class ChartTestDialog extends javax.swing.JDialog { } // Variables declaration - do not modify//GEN-BEGIN:variables - private chart.ChartPanal chartPanal2; + private chart.Chart1 chart11; + private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables } diff --git a/src/gui/SeSimApplication.form b/src/gui/SeSimApplication.form index d22df6c..23cf940 100644 --- a/src/gui/SeSimApplication.form +++ b/src/gui/SeSimApplication.form @@ -488,26 +488,13 @@ - + - - - - - - - - - - - - - - + diff --git a/src/gui/SeSimApplication.java b/src/gui/SeSimApplication.java index 9d1422c..b2f4254 100644 --- a/src/gui/SeSimApplication.java +++ b/src/gui/SeSimApplication.java @@ -187,7 +187,7 @@ public class SeSimApplication extends javax.swing.JFrame { quoteVertical1 = new gui.orderbook.QuoteVertical(); jSplitPane5 = new javax.swing.JSplitPane(); statistics1 = new gui.Statistics(); - chart11 = new chart.Chart1(); + chartPanal1 = new chart.ChartPanal(); menuBar = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); openMenuItem = new javax.swing.JMenuItem(); @@ -340,19 +340,7 @@ public class SeSimApplication extends javax.swing.JFrame { jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane5.setTopComponent(statistics1); - - javax.swing.GroupLayout chart11Layout = new javax.swing.GroupLayout(chart11); - chart11.setLayout(chart11Layout); - chart11Layout.setHorizontalGroup( - chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 104, Short.MAX_VALUE) - ); - chart11Layout.setVerticalGroup( - chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 235, Short.MAX_VALUE) - ); - - jSplitPane5.setRightComponent(chart11); + jSplitPane5.setRightComponent(chartPanal1); jSplitPane3.setLeftComponent(jSplitPane5); @@ -936,7 +924,7 @@ public class SeSimApplication extends javax.swing.JFrame { private javax.swing.JMenuItem aboutMenuItem; private javax.swing.JSpinner accelSpinner; private gui.MainChart chart; - private chart.Chart1 chart11; + private chart.ChartPanal chartPanal1; private javax.swing.JScrollPane chartSrollPane; private javax.swing.JMenuItem clearMenuItem; private gui.Clock clock;