Converted to maven

This commit is contained in:
7u83
2017-01-05 19:20:44 +01:00
parent 2efa1d3d63
commit bd7638c05a
36 changed files with 4275 additions and 0 deletions

View File

@ -0,0 +1,56 @@
/*
* 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.Order.*;
import java.util.ArrayList;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AskBook extends OrderBook {
@Override
ArrayList getOrderBook() {
return MainWin.se.getOrderBook(OrderType.ask,40);
}
@Override
boolean getDesc(){
return true;
}
public AskBook(){
if (MainWin.se == null) {
return;
}
MainWin.se.addBookReceiver(OrderType.ask, this);
}
}

View 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 sesim.Order.*;
import java.util.ArrayList;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class BidBook extends OrderBook {
@Override
ArrayList getOrderBook() {
return MainWin.se.getOrderBook(OrderType.bid, 40);
}
public BidBook() {
if (MainWin.se == null) {
return;
}
MainWin.se.addBookReceiver(OrderType.bid, this);
}
}

View File

@ -0,0 +1,99 @@
package gui;
import org.jfree.chart.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.CandlestickRenderer;
import org.jfree.data.xy.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.net.URL;
import java.text.*;
import java.util.*;
import java.util.List;
public class CandlestickDemo extends JFrame {
public CandlestickDemo(String stockSymbol) {
super("CandlestickDemo");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DateAxis domainAxis = new DateAxis("Date");
NumberAxis rangeAxis = new NumberAxis("Price");
CandlestickRenderer renderer = new CandlestickRenderer();
XYDataset dataset = getDataSet(stockSymbol);
XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
//Do some setting up, see the API Doc
renderer.setSeriesPaint(0, Color.BLACK);
renderer.setDrawVolume(false);
rangeAxis.setAutoRangeIncludesZero(false);
domainAxis.setTimeline( SegmentedTimeline.newMondayThroughFridayTimeline() );
//Now create the chart and chart panel
JFreeChart chart = new JFreeChart(stockSymbol, null, mainPlot, false);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(600, 300));
this.add(chartPanel);
this.pack();
}
protected AbstractXYDataset getDataSet(String stockSymbol) {
//This is the dataset we are going to create
DefaultOHLCDataset result = null;
//This is the data needed for the dataset
OHLCDataItem[] data;
//This is where we go get the data, replace with your own data source
data = getData(stockSymbol);
//Create a dataset, an Open, High, Low, Close dataset
result = new DefaultOHLCDataset(stockSymbol, data);
return result;
}
//This method uses yahoo finance to get the OHLC data
protected OHLCDataItem[] getData(String stockSymbol) {
List<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>();
try {
String strUrl= "http://ichart.finance.yahoo.com/table.csv?s="+stockSymbol+"&a=0&b=1&c=2008&d=3&e=30&f=2008&ignore=.csv";
URL url = new URL(strUrl);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
DateFormat df = new SimpleDateFormat("y-M-d");
String inputLine;
in.readLine();
while ((inputLine = in.readLine()) != null) {
StringTokenizer st = new StringTokenizer(inputLine, ",");
Date date = df.parse( st.nextToken() );
double open = Double.parseDouble( st.nextToken() );
double high = Double.parseDouble( st.nextToken() );
double low = Double.parseDouble( st.nextToken() );
double close = Double.parseDouble( st.nextToken() );
double volume = Double.parseDouble( st.nextToken() );
double adjClose = Double.parseDouble( st.nextToken() );
OHLCDataItem item = new OHLCDataItem(date, open, high, low, close, volume);
dataItems.add(item);
}
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
//Data from Yahoo is from newest to oldest. Reverse so it is oldest to newest
Collections.reverse(dataItems);
//Convert the list into an array
OHLCDataItem[] data = dataItems.toArray(new OHLCDataItem[dataItems.size()]);
return data;
}
public static void main(String[] args) {
new CandlestickDemo("MSFT").setVisible(true);
}
}

View File

@ -0,0 +1,30 @@
<?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,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JToggleButton" name="jToggleButton2">
<Properties>
<Property name="text" type="java.lang.String" value="jToggleButton2"/>
</Properties>
<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>

View File

@ -0,0 +1,268 @@
/*
* 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.awt.Color;
import java.awt.Dimension;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Iterator;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.SegmentedTimeline;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.CandlestickRenderer;
import org.jfree.data.xy.AbstractXYDataset;
import org.jfree.data.xy.DefaultOHLCDataset;
import org.jfree.data.xy.OHLCDataItem;
import org.jfree.data.xy.XYDataset;
import sesim.Quote;
import java.util.SortedSet;
import java.util.TreeSet;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class Chart extends javax.swing.JPanel implements QuoteReceiver {
/**
* Creates new form Chart
*/
public Chart() {
initComponents();
String stockSymbol = "Schliemanz Koch AG";
//String stockSymbol = "MSFT";
DateAxis domainAxis = new DateAxis("Date");
NumberAxis rangeAxis = new NumberAxis("Price");
CandlestickRenderer renderer = new CandlestickRenderer();
XYDataset dataset = getDataSet(stockSymbol);
XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
//Do some setting up, see the API Doc
renderer.setSeriesPaint(0, Color.BLACK);
renderer.setDrawVolume(false);
rangeAxis.setAutoRangeIncludesZero(false);
domainAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
//Now create the chart and chart panel
JFreeChart chart = new JFreeChart(stockSymbol, null, mainPlot, false);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(500, 270));
add(chartPanel);
System.out.print("Hallo Welt\n");
if (MainWin.se == null) {
return;
}
MainWin.se.addQuoteReceiver(this);
}
protected AbstractXYDataset getDataSet(String stockSymbol) {
//This is the dataset we are going to create
DefaultOHLCDataset result = null;
//This is the data needed for the dataset
OHLCDataItem[] data;
//This is where we go get the data, replace with your own data source
data = getData();
//Create a dataset, an Open, High, Low, Close dataset
result = new DefaultOHLCDataset(stockSymbol, data);
return result;
}
protected OHLCDataItem getOhlcData(long first, long last, SortedSet<Quote> quotes) {
Quote s = new Quote();
s.time = first;
SortedSet<Quote> l = quotes.tailSet(s);
double open = 0;
double high = 0;
double low = 0;
double close = 0;
double volume=0;
Iterator<Quote> it = l.iterator();
Quote q;
if (it.hasNext()) {
q = it.next();
open = q.price;
high = q.price;
low = q.price;
volume = q.volume;
}
else {
q = new Quote();
}
while (it.hasNext() && q.time < last) {
q = it.next();
if (q.price > high) {
high = q.price;
}
if (q.price < low) {
low = q.price;
}
volume += q.volume;
}
close = q.price;
Date date = new Date(first);
return new OHLCDataItem(
date, open, high, low, close, volume
);
}
protected OHLCDataItem[] getData() {
List<OHLCDataItem> data = new ArrayList<>();
long ct;
ct = Exchange.getCurrentTimeSeconds(10);
SortedSet<Quote> h = MainWin.se.getQuoteHistory(ct - 60);
for (long i = (ct - 60)*1000; i < (ct + 10)*1000; i += 10*1000) {
OHLCDataItem d = getOhlcData(i, i + 10*1000, h);
data.add(d);
}
System.out.print(data.size() + "\n");
// System.exit(0);
return data.toArray(new OHLCDataItem[data.size()]);
}
//This method uses yahoo finance to get the OHLC data
protected OHLCDataItem[] getData_old() {
String stockSymbol = "MSFT";
List<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>();
try {
String strUrl = "http://ichart.finance.yahoo.com/table.csv?s=" + stockSymbol + "&a=0&b=1&c=2008&d=3&e=30&f=2008&ignore=.csv";
URL url = new URL(strUrl);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
DateFormat df = new SimpleDateFormat("y-M-d");
String inputLine;
in.readLine();
while ((inputLine = in.readLine()) != null) {
StringTokenizer st = new StringTokenizer(inputLine, ",");
Date date = df.parse(st.nextToken());
double open = Double.parseDouble(st.nextToken());
double high = Double.parseDouble(st.nextToken());
double low = Double.parseDouble(st.nextToken());
double close = Double.parseDouble(st.nextToken());
double volume = Double.parseDouble(st.nextToken());
double adjClose = Double.parseDouble(st.nextToken());
OHLCDataItem item = new OHLCDataItem(date, open, high, low, close, volume);
dataItems.add(item);
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
//Data from Yahoo is from newest to oldest. Reverse so it is oldest to newest
Collections.reverse(dataItems);
//Convert the list into an array
OHLCDataItem[] data = dataItems.toArray(new OHLCDataItem[dataItems.size()]);
System.out.print("Return oghls old data items\n");
return data;
}
/**
* 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() {
jToggleButton2 = new javax.swing.JToggleButton();
setLayout(new java.awt.BorderLayout());
jToggleButton2.setText("jToggleButton2");
add(jToggleButton2, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JToggleButton jToggleButton2;
// End of variables declaration//GEN-END:variables
@Override
public void UpdateQuote(Quote q) {
return;
//q.print();
/* SortedSet h = MainWin.se.getQuoteHistory(60);
System.out.print(
"SortedSet size:"
+ h.size()
+ "\n"
);
*/
}
}

View File

@ -0,0 +1,76 @@
<?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"/>
<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,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="0"/>
<Property name="rows" type="int" value="3"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="SellButton">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="c" green="0" red="b5" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="SellButton" property="font" relativeSize="true" size="12"/>
</FontInfo>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="fe" green="fe" red="fe" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Sell"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="SellButtonActionPerformed"/>
</Events>
</Component>
<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="jTextArea1">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="BuyButton">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="1" green="5e" red="5" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="BuyButton" property="font" relativeSize="true" size="12"/>
</FontInfo>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="fe" green="fe" red="fe" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Buy"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="BuyButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,101 @@
/*
* 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() {
SellButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
BuyButton = new javax.swing.JButton();
setLayout(new java.awt.GridLayout(3, 0));
SellButton.setBackground(new java.awt.Color(181, 0, 12));
SellButton.setFont(SellButton.getFont().deriveFont(SellButton.getFont().getStyle() | java.awt.Font.BOLD, SellButton.getFont().getSize()+12));
SellButton.setForeground(new java.awt.Color(254, 254, 254));
SellButton.setText("Sell");
SellButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SellButtonActionPerformed(evt);
}
});
add(SellButton);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
add(jScrollPane1);
BuyButton.setBackground(new java.awt.Color(5, 94, 1));
BuyButton.setFont(BuyButton.getFont().deriveFont(BuyButton.getFont().getStyle() | java.awt.Font.BOLD, BuyButton.getFont().getSize()+12));
BuyButton.setForeground(new java.awt.Color(254, 254, 254));
BuyButton.setText("Buy");
BuyButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BuyButtonActionPerformed(evt);
}
});
add(BuyButton);
}// </editor-fold>//GEN-END:initComponents
private void SellButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SellButtonActionPerformed
MainWin.myAccount.sell(81, 55.0);
}//GEN-LAST:event_SellButtonActionPerformed
private void BuyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BuyButtonActionPerformed
MainWin.myAccount.buy(44, 66.0);
}//GEN-LAST:event_BuyButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton BuyButton;
private javax.swing.JButton SellButton;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,105 @@
<?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="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
</Properties>
</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,2,-69"/>
</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="gui.Chart" name="zZChart1">
<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>

View File

@ -0,0 +1,224 @@
/*
* 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 traders.RandomTraderConfig;
import traders.SwitchingTraderConfig;
import sesim.Account;
import sesim.AutoTraderLIst;
import sesim.Exchange;
import sesim.BuyOrder;
import javax.swing.UIManager;
import javax.swing.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class MainWin extends javax.swing.JFrame {
static sesim.Exchange se;
static sesim.Account myAccount;
static traders.ManTrader myTrader;
/**
* Creates new form MainWin
*/
public MainWin() {
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();
jMenuItem1 = new javax.swing.JMenuItem();
controlPanel2 = new gui.ControlPanel();
orderBookPanel1 = new gui.OrderBookPanel();
zZChart1 = new gui.Chart();
MainMenu = new javax.swing.JMenuBar();
FileMenu = new javax.swing.JMenu();
FileNew = new javax.swing.JMenuItem();
FileRun = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
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(zZChart1, 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);
jMenu2.setText("Edit");
MainMenu.add(jMenu2);
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
se.start();
}//GEN-LAST:event_FileRunActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
se = new Exchange();
myAccount = new Account(se,1000,100000000.0);
myTrader = new traders.ManTrader(myAccount,null);
/* Account otherAccount = new Account(se,1000,1000);
Traders.ManTrader otherTrader = new Traders.ManTrader(otherAccount);
otherTrader.sell(80, 22.70);
*/
/*
Account traccount = new Account(se,5500,1000000.0);
RandomTrader rt = new RandomTrader(traccount,null);
TraderRunner tr = new TraderRunner(rt);
tr.start();
*/
AutoTraderLIst at = new AutoTraderLIst();
// RandomTraderConfig rcfg = new RandomTraderConfig();
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);
// 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.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
*/
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainWin().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.JButton jButton1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuItem jMenuItem1;
private gui.OrderBookPanel orderBookPanel1;
private gui.Chart zZChart1;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" 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,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
</Form>

View File

@ -0,0 +1,128 @@
/*
* 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 static Gui.SimpleJFreeDemo.createDemoPanel;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.function.Function2D;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.xy.XYDataset;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewPanel extends javax.swing.JPanel {
/**
* Creates new form NewPanel
*/
public NewPanel() {
initComponents();
initComponents();
JPanel chartPanel = createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
add(chartPanel);
}
private static JFreeChart createChart(XYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(
"Function2DDemo1 ", // chart title
"X", // x axis label
"Y", // y axis label
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
plot.getDomainAxis().setLowerMargin(0.0);
plot.getDomainAxis().setUpperMargin(0.0);
return chart;
}
/**
* Creates a sample dataset.
*
* @return A sample dataset.
*/
public static XYDataset createDataset() {
XYDataset result = DatasetUtilities.sampleFunction2D(new X2(),
-4.0, 4.0, 40, "f(x)");
return result;
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public static JPanel createDemoPanel() {
JFreeChart chart = createChart(createDataset());
return new ChartPanel(chart);
}
/**
* A simple function.
*/
static class X2 implements Function2D {
/* (non-Javadoc)
* @see org.jfree.data.function.Function2D#getValue(double)
*/
public double getValue(double x) {
return x * x + 2;
}
}
/**
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setLayout(new java.awt.BorderLayout());
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,83 @@
<?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="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="doubleBuffered" type="boolean" value="true"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,276 @@
/*
* 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 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 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 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 newlist;
@Override
public void run() {
model.update(this.newlist);
}
Updater(OrderBookListModel model, ArrayList newlist){
this.model = model;
this.newlist = newlist;
}
}
ArrayList newlist = getOrderBook();
SwingUtilities.invokeLater(new Updater(this.model,newlist));
}
boolean getDesc() {
return false;
}
// protected OrderBookListModel model;
protected class OrderBookListModel extends AbstractTableModel {
private ArrayList list;
private 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;
}
@Override
public Object getValueAt(int r, int c) {
sesim.Order o;
int s = list.size();
//System.out.print("Looking for Value at" + r + ":" + c + " w size:" + s + "\n");
if (!getDesc()) {
o = (sesim.Order) list.get(r);
} else {
o = (sesim.Order) list.get(list.size() - r - 1);
}
Formatter f = new Formatter();
switch (c) {
case 0:
return f.format("#%06x", o.id);
case 1:
return o.limit;
case 2:
return o.volume;
}
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 (MainWin.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.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.setDoubleBuffered(true);
orderBookList.setFocusable(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
}

View 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>

View 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 = MainWin.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
}

View 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>

View 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 (MainWin.se==null)
return;
MainWin.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("%.2f\n(%d)", 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);
}
}

115
src/main/java/gui/test.java Normal file
View File

@ -0,0 +1,115 @@
/*
* 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());
}
public static void main(String args[]) {
NoProblem p = new NoProblem();
p.run();
}
}