]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/participant/HandPainter.java
Fixed invalid comparisons which were identified by Eclipse IDE 2018-09
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / participant / HandPainter.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.participant;
13
14 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
15 import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;
16 import org.simantics.scenegraph.g2d.events.MouseEvent;
17 import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
18 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonEvent;
19 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
20
21 /**
22  * Paints a grabbed hand when canvas is grabbed.
23  * 
24  * TODO: out of order for now, needs to be adapted to scene graph
25  * 
26  * @author Toni Kalajainen
27  */
28 public class HandPainter extends AbstractCanvasParticipant {
29
30     @Dependency CanvasGrab grab;
31     @Dependency SymbolUtil symbols;
32     @Dependency TransformUtil util;
33     @Dependency MouseUtil mice;
34
35 //    @Painter(priority=PointerPainter.CURSOR_PAINT_PRIORITY+10)
36 //    public void paint(GraphicsContext gc) {
37 //        assertDependencies();
38 //        Map<Integer, PointerInfo> pis = grab.getGrabInfo();
39 //        Collection<MouseInfo> mis = mice.getMiceInfo().values();
40 //        if (mis.isEmpty()) return;
41 //
42 //        // Symbol
43 //        Image grab = symbols.get(DefaultImages.GRAB32, gc.getGraphics2D().getDeviceConfiguration());
44 //        double gcx = grab.getBounds().getCenterX();
45 //        double gcy = grab.getBounds().getCenterY();
46 //        Image hand = symbols.get(DefaultImages.HAND32, gc.getGraphics2D().getDeviceConfiguration());
47 //        double hcx = hand.getBounds().getCenterX();
48 //        double hcy = hand.getBounds().getCenterY();
49 //
50 //        for (MouseInfo mi : mis) {
51 //            GraphicsContext g = gc.clone();
52 //            PointerInfo pi = pis.get(mi.mouseId);
53 //            if (pi!=null) {
54 //                Point2D pos = util.canvasToControl(pi.anchorPos, null);
55 //                g.getGraphics2D().translate(pos.getX(), pos.getY());
56 //                g.getGraphics2D().translate(-gcx, -gcy);
57 //                grab.paint(g);
58 //            } else {
59 //                Point2D pos = mi.controlPosition;
60 //                g.getGraphics2D().translate(pos.getX(), pos.getY());
61 //                g.getGraphics2D().translate(-gcx, -gcy);
62 //                hand.paint(g);
63 //            }
64 //            g.dispose();
65 //        }
66 //    }
67
68     @EventHandler(priority = Integer.MAX_VALUE)
69     public boolean handleMouseEvent(MouseEvent e) {
70         if (e instanceof MouseMovedEvent || e instanceof MouseButtonEvent)
71             setDirty();
72         return false;
73     }
74 }