import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseWheelMovedEvent;
import org.simantics.scenegraph.g2d.events.adapter.AbstractEventAdapter;
+import org.simantics.utils.ui.SWTDPIUtil;
public class SWTMouseEventAdapter extends AbstractEventAdapter implements MouseListener, MouseMoveListener, MouseTrackListener, MouseWheelListener {
private Point2D getControlPosition(MouseEvent e)
{
- return new Point2D.Double(e.x, e.y);
+ return new Point2D.Double(SWTDPIUtil.upscaleSwt(e.x), SWTDPIUtil.upscaleSwt(e.y));
}
private Point2D getScreenPosition(MouseEvent e)
{
- Point p = e.display.getCursorLocation();
+ Point p = SWTDPIUtil.upscaleSwt(e.display.getCursorLocation());
return new Point2D.Double(p.x, p.y);
}
}
public static Point2D upscaleSwt(Point2D p) {
- return upscaleSwt(p.getX(), p.getY());
+ initialize();
+ return (hasSwtScale && p != null) ? upscaleSwt(p.getX(), p.getY()) : p;
}
public static Point upscaleSwtToInteger(Point2D p) {
}
public static Point upscaleSwt(Point p) {
- return upscaleSwt(p.x, p.y);
+ initialize();
+ return (hasSwtScale && p != null) ? upscaleSwt(p.x, p.y) : p;
}
public static Rectangle2D upscaleSwt(Rectangle2D r, Rectangle2D target) {