1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
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.g3d.scenegraph.base;
14 import org.eclipse.core.runtime.ListenerList;
17 public abstract class Node implements INode {
18 public transient static long IDCOUNTER = 1;
19 protected transient ParentNode<?> parent = null;
20 protected transient String parentName = null;
21 protected Long id = IDCOUNTER++;
29 public ParentNode<?> getParent() {
35 public String getParentRel() {
39 public void setParent(ParentNode<?> parent, String name) {
41 this.parentName = name;
44 public ParentNode<?> getRootNode() {
45 return parent != null ? parent.getRootNode() : null;
48 public void remove() {
50 parent.removeNode(parentName, this);
54 public void deattach() {
56 parent.deattachNode(parentName, this);
63 public void cleanup() {
65 parent.removeNode(parentName, this);
70 public String toString() {
71 return getClass().getSimpleName();
74 protected ListenerList<NodeListener> listeners = new ListenerList<NodeListener>();
77 public void addListener(NodeListener listener) {
78 listeners.add(listener);
82 public void removeListener(NodeListener listener) {
83 listeners.remove(listener);
87 public ListenerList<NodeListener> getListeners() {
91 protected void firePropertyChanged(String id) {
92 for (NodeListener listener : listeners) {
93 listener.propertyChanged(this, id);