1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.participant;
14 import java.awt.geom.Point2D;
15 import java.util.HashMap;
18 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
19 import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;
22 * Participant that enables grabbing of canvas.
24 * @See {@link HandPainter} Paints grabbing of canvas
25 * @author Toni Kalajainen
27 public class CanvasGrab extends AbstractCanvasParticipant {
29 @Dependency TransformUtil util;
31 public Map<Integer, PointerInfo> grabInfo = new HashMap<Integer, PointerInfo>();
33 public PointerInfo grabCanvas(int id, Point2D pos)
35 PointerInfo result = new PointerInfo(pos, id);
36 result.currentPos = pos;
37 grabInfo.put(id, result);
41 public void releaseCanvas(int id)
46 /** Info of pointers with left button down */
47 public static final class PointerInfo {
48 public final int mouseId;
49 // Anchoring position in control coordinates
50 public Point2D anchorPos;
51 public Point2D currentPos;
52 public PointerInfo(Point2D anchorPos, int mouseId) {
53 this.anchorPos = anchorPos;
54 this.mouseId = mouseId;
58 public Map<Integer, PointerInfo> getGrabInfo()