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.chassis;
14 import org.simantics.g2d.canvas.ICanvasContext;
15 import org.simantics.utils.datastructures.hints.HintContext;
16 import org.simantics.utils.datastructures.hints.IHintContext;
17 import org.simantics.utils.threads.IThreadWorkQueue;
18 import org.simantics.utils.threads.SyncListenerList;
21 * @author Toni Kalajainen
23 public abstract class AbstractChassis implements ICanvasChassis {
26 protected IHintContext hintCtx = new HintContext();
28 protected SyncListenerList<IChassisListener> listeners = new SyncListenerList<IChassisListener>(IChassisListener.class);
30 protected ICanvasContext canvasContext;
32 public void setCanvasContext(ICanvasContext canvasContext) {
33 assert (this.canvasContext == null);
34 assert (canvasContext != null);
35 this.canvasContext = canvasContext;
36 // Create canvas context and a layer of interactors
37 canvasContext.getHintStack().addHintContext(hintCtx, 0);
41 public ICanvasContext getCanvasContext() {
46 public void addChassisListener(IThreadWorkQueue thread, IChassisListener listener) {
47 listeners.add(thread, listener);
51 public void removeChassisListener(IThreadWorkQueue thread, IChassisListener listener) {
52 listeners.remove(thread, listener);
56 public void addChassisListener(IChassisListener listener) {
57 listeners.add(listener);
61 public void removeChassisListener(IChassisListener listener) {
62 listeners.remove(listener);
66 public IHintContext getHintContext() {