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 java.util.ArrayList;
15 import java.util.List;
17 import org.eclipse.core.runtime.ListenerList;
20 public abstract class Node implements INode {
21 public transient static long IDCOUNTER = 1;
22 protected transient ParentNode<?> parent = null;
23 protected transient String parentName = null;
24 protected Long id = IDCOUNTER++;
32 public ParentNode<?> getParent() {
38 public String getParentRel() {
42 public void setParent(ParentNode<?> parent, String name) {
44 this.parentName = name;
47 public ParentNode<?> getRootNode() {
48 return parent != null ? parent.getRootNode() : null;
51 public void remove() {
53 parent.removeNode(parentName, this);
57 public void deattach() {
59 parent.deattachNode(parentName, this);
66 public void cleanup() {
68 parent.removeNode(parentName, this);
73 public String toString() {
74 return getClass().getSimpleName();
77 protected ListenerList<NodeListener> listeners = new ListenerList<NodeListener>();
80 public void addListener(NodeListener listener) {
81 listeners.add(listener);
85 public void removeListener(NodeListener listener) {
86 listeners.remove(listener);
90 public ListenerList<NodeListener> getListeners() {
94 protected void firePropertyChanged(String id) {
95 for (NodeListener listener : listeners) {
96 listener.propertyChanged(this, id);