Hello, I tried playing with a new IScreenLabelChartObject introduced in 3.2.19/API 2.13.43. It seems there is no way to make it work via public API.
My observations are:
1. Invocation of IScreenLabelChartObject.setColor() before setText() causes NullPointerException
2. Invocation of IScreenLabelChartObject.setColor() after setText() - resets text to empty string - ""
3. setText() after setColor() does not make text to show up in actual label - it is empty, however text is correctly displayed in Navigator tree. Right Click (on label in Navigator) -> "Edit Label" shows up "Edit Text" dialog with empty editor.
Below is dummy plugin to reproduce the problem:
package jforex;
import com.dukascopy.api.IChart;
import com.dukascopy.api.JFException;
import com.dukascopy.api.drawings.IChartObjectFactory;
import com.dukascopy.api.drawings.IScreenLabelChartObject;
import com.dukascopy.api.plugins.IPluginContext;
import com.dukascopy.api.plugins.Plugin;
import java.awt.*;
import java.io.PrintStream;
public class MyUiTestPlugin extends Plugin {
@Override
public void onStart(IPluginContext context) throws JFException {
IChart chart = context.getLastActiveChart();
IChartObjectFactory cof = chart.getChartObjectFactory();
Font boldFont = new Font("Arial", Font.BOLD, 11);
PrintStream info = context.getConsole().getInfo();
chart.remove("top-left-key");
chart.remove("top-right-key");
try {
IScreenLabelChartObject label = cof.createScreenLabel("top-left-key");
label.setCorner(IScreenLabelChartObject.Corner.TOP_LEFT);
label.setxDistance(10);
label.setyDistance(10);
label.setText("top-left-text", boldFont);
info.println("text 1: " + label.getText());
label.setColor(Color.RED);
info.println("text 2: " + label.getText());
label.setText("top-left-text");
info.println("text 3: " + label.getText());
chart.add(label);
}
catch( Exception e ) {
e.printStackTrace(context.getConsole().getErr());
}
try {
IScreenLabelChartObject label = cof.createScreenLabel("top-right-key");
label.setCorner(IScreenLabelChartObject.Corner.TOP_RIGHT);
label.setxDistance(10);
label.setyDistance(10);
label.setColor(Color.RED);
label.setText("top-right-text", boldFont);
chart.add(label);
}
catch( Exception e ) {
e.printStackTrace(context.getConsole().getErr());
}
}
@Override
public void onStop() throws JFException {
}
}