1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.participant;
\r
14 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
\r
15 import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;
\r
16 import org.simantics.scenegraph.g2d.events.MouseEvent;
\r
17 import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
\r
18 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonEvent;
\r
19 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
\r
22 * Paints a grabbed hand when canvas is grabbed.
\r
24 * TODO: out of order for now, needs to be adapted to scene graph
\r
26 * @author Toni Kalajainen
\r
28 public class HandPainter extends AbstractCanvasParticipant {
\r
30 @Dependency CanvasGrab grab;
\r
31 @Dependency SymbolUtil symbols;
\r
32 @Dependency TransformUtil util;
\r
33 @Dependency MouseUtil mice;
\r
35 // @Painter(priority=PointerPainter.CURSOR_PAINT_PRIORITY+10)
\r
36 // public void paint(GraphicsContext gc) {
\r
37 // assertDependencies();
\r
38 // Map<Integer, PointerInfo> pis = grab.getGrabInfo();
\r
39 // Collection<MouseInfo> mis = mice.getMiceInfo().values();
\r
40 // if (mis.isEmpty()) return;
\r
43 // Image grab = symbols.get(DefaultImages.GRAB32, gc.getGraphics2D().getDeviceConfiguration());
\r
44 // double gcx = grab.getBounds().getCenterX();
\r
45 // double gcy = grab.getBounds().getCenterY();
\r
46 // Image hand = symbols.get(DefaultImages.HAND32, gc.getGraphics2D().getDeviceConfiguration());
\r
47 // double hcx = hand.getBounds().getCenterX();
\r
48 // double hcy = hand.getBounds().getCenterY();
\r
50 // for (MouseInfo mi : mis) {
\r
51 // GraphicsContext g = gc.clone();
\r
52 // PointerInfo pi = pis.get(mi.mouseId);
\r
54 // Point2D pos = util.canvasToControl(pi.anchorPos, null);
\r
55 // g.getGraphics2D().translate(pos.getX(), pos.getY());
\r
56 // g.getGraphics2D().translate(-gcx, -gcy);
\r
59 // Point2D pos = mi.controlPosition;
\r
60 // g.getGraphics2D().translate(pos.getX(), pos.getY());
\r
61 // g.getGraphics2D().translate(-gcx, -gcy);
\r
68 @EventHandler(priority = Integer.MAX_VALUE)
\r
69 public boolean handleMouseEvent(MouseEvent e) {
\r
70 if (e instanceof MouseMovedEvent || e instanceof MouseButtonEvent)
\r