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 java.awt.geom.Point2D;
\r
15 import java.util.HashMap;
\r
16 import java.util.Map;
\r
18 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
\r
19 import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;
\r
22 * Participant that enables grabbing of canvas.
\r
24 * @See {@link HandPainter} Paints grabbing of canvas
\r
25 * @author Toni Kalajainen
\r
27 public class CanvasGrab extends AbstractCanvasParticipant {
\r
29 @Dependency TransformUtil util;
\r
31 public Map<Integer, PointerInfo> grabInfo = new HashMap<Integer, PointerInfo>();
\r
33 public PointerInfo grabCanvas(int id, Point2D pos)
\r
35 PointerInfo result = new PointerInfo(pos, id);
\r
36 result.currentPos = pos;
\r
37 grabInfo.put(id, result);
\r
41 public void releaseCanvas(int id)
\r
43 grabInfo.remove(id);
\r
46 /** Info of pointers with left button down */
\r
47 public static final class PointerInfo {
\r
48 public final int mouseId;
\r
49 // Anchoring position in control coordinates
\r
50 public Point2D anchorPos;
\r
51 public Point2D currentPos;
\r
52 public PointerInfo(Point2D anchorPos, int mouseId) {
\r
53 this.anchorPos = anchorPos;
\r
54 this.mouseId = mouseId;
\r
58 public Map<Integer, PointerInfo> getGrabInfo()
\r