Canvas.class.cast(owner).addPaintListener(this);
}
@Override
public void paintControl(PaintEvent event) {
final JsrcFile jsrc = context.getJsrcFile(context.getSelectedFile());
if(jsrc == null) {
return;
}
Integer f = context.getSelectedFrame(jsrc.getUuid());
if (f < 0) {
return;
}
Rectangle rectangle = ((Canvas) event.widget).getBounds();
event.gc.setForeground(event.display.getSystemColor(SWT.COLOR_DARK_GRAY));
event.gc.drawFocus(5, 5, rectangle.width - 15, rectangle.height - 15);
try {
JsrcFile.Frame frame = jsrc.readFrame(f);
double size = Double.parseDouble(jsrc.getHeader().getItem("size"));
double halfSize = size*0.5;
for (JsrcFile.Frame.Particle particle : frame.getParticles()) {
int x = (int)(((particle.getRx() + halfSize) / size) * (double)(rectangle.width - 20));
int y = (int)(((halfSize - particle.getRy()) / size) * (double)(rectangle.height - 20));
event.gc.drawOval(x + 10 - 2, y + 10 - 2, 4, 4);