logger.fine("WindowSwing hit");
logger.fine("Pick hit entity = " + ret.entity);
EntityComponent comp = ret.entity.getComponent(WindowSwing.WindowSwingViewReference.class);
assert comp != null;
final View2D view = ((WindowSwing.WindowSwingViewReference) comp).getView();
WindowSwing windowSwing = (WindowSwing) view.getWindow();
// Keep track of the last window we hit
if (lastWindow == null) {
logger.fine("Enter swing");
}
lastWindow = windowSwing;
// TODO: someday: I don't think we need to set this anymore for drag events. But it doesn't hurt.
final Vector3f intersectionPointWorld = ret.destPickDetails.getPosition();
logger.fine("intersectionPointWorld = " + intersectionPointWorld);
if (e.getID() == MouseEvent.MOUSE_PRESSED) {
lastPressPointScreen = new Point(e.getX(), e.getY());
lastPressEventHook = windowSwing.getEventHook();
if (lastPressEventHook != null) {
WindowSwing.EventHookInfo hookInfo = new WindowSwing.EventHookInfo(intersectionPointWorld,
e.getX(), e.getY());
lastPressEventHook.specifyHookInfoForEvent(e, hookInfo);
}
}
final EmbeddedPeer targetEmbeddedPeer = windowSwing.getEmbeddedPeer();
CoordinateHandler coordinateHandler = new CoordinateHandler() {
public EmbeddedPeer getEmbeddedPeer() {
return targetEmbeddedPeer;
}
// Note: event is in frame coordinates
public Point2D transform(Point2D src, Point2D dst, MouseEvent event) {
logger.fine("event = " + event);
logger.fine("src = " + src);
Point pt;
if (event.getID() == MouseEvent.MOUSE_DRAGGED) {
// We will need the event in canvas coordinates
Canvas canvas = JmeClientMain.getFrame().getCanvas();
JFrame frame = (JFrame) event.getSource();
Point framePoint = event.getPoint();
Point canvasPoint = SwingUtilities.convertPoint(frame, framePoint, canvas);
int canvasX = event.getX() + canvasPoint.x - framePoint.x;
int canvasY = event.getY() + canvasPoint.y - framePoint.y;
pt = view.calcIntersectionPixelOfEyeRay(canvasX, canvasY);
if (lastPressEventHook != null) {
WindowSwing.EventHookInfo hookInfo =
new WindowSwing.EventHookInfo(intersectionPointWorld, canvasX, canvasY);
lastPressEventHook.specifyHookInfoForEvent(event, hookInfo);
}
} else {
pt = view.calcPositionInPixelCoordinates(intersectionPointWorld, true);
}
// TODO: temp
if (pt == null) {
logger.severe("pt is null");