/* * 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 chart; import java.awt.*; import sesim.Exchange.*; import sesim.Quote; import gui.MainWin; /** * * @author 7u83 <7u83@mail.ru> */ public class Chart extends javax.swing.JPanel implements QuoteReceiver{ /** * Creates new form Chart */ public Chart() { initComponents(); MainWin.se.addQuoteReceiver(this); //Graphics g = this.getGraphics(); //g.drawString("Hello world", 0, 0); } int item_width=10; int items=350; OHLCData data; OHLCDataItem current=null; private void realTimeAdd(long time,float price,float volume){ if (current==null){ current=new OHLCDataItem(price,price,price,price,volume); return; } boolean rc = current.update(price,volume); if (rc){ System.out.print("Updated -" +" High:" +current.high +" Low:" +current.low +" Volume" +current.volume +"\n" ); } } private void getData(){ } private void draw(Graphics2D g){ this.getSize(); int pwidth = item_width*items; this.setPreferredSize(new Dimension(pwidth,400)); for (int i=0; i//GEN-BEGIN:initComponents private void initComponents() { setBackground(java.awt.Color.white); setBorder(javax.swing.BorderFactory.createTitledBorder("")); setPreferredSize(new java.awt.Dimension(300, 300)); setRequestFocusEnabled(false); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 316, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 280, Short.MAX_VALUE) ); }// //GEN-END:initComponents @Override public void UpdateQuote(Quote q) { // System.out.print("Quote Received\n"); this.realTimeAdd(q.time, (float)q.price , q.volume); } // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables }