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.canvas.impl;
14 import org.simantics.g2d.canvas.IMouseCaptureHandle;
15 import org.simantics.g2d.canvas.IMouseCaptureHandleListener;
16 import org.simantics.utils.datastructures.ListenerList;
19 * @author Toni Kalajainen
21 public class MouseCaptureHandle implements IMouseCaptureHandle {
23 boolean released = false;
25 ListenerList<IMouseCaptureHandleListener> listeners;
27 public MouseCaptureHandle(int mouseId)
29 this.mouseId = mouseId;
33 public int mouseId() {
38 public void release() {
46 void fireOnReleased() {
47 ListenerList<IMouseCaptureHandleListener> lis;
50 if (lis==null) return;
53 for (IMouseCaptureHandleListener l : lis.getListeners())
54 l.onCaptureReleased(this);
58 public void removeMouseCaptureHandleListener(IMouseCaptureHandleListener listener) {
59 if (listeners == null) return;
60 listeners.remove(listener);
64 public synchronized void addMouseCaptureHandleListener(IMouseCaptureHandleListener listener) {
65 if (listeners == null) {
66 listeners = new ListenerList<IMouseCaptureHandleListener>(IMouseCaptureHandleListener.class);
68 listeners.add(listener);