@Override public boolean paint() { final boolean valid = renderer.drawScreenImage(); renderer.drawOverlays(screenImage.image().getGraphics()); imp.draw(); return valid; }
public ImagePlusInteractiveDisplay2D( final int width, final int height, final ScreenImageRenderer renderer, final TransformListener2D renderTransformListener) { sourceToScreen = new AffineTransform2D(); final ColorProcessor cp = new ColorProcessor(width, height); screenImage = new ARGBScreenImage(cp.getWidth(), cp.getHeight(), (int[]) cp.getPixels()); this.renderer = renderer; renderer.screenImageChanged(screenImage); this.renderTransformListener = renderTransformListener; imp = new ImagePlus("argbScreenProjection", cp); imp.show(); imp.getCanvas().setMagnification(1.0); imp.draw(); gui = new GUI(imp); handler = new TransformEventHandler2Dij(imp, this); handler.setWindowCenter(width / 2, height / 2); addHandler(handler); // additional keyboard mappings addHandler( new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_E) { IJ.log(sourceToScreen.toString()); } else if (e.getKeyCode() == KeyEvent.VK_F1) { IJ.showMessage(handler.getHelpString()); } else if (e.getKeyCode() == KeyEvent.VK_PLUS || e.getKeyCode() == KeyEvent.VK_EQUALS) { IJ.run("In [+]"); } else if (e.getKeyCode() == KeyEvent.VK_MINUS) { IJ.run("Out [-]"); } } @Override public void keyTyped(final KeyEvent e) {} @Override public void keyReleased(final KeyEvent e) {} }); }