More work on new charts
This commit is contained in:
parent
c8c72d264d
commit
a352e4e841
@ -1,4 +1,4 @@
|
||||
#Tue, 03 Oct 2017 07:33:39 +0200
|
||||
#Tue, 03 Oct 2017 12:34:23 +0200
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
|
@ -40,7 +40,8 @@ public class ChartCrossPainter extends ChartPainter{
|
||||
@Override
|
||||
public void drawChart(Graphics2D g, JScrollBar sb, OHLCData data, ChartPanel p, ChartDef def) {
|
||||
Point mp = p.mouse;
|
||||
|
||||
if (mp==null)
|
||||
return;
|
||||
|
||||
g.drawLine(0, p.mouse.y-1, p.getSize().width, p.mouse.y-1);
|
||||
g.drawLine(p.mouse.x-1, 0, p.mouse.x-1, p.getSize().height);
|
||||
|
@ -38,12 +38,12 @@ import sesim.OHLCData;
|
||||
*/
|
||||
abstract public class ChartPainter {
|
||||
|
||||
int em_width;
|
||||
int em_size;
|
||||
|
||||
protected final void init(Graphics2D g) {
|
||||
|
||||
// Calculate the number of pixels for 1 em
|
||||
em_width = g.getFontMetrics().stringWidth("M");
|
||||
em_size = g.getFontMetrics().stringWidth("M");
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import sesim.Quote;
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ChartPanel extends javax.swing.JPanel implements QuoteReceiver, AdjustmentListener {
|
||||
public class ChartPanel extends javax.swing.JPanel /*implements AdjustmentListener*/ {
|
||||
|
||||
public JScrollBar xbar;
|
||||
|
||||
@ -33,56 +33,42 @@ public class ChartPanel extends javax.swing.JPanel implements QuoteReceiver, Adj
|
||||
*/
|
||||
public ChartPanel() {
|
||||
initComponents();
|
||||
System.out.printf("Now cursor\n");
|
||||
|
||||
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSize(new Dimension(9000, 500));
|
||||
Globals.se.addQuoteReceiver(this);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
private ArrayList <ChartPainter> chartPainters = new ArrayList<>();
|
||||
|
||||
|
||||
private ArrayList<ChartPainter> chartPainters = new ArrayList<>();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
public void addChartPainter(ChartPainter p){
|
||||
public void addChartPainter(ChartPainter p) {
|
||||
chartPainters.add(p);
|
||||
}
|
||||
|
||||
|
||||
OHLCData data;
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
if (Globals.se==null)
|
||||
return;
|
||||
|
||||
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//this.xbar.setMaximum(994000);
|
||||
|
||||
XLegendChartPainter p = new XLegendChartPainter();
|
||||
data = Globals.se.getOHLCdata(60000*60);
|
||||
|
||||
data = Globals.se.getOHLCdata(60000 * 60);
|
||||
|
||||
ChartDef def = new ChartDef();
|
||||
def.x_unit_width = 1.0;
|
||||
def.x_scrollbar=xbar;
|
||||
|
||||
|
||||
for (ChartPainter painter: chartPainters){
|
||||
painter.drawChart((Graphics2D)g, xbar, data, this, def);
|
||||
def.x_scrollbar = xbar;
|
||||
|
||||
for (ChartPainter painter : chartPainters) {
|
||||
painter.drawChart((Graphics2D) g, xbar, data, this, def);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -113,28 +99,17 @@ public class ChartPanel extends javax.swing.JPanel implements QuoteReceiver, Adj
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
Point mouse=null;
|
||||
|
||||
Point mouse = null;
|
||||
|
||||
private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved
|
||||
// TODO add your handling code here:
|
||||
|
||||
Point p = evt.getPoint();
|
||||
mouse = p;
|
||||
System.out.printf("Point %d %d\n",p.x,p.y);
|
||||
repaint();
|
||||
|
||||
|
||||
}//GEN-LAST:event_formMouseMoved
|
||||
|
||||
|
||||
@Override
|
||||
public void UpdateQuote(Quote q) {
|
||||
|
||||
int s = data.size();
|
||||
// System.out.printf("Data size %d",s);
|
||||
// xbar.setMaximum(data.size());
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Override
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
|
||||
this.repaint();
|
||||
|
@ -26,109 +26,24 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollBar1" pref="639" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="chart11" max="32767" attributes="0"/>
|
||||
<Component id="chart12" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chartPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="masterChart" pref="639" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="chart11" max="32767" attributes="0"/>
|
||||
<Component id="chartPanel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chart12" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollBar1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="masterChart" pref="408" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JScrollBar" name="jScrollBar1">
|
||||
<Properties>
|
||||
<Property name="maximum" type="int" value="0"/>
|
||||
<Property name="orientation" type="int" value="0"/>
|
||||
<Property name="name" type="java.lang.String" value="" noResource="true"/>
|
||||
</Properties>
|
||||
<Component class="chart.MasterChart" name="masterChart">
|
||||
</Component>
|
||||
<Container class="chart.ChartPanel" name="chart12">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="58" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="chart.ChartPanel" name="chart11">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder roundedCorners="true"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="546" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="231" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="chart.ChartPanel" name="chartPanel1">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder>
|
||||
<Color PropertyName="color" blue="99" green="99" red="ff" type="rgb"/>
|
||||
</LineBorder>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="83" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -34,7 +34,7 @@ import sesim.Quote;
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceiver {
|
||||
public class ChartTestDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form ChartTestDialog
|
||||
@ -42,28 +42,8 @@ public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceive
|
||||
public ChartTestDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
setLocationRelativeTo(parent);
|
||||
this.chart12.xbar = this.jScrollBar1;
|
||||
this.jScrollBar1.addAdjustmentListener(chart12);
|
||||
|
||||
ChartPainter p = new XLegendChartPainter();
|
||||
chart12.addChartPainter(p);
|
||||
Globals.se.addQuoteReceiver(this);
|
||||
|
||||
this.chart11.xbar = this.jScrollBar1;
|
||||
this.jScrollBar1.addAdjustmentListener(chart11);
|
||||
|
||||
p = new CandleStickChartPainter();
|
||||
this.chart11.addChartPainter(p);
|
||||
|
||||
p = new LineChartPainter();
|
||||
this.chart11.addChartPainter(p);
|
||||
|
||||
p = new ChartCrossPainter();
|
||||
this.chart11.addChartPainter(p);
|
||||
|
||||
|
||||
|
||||
// setLocationRelativeTo(parent);
|
||||
// masterChart.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,83 +55,24 @@ public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceive
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jScrollBar1 = new javax.swing.JScrollBar();
|
||||
chart12 = new chart.ChartPanel();
|
||||
chart11 = new chart.ChartPanel();
|
||||
chartPanel1 = new chart.ChartPanel();
|
||||
masterChart = new chart.MasterChart();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(100, 100));
|
||||
|
||||
jScrollBar1.setMaximum(0);
|
||||
jScrollBar1.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
|
||||
jScrollBar1.setName(""); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout chart12Layout = new javax.swing.GroupLayout(chart12);
|
||||
chart12.setLayout(chart12Layout);
|
||||
chart12Layout.setHorizontalGroup(
|
||||
chart12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
chart12Layout.setVerticalGroup(
|
||||
chart12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 58, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
chart11.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
|
||||
|
||||
javax.swing.GroupLayout chart11Layout = new javax.swing.GroupLayout(chart11);
|
||||
chart11.setLayout(chart11Layout);
|
||||
chart11Layout.setHorizontalGroup(
|
||||
chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 546, Short.MAX_VALUE)
|
||||
);
|
||||
chart11Layout.setVerticalGroup(
|
||||
chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 231, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
chartPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 153, 153)));
|
||||
|
||||
javax.swing.GroupLayout chartPanel1Layout = new javax.swing.GroupLayout(chartPanel1);
|
||||
chartPanel1.setLayout(chartPanel1Layout);
|
||||
chartPanel1Layout.setHorizontalGroup(
|
||||
chartPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 83, Short.MAX_VALUE)
|
||||
);
|
||||
chartPanel1Layout.setVerticalGroup(
|
||||
chartPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(chart11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chart12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chartPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addComponent(masterChart, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(chart11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chartPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chart12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(masterChart, javax.swing.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -201,17 +122,8 @@ public class ChartTestDialog extends javax.swing.JDialog implements QuoteReceive
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private chart.ChartPanel chart11;
|
||||
private chart.ChartPanel chart12;
|
||||
private chart.ChartPanel chartPanel1;
|
||||
private javax.swing.JScrollBar jScrollBar1;
|
||||
private chart.MasterChart masterChart;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void UpdateQuote(Quote q) {
|
||||
OHLCData data = Globals.se.getOHLCdata(60000 * 60 * 4);
|
||||
this.jScrollBar1.setMaximum(data.size());
|
||||
repaint();
|
||||
System.out.printf("SETMAXIMUM: %d", data.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ import sesim.OHLCDataItem;
|
||||
*/
|
||||
public class LineChartPainter extends OHLCChartPainter{
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
void drawItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) {
|
||||
|
||||
@ -45,7 +47,7 @@ public class LineChartPainter extends OHLCChartPainter{
|
||||
int y2 = (int) getY(i.close);
|
||||
Color cur = g.getColor();
|
||||
g.setColor(Color.RED);
|
||||
|
||||
|
||||
g.drawLine(prevx, y1, x, y2);
|
||||
g.setColor(cur);
|
||||
}
|
||||
|
131
src/chart/MasterChart.form
Normal file
131
src/chart/MasterChart.form
Normal file
@ -0,0 +1,131 @@
|
||||
<?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">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="xScrollBar" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="xLegend" max="32767" attributes="0"/>
|
||||
<Component id="chart" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="yLegend" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="yLegend" max="32767" attributes="0"/>
|
||||
<Component id="chart" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="xLegend" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="xScrollBar" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="chart.ChartPanel" name="chart">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder roundedCorners="true">
|
||||
<Color PropertyName="color" blue="99" green="0" red="99" type="rgb"/>
|
||||
</LineBorder>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="chartMouseMoved"/>
|
||||
</Events>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="chart.ChartPanel" name="yLegend">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder roundedCorners="true"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="95" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="253" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="chart.ChartPanel" name="xLegend">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder roundedCorners="true"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="520" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="73" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Component class="javax.swing.JScrollBar" name="xScrollBar">
|
||||
<Properties>
|
||||
<Property name="orientation" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
174
src/chart/MasterChart.java
Normal file
174
src/chart/MasterChart.java
Normal file
@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package chart;
|
||||
|
||||
import gui.Globals;
|
||||
import sesim.Exchange.QuoteReceiver;
|
||||
import sesim.OHLCData;
|
||||
import sesim.Quote;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class MasterChart extends javax.swing.JPanel implements QuoteReceiver{
|
||||
|
||||
OHLCData data;
|
||||
|
||||
/**
|
||||
* Creates new form MasterChart
|
||||
*/
|
||||
public MasterChart() {
|
||||
initComponents();
|
||||
|
||||
ChartDef def = new ChartDef();
|
||||
def.x_unit_width=1.0;
|
||||
def.x_scrollbar=xScrollBar;
|
||||
|
||||
if (Globals.se==null)
|
||||
return;
|
||||
|
||||
data = Globals.se.getOHLCdata(60000);
|
||||
|
||||
ChartPainter p = new CandleStickChartPainter();
|
||||
//this.chart.addChartPainter(p);
|
||||
|
||||
p = new XLegendChartPainter();
|
||||
xLegend.addChartPainter(p);
|
||||
|
||||
p = new ChartCrossPainter();
|
||||
this.chart.addChartPainter(p);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
chart = new chart.ChartPanel();
|
||||
yLegend = new chart.ChartPanel();
|
||||
xLegend = new chart.ChartPanel();
|
||||
xScrollBar = new javax.swing.JScrollBar();
|
||||
|
||||
chart.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 0, 153), 1, true));
|
||||
chart.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
|
||||
public void mouseMoved(java.awt.event.MouseEvent evt) {
|
||||
chartMouseMoved(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout chartLayout = new javax.swing.GroupLayout(chart);
|
||||
chart.setLayout(chartLayout);
|
||||
chartLayout.setHorizontalGroup(
|
||||
chartLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
chartLayout.setVerticalGroup(
|
||||
chartLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
yLegend.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
|
||||
|
||||
javax.swing.GroupLayout yLegendLayout = new javax.swing.GroupLayout(yLegend);
|
||||
yLegend.setLayout(yLegendLayout);
|
||||
yLegendLayout.setHorizontalGroup(
|
||||
yLegendLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 95, Short.MAX_VALUE)
|
||||
);
|
||||
yLegendLayout.setVerticalGroup(
|
||||
yLegendLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 253, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
xLegend.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
|
||||
|
||||
javax.swing.GroupLayout xLegendLayout = new javax.swing.GroupLayout(xLegend);
|
||||
xLegend.setLayout(xLegendLayout);
|
||||
xLegendLayout.setHorizontalGroup(
|
||||
xLegendLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 520, Short.MAX_VALUE)
|
||||
);
|
||||
xLegendLayout.setVerticalGroup(
|
||||
xLegendLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 73, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
xScrollBar.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(xScrollBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(xLegend, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(yLegend, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(yLegend, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(xLegend, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(xScrollBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void chartMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_chartMouseMoved
|
||||
System.out.printf("Chart Mouse Moved\n");
|
||||
}//GEN-LAST:event_chartMouseMoved
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private chart.ChartPanel chart;
|
||||
private chart.ChartPanel xLegend;
|
||||
private javax.swing.JScrollBar xScrollBar;
|
||||
private chart.ChartPanel yLegend;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void UpdateQuote(Quote q) {
|
||||
repaint();
|
||||
}
|
||||
}
|
@ -64,11 +64,11 @@ public abstract class OHLCChartPainter extends ChartPainter {
|
||||
public void drawChart(Graphics2D g, JScrollBar sb, OHLCData data, ChartPanel p, ChartDef def) {
|
||||
init(g);
|
||||
|
||||
iwidth = (float) ((def.x_unit_width * em_width) * 0.9f);
|
||||
iwidth = (float) ((def.x_unit_width * em_size) * 0.9f);
|
||||
|
||||
int first_bar = def.x_scrollbar.getValue();
|
||||
dim = p.getSize();
|
||||
int bars = (int) (dim.width / (def.x_unit_width * em_width));
|
||||
int bars = (int) (dim.width / (def.x_unit_width * em_size));
|
||||
|
||||
int last_bar = first_bar + bars+1;
|
||||
|
||||
@ -88,11 +88,11 @@ public abstract class OHLCChartPainter extends ChartPainter {
|
||||
for (int b = first_bar, n = 0; b < last_bar && b < data.size(); b++, n++) {
|
||||
OHLCDataItem d = data.get(b);
|
||||
|
||||
int x = (int) (n * em_width * def.x_unit_width); //em_width;
|
||||
drawItem(g, (int) (x - em_width * def.x_unit_width), x, prevd, d);
|
||||
int x = (int) (n * em_size * def.x_unit_width); //em_width;
|
||||
drawItem(g, (int) (x - em_size * def.x_unit_width), x, prevd, d);
|
||||
prevd = d;
|
||||
|
||||
//this.drawCandleItem(g, (int)((n-1)*def.x_unit_width*em_width), (int)(n*def.x_unit_width*em_width), prevd, d);
|
||||
//this.drawCandleItem(g, (int)((n-1)*def.x_unit_width*em_size), (int)(n*def.x_unit_width*em_size), prevd, d);
|
||||
}
|
||||
}
|
||||
|
||||
|
46
src/chart/SuperDlg.form
Normal file
46
src/chart/SuperDlg.form
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<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"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="masterChart1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="masterChart1" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="chart.MasterChart" name="masterChart1">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
120
src/chart/SuperDlg.java
Normal file
120
src/chart/SuperDlg.java
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package chart;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class SuperDlg extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form SuperDlg
|
||||
*/
|
||||
public SuperDlg(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
masterChart1 = new chart.MasterChart();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(masterChart1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(masterChart1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* 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 ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(SuperDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(SuperDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(SuperDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(SuperDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
SuperDlg dialog = new SuperDlg(new javax.swing.JFrame(), true);
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private chart.MasterChart masterChart1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -48,32 +48,35 @@ public class XLegendChartPainter extends ChartPainter {
|
||||
public void drawChart(Graphics2D g, JScrollBar sb, OHLCData data, ChartPanel p, ChartDef def)
|
||||
{
|
||||
init(g);
|
||||
|
||||
g.setColor(Color.black);
|
||||
Dimension size = p.getSize();
|
||||
//g.drawLine(0, 0, size.width, 100);
|
||||
|
||||
System.out.printf("SIZE %d %d\n", size.width, size.height);
|
||||
|
||||
int bars = (int) (size.width / (def.x_unit_width * em_width));
|
||||
int bars = (int) (size.width / (def.x_unit_width * em_size));
|
||||
System.out.printf("Units = %d\n", bars);
|
||||
|
||||
int first_bar = def.x_scrollbar.getValue();
|
||||
//if (first_bar<0)
|
||||
// first_bar=0;
|
||||
|
||||
int first_bar;
|
||||
if (def.x_scrollbar!=null)
|
||||
first_bar = def.x_scrollbar.getValue();
|
||||
else
|
||||
first_bar=0;
|
||||
|
||||
int n;
|
||||
int x;
|
||||
for (n = first_bar, x = 0; x < size.width; x += em_width * def.x_unit_width) {
|
||||
for (n = first_bar, x = 0; x < size.width; x += em_size * def.x_unit_width) {
|
||||
if (n % big_tick == 1) {
|
||||
g.drawLine((int) x, y, (int) x, y + em_width);
|
||||
g.drawLine((int) x, y, (int) x, y + em_size);
|
||||
String text;
|
||||
text = getTimeStrAt(data, n);
|
||||
|
||||
int swidth = g.getFontMetrics().stringWidth(text);
|
||||
g.drawString(text, (int) x - swidth / 2, y + em_width * 2);
|
||||
g.drawString(text, (int) x - swidth / 2, y + em_size * 2);
|
||||
|
||||
} else {
|
||||
g.drawLine((int) x, y, (int) x, y + em_width / 2);
|
||||
g.drawLine((int) x, y, (int) x, y + em_size / 2);
|
||||
}
|
||||
|
||||
if (n % big_tick == 0) {
|
||||
|
@ -26,6 +26,7 @@
|
||||
package gui;
|
||||
|
||||
import chart.ChartTestDialog;
|
||||
import chart.SuperDlg;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
@ -867,7 +868,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
||||
}//GEN-LAST:event_clearMenuItemActionPerformed
|
||||
|
||||
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
|
||||
ChartTestDialog d = new ChartTestDialog(this, false);
|
||||
SuperDlg d = new SuperDlg(this, false);
|
||||
d.setVisible(true);
|
||||
|
||||
}//GEN-LAST:event_jMenuItem1ActionPerformed
|
||||
|
Loading…
Reference in New Issue
Block a user