Standalone API 2.7.8
Yes, from your example, it seems to work within an IStrategy construct.
In my case, the standalone client creates the chart, and establishes the
IChartPanelMouseListener using the following steps:
In this code, the instance variables are named for clarity. Code fragments to explain
exactly how the IChartPanelMouseListener is established:
ticksFeedDescriptor = new TicksFeedDescriptor(instrument); // Instrument.EURUSD
ticksFeedDescriptor.setOfferSide(OfferSide.BID);
// ...
ichart = getIClient().openChart(feedDescriptor);
iclientGUI = getIClient().getClientGUI(ichart);
// ...then using SwingUtilities.invokeLater, code passes iclientGUI to the constructor for a JFrame
// ...as shown here
//// SwingUtilities.invokeLater(new Runnable() {
//// public void run() {
//// chartFrame = new JForexChartFrame(iclientGUI);
//// }
//// });
// now, within the JForexChartFrame which extends JFrame constructor code
// ...within that constructor, the IChart instance is fetched **from the iclientGUI** like this:
// ichart and iclientGUI are member variables, not stack variables...
ichart = iclientGUI.getChart();
// code functions perfectly, but adding this mouse listener causes exceptions
ichart.addMouseListener(false, new MyIChartPanelMouseListener()); // synchronous
// code is fine, but when mouse enters the ichart area, exceptions are thrown to console
This is the only exception thrown, and only when mouse is being moved within the charting area.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.dukascopy.charts.wrapper.StrategyThreadDelegatableMouseListener.mouseEntered(StrategyThreadDelegatableMouseListener.java:69)
at com.dukascopy.charts.view.swing.AbstractChartPanelView$1.mouseEntered(AbstractChartPanelView.java:91)
at java.awt.AWTEventMulticaster.mouseEntered(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
// BUG?: adding this mouse listener causes null pointer exceptions
// none of these events occurs
final class MyIChartPanelMouseListener implements IChartPanelMouseListener {
@Override
public void mouseClicked(IChartPanelMouseEvent e) {
// TODO Auto-generated method stub
try {
double price = e.getPrice();
long time = e.getTime();
System.out.println("mouseClicked price: "+price+" date: "+new java.util.Date(time));
}
catch(Exception ex) {
ex.printStackTrace();
}
}
@Override
public void mouseDragged(IChartPanelMouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mouseDragged");
}
@Override
public void mouseEntered(IChartPanelMouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mouseEntered");
}
@Override
public void mouseExited(IChartPanelMouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mouseExited");
}
@Override
public void mouseMoved(IChartPanelMouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mouseMoved");
}
@Override
public void mousePressed(IChartPanelMouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mousePressed");
}
@Override
public void mouseReleased(IChartPanelMouseEvent e) {
// TODO Auto-generated method stub
System.out.println("mouseReleased");
}
}