next generation x legend
This commit is contained in:
parent
254846c356
commit
caeb2c4060
@ -1,4 +1,4 @@
|
||||
#Sat, 30 Sep 2017 21:57:38 +0200
|
||||
#Sun, 01 Oct 2017 11:14:27 +0200
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
|
@ -1,19 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[300, 300]"/>
|
||||
</Property>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="2"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="formMouseMoved"/>
|
||||
</Events>
|
||||
|
@ -193,7 +193,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
||||
class RenderCtx {
|
||||
|
||||
Rectangle rect;
|
||||
float scaling;
|
||||
//float scaling;
|
||||
float min;
|
||||
Graphics2D g;
|
||||
float iwidth;
|
||||
@ -461,7 +461,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
||||
RenderCtx ctx = new RenderCtx();
|
||||
|
||||
ctx.rect = new Rectangle(0, h1 + pad_top, pwidth, subchartwin_height - pad_top);
|
||||
ctx.scaling = (float) ctx.rect.height / (c_mm.getMax() - c_mm.getMin());
|
||||
// ctx.scaling = (float) ctx.rect.height / (c_mm.getMax() - c_mm.getMin());
|
||||
ctx.min = c_mm.getMin();
|
||||
ctx.g = g;
|
||||
ctx.iwidth = (float) ((x_unit_width * em_width) * 0.9f);
|
||||
|
@ -25,7 +25,7 @@ import sesim.Quote;
|
||||
public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, AdjustmentListener {
|
||||
|
||||
public JScrollBar xbar;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form Chart1
|
||||
*/
|
||||
@ -34,16 +34,12 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Adjustm
|
||||
System.out.printf("Now cursor\n");
|
||||
|
||||
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||
|
||||
|
||||
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
setSize(new Dimension(9000,500));
|
||||
setSize(new Dimension(9000, 500));
|
||||
Globals.se.addQuoteReceiver(this);
|
||||
}
|
||||
|
||||
@ -51,38 +47,27 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Adjustm
|
||||
|
||||
private void drawChart(Graphics2D g) {
|
||||
|
||||
|
||||
|
||||
JViewport vp = new JViewport();
|
||||
|
||||
|
||||
|
||||
// if (Globals.se==null)
|
||||
// return;
|
||||
|
||||
Dimension d = new Dimension(200,200);
|
||||
// if (Globals.se==null)
|
||||
// return;
|
||||
Dimension d = new Dimension(200, 200);
|
||||
setPreferredSize(d);
|
||||
|
||||
|
||||
g.setClip(10,10,800,200);
|
||||
g.setClip(10, 10, 800, 200);
|
||||
g.setColor(Color.red);
|
||||
g.drawLine(0, 0, 8000, 610);
|
||||
|
||||
if (Globals.se==null)
|
||||
|
||||
if (Globals.se == null) {
|
||||
return;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
revalidate();
|
||||
|
||||
|
||||
System.out.printf("Setting pref size\n" );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.printf("Setting pref size\n");
|
||||
|
||||
OHLCData data = Globals.se.getOHLCdata(60000);
|
||||
/*
|
||||
/*
|
||||
int first_bar = 0;
|
||||
int last_bar = data.size();
|
||||
|
||||
@ -103,8 +88,9 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Adjustm
|
||||
prev = di;
|
||||
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
OHLCData data;
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
@ -113,12 +99,12 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Adjustm
|
||||
// Calculate the number of pixels for 1 em
|
||||
em_width = g.getFontMetrics().stringWidth("M");
|
||||
|
||||
this.xbar.setMaximum(994000);
|
||||
|
||||
//this.xbar.setMaximum(994000);
|
||||
|
||||
ChartPainter p = new ChartPainter();
|
||||
p.drawChart((Graphics2D)g, xbar, getSize());
|
||||
|
||||
|
||||
data = Globals.se.getOHLCdata(60000);
|
||||
p.drawChart((Graphics2D) g, xbar, data, this);
|
||||
|
||||
//drawChart((Graphics2D)g);
|
||||
}
|
||||
|
||||
@ -145,17 +131,20 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Adjustm
|
||||
|
||||
@Override
|
||||
public void UpdateQuote(Quote q) {
|
||||
|
||||
int s = data.size();
|
||||
System.out.printf("Data size %d",s);
|
||||
xbar.setMaximum(data.size());
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
System.out.printf("Adjustemntlistener called %d\n",xbar.getValue());
|
||||
System.out.printf("Adjustemntlistener called %d\n", xbar.getValue());
|
||||
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
37
src/chart/ChartDef.java
Normal file
37
src/chart/ChartDef.java
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 javax.swing.JScrollBar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ChartDef {
|
||||
JScrollBar scrollbar;
|
||||
|
||||
}
|
@ -29,6 +29,7 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.swing.JScrollBar;
|
||||
import sesim.OHLCData;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -39,18 +40,54 @@ public class ChartPainter {
|
||||
int em_width;
|
||||
|
||||
protected final void init(Graphics2D g) {
|
||||
|
||||
|
||||
// Calculate the number of pixels for 1 em
|
||||
em_width = g.getFontMetrics().stringWidth("M");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void drawChart(Graphics2D g, JScrollBar sb, Dimension size) {
|
||||
init (g);
|
||||
int big_tick = 10;
|
||||
int y = 0;
|
||||
|
||||
String getAt(OHLCData data, int unit) {
|
||||
|
||||
int fs = data.getFrameSize();
|
||||
return sesim.Scheduler.formatTimeMillis(0 + unit * fs);
|
||||
|
||||
}
|
||||
|
||||
public void drawChart(Graphics2D g, JScrollBar sb, OHLCData data, Chart1 p) {
|
||||
init(g);
|
||||
g.setColor(Color.MAGENTA);
|
||||
g.drawLine(0, 0, size.width, 100);
|
||||
g.setBackground(Color.yellow);
|
||||
Dimension size = p.getSize();
|
||||
//g.drawLine(0, 0, size.width, 100);
|
||||
|
||||
System.out.printf("SIZE %d %d\n",size.width,size.height);
|
||||
|
||||
|
||||
|
||||
int n;
|
||||
int x;
|
||||
for (n = 0, x = 0; x < size.width; x += em_width * 1.0) {
|
||||
if (n % big_tick == 1) {
|
||||
g.drawLine((int) x, y, (int) x, y + em_width);
|
||||
String text;
|
||||
text = getAt(data,n);
|
||||
|
||||
int swidth = g.getFontMetrics().stringWidth(text);
|
||||
g.drawString(text, (int) x - swidth / 2, y + em_width * 2);
|
||||
|
||||
} else {
|
||||
g.drawLine((int) x, y, (int) x, y + em_width / 2);
|
||||
}
|
||||
|
||||
if (n % big_tick == 0) {
|
||||
|
||||
}
|
||||
|
||||
n += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,9 +32,8 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="chart11" alignment="1" pref="482" max="32767" attributes="0"/>
|
||||
<Component id="jScrollBar1" alignment="1" pref="482" max="32767" attributes="0"/>
|
||||
<Component id="jToolBar1" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="jScrollBar1" pref="586" max="32767" attributes="0"/>
|
||||
<Component id="chart11" pref="586" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -44,10 +43,8 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chart11" min="-2" pref="198" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jToolBar1" pref="102" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="chart11" pref="318" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollBar1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -70,18 +67,10 @@
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="198" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="318" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JToolBar" name="jToolBar1">
|
||||
<Properties>
|
||||
<Property name="floatable" type="boolean" value="false"/>
|
||||
<Property name="rollover" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -53,7 +53,6 @@ public class ChartTestDialog extends javax.swing.JDialog {
|
||||
|
||||
jScrollBar1 = new javax.swing.JScrollBar();
|
||||
chart11 = new chart.Chart1();
|
||||
jToolBar1 = new javax.swing.JToolBar();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setMaximumSize(new java.awt.Dimension(800, 600));
|
||||
@ -69,12 +68,9 @@ public class ChartTestDialog extends javax.swing.JDialog {
|
||||
);
|
||||
chart11Layout.setVerticalGroup(
|
||||
chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 198, Short.MAX_VALUE)
|
||||
.addGap(0, 318, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
jToolBar1.setFloatable(false);
|
||||
jToolBar1.setRollover(true);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@ -82,19 +78,16 @@ public class ChartTestDialog extends javax.swing.JDialog {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(chart11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
|
||||
.addComponent(jScrollBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
|
||||
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(jScrollBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
|
||||
.addComponent(chart11, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(chart11, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(chart11, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
@ -147,6 +140,5 @@ public class ChartTestDialog extends javax.swing.JDialog {
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private chart.Chart1 chart11;
|
||||
private javax.swing.JScrollBar jScrollBar1;
|
||||
private javax.swing.JToolBar jToolBar1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user