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 *******************************************************************************/
14 * @author Toni Kalajainen
16 package org.simantics.scenegraph.g2d.events.adapter;
18 import org.simantics.scenegraph.g2d.events.Event;
19 import org.simantics.scenegraph.g2d.events.EventTypes;
20 import org.simantics.scenegraph.g2d.events.IEventHandler;
21 import org.simantics.scenegraph.g2d.events.IEventQueue;
24 * Adapts SWT, AWT and multitouch events
26 public abstract class AbstractEventAdapter {
28 /** Used for delegating events */
29 protected final IEventHandler delegator;
30 protected final IEventQueue queue;
31 protected final Object sender;
33 public AbstractEventAdapter(Object sender, IEventHandler delegator) {
34 if (delegator == null)
35 throw new IllegalArgumentException("null delegator");
36 this.delegator = delegator;
41 public AbstractEventAdapter(Object sender, IEventQueue queue) {
43 throw new IllegalArgumentException("null event queue");
44 this.delegator = null;
49 protected void handleEvent(Event e) {
52 else if (EventTypes.passes(delegator, e))
53 delegator.handleEvent(e);