Som work on MMChart

This commit is contained in:
7u83 2018-01-23 01:36:25 +01:00
parent fc06570e13
commit e9a89bb816
5 changed files with 54 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#Sat, 20 Jan 2018 21:21:05 +0100 #Tue, 23 Jan 2018 01:36:03 +0100
annotation.processing.enabled=true annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false annotation.processing.enabled.in.editor=false
annotation.processing.processors.list= annotation.processing.processors.list=

View File

@ -1,8 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?> <?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.JPanelFormInfo">
<NonVisualComponents>
<Container class="javax.swing.JPopupMenu" name="popupMenu">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
</Container>
</NonVisualComponents>
<Events> <Events>
<EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="formMouseMoved"/> <EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="formMouseMoved"/>
<EventHandler event="mouseWheelMoved" listener="java.awt.event.MouseWheelListener" parameters="java.awt.event.MouseWheelEvent" handler="formMouseWheelMoved"/>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
</Events> </Events>
<AuxValues> <AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>

View File

@ -33,6 +33,7 @@ import chart.painter.XLegendPainter;
import chart.painter.YLegendPainter; import chart.painter.YLegendPainter;
import gui.Globals; import gui.Globals;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
@ -50,7 +51,7 @@ import sesim.Stock;
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
*/ */
public class MMChart extends javax.swing.JPanel { public class MMChart extends JPanel {
Stock stock; Stock stock;
@ -69,6 +70,11 @@ public class MMChart extends javax.swing.JPanel {
ChartPanel yLegend; ChartPanel yLegend;
ChartPanel mainChart; ChartPanel mainChart;
private int compression=60000;
private void setupYLegend() { private void setupYLegend() {
yLegend = new ChartPanel(); yLegend = new ChartPanel();
Border redborder = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0)); Border redborder = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0));
@ -88,7 +94,7 @@ public class MMChart extends javax.swing.JPanel {
this.addMouseMotionListener(yLegend); this.addMouseMotionListener(yLegend);
OHLCChartPainter ylp = new YLegendPainter(/*null*/); OHLCChartPainter ylp = new YLegendPainter(/*null*/);
OHLCData mydata = stock.getOHLCdata(60000); OHLCData mydata = stock.getOHLCdata(compression);
ylp.setOHLCData(mydata); ylp.setOHLCData(mydata);
yLegend.setChartDef(chartDef); yLegend.setChartDef(chartDef);
@ -116,7 +122,7 @@ public class MMChart extends javax.swing.JPanel {
add(xLegend, gbConstraints); add(xLegend, gbConstraints);
OHLCChartPainter p; OHLCChartPainter p;
OHLCData mydata = stock.getOHLCdata(60000); OHLCData mydata = stock.getOHLCdata(compression);
// this.xScrollBar.setMaximum(0); // this.xScrollBar.setMaximum(0);
p = new XLegendPainter(); p = new XLegendPainter();
@ -136,6 +142,7 @@ public class MMChart extends javax.swing.JPanel {
private void addMouseMotionListener(JPanel panel) { private void addMouseMotionListener(JPanel panel) {
panel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { panel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
@Override
public void mouseMoved(java.awt.event.MouseEvent evt) { public void mouseMoved(java.awt.event.MouseEvent evt) {
formMouseMoved(evt); formMouseMoved(evt);
} }
@ -163,6 +170,9 @@ public class MMChart extends javax.swing.JPanel {
this.addMouseMotionListener(mainChart); this.addMouseMotionListener(mainChart);
mainChart.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
} }
ChartDef chartDef; ChartDef chartDef;
@ -216,11 +226,23 @@ public class MMChart extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
popupMenu = new javax.swing.JPopupMenu();
addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) { public void mouseMoved(java.awt.event.MouseEvent evt) {
formMouseMoved(evt); formMouseMoved(evt);
} }
}); });
addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
formMouseWheelMoved(evt);
}
});
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
});
setLayout(null); setLayout(null);
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@ -231,7 +253,16 @@ public class MMChart extends javax.swing.JPanel {
xLegend.repaint(); xLegend.repaint();
}//GEN-LAST:event_formMouseMoved }//GEN-LAST:event_formMouseMoved
private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
System.out.printf("The mouse was clicked\n");
}//GEN-LAST:event_formMouseClicked
private void formMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_formMouseWheelMoved
System.out.printf("Wheel!!!\n");
}//GEN-LAST:event_formMouseWheelMoved
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPopupMenu popupMenu;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -3,6 +3,7 @@
<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.JPanelFormInfo">
<Events> <Events>
<EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="formMouseMoved"/> <EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="formMouseMoved"/>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseExited"/> <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseExited"/>
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseEntered"/> <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseEntered"/>
</Events> </Events>

View File

@ -31,7 +31,7 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
public ChartPanel() { public ChartPanel() {
initComponents(); initComponents();
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); //setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
} }
@ -101,6 +101,9 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
} }
}); });
addMouseListener(new java.awt.event.MouseAdapter() { addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) { public void mouseExited(java.awt.event.MouseEvent evt) {
formMouseExited(evt); formMouseExited(evt);
} }
@ -141,6 +144,10 @@ public class ChartPanel extends javax.swing.JPanel implements AdjustmentListener
repaint(); repaint();
}//GEN-LAST:event_formMouseExited }//GEN-LAST:event_formMouseExited
private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
getParent().dispatchEvent(evt);
}//GEN-LAST:event_formMouseClicked
@Override @Override
public void adjustmentValueChanged(AdjustmentEvent e) { public void adjustmentValueChanged(AdjustmentEvent e) {