X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fscenegraph%2Fbase%2FNode.java;h=6d122930a3e2be155771d4b99d0e313cbf39d7c9;hb=5cd9bf2669ef6907cff73670a393af5355241f56;hp=f7fe9eded0e0d1e606814e5b6556af2da85b5096;hpb=9070983be64f9f107e0a6388549aad475fcd9d76;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/base/Node.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/base/Node.java index f7fe9ede..6d122930 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/base/Node.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/base/Node.java @@ -1,99 +1,100 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g3d.scenegraph.base; - -import java.util.ArrayList; -import java.util.List; - - -public abstract class Node implements INode { - public transient static long IDCOUNTER = 1; - protected transient ParentNode parent = null; - protected transient String parentName = null; - protected Long id = IDCOUNTER++; - - - public Long getId() { - return id; - } - - - public ParentNode getParent() { - return parent; - } - - - @Override - public String getParentRel() { - return parentName; - } - - public void setParent(ParentNode parent, String name) { - this.parent = parent; - this.parentName = name; - } - - public ParentNode getRootNode() { - return parent != null ? parent.getRootNode() : null; - } - - public void remove() { - if (parent != null) { - parent.removeNode(parentName, this); - } - } - - public void deattach() { - if (parent != null) { - parent.deattachNode(parentName, this); - } - } - - public void init() { - } - - public void cleanup() { - if (parent != null) { - parent.removeNode(parentName, this); - } - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } - - protected List listeners = new ArrayList(); - - @Override - public void addListener(NodeListener listener) { - if (!listeners.contains(listener)) - listeners.add(listener); - } - - @Override - public void removeListener(NodeListener listener) { - listeners.remove(listener); - } - - @Override - public List getListeners() { - return listeners; - } - - protected void firePropertyChanged(String id) { - for (NodeListener listener : listeners) { - listener.propertyChanged(this, id); - } - } - -} +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g3d.scenegraph.base; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.ListenerList; + + +public abstract class Node implements INode { + public transient static long IDCOUNTER = 1; + protected transient ParentNode parent = null; + protected transient String parentName = null; + protected Long id = IDCOUNTER++; + + + public Long getId() { + return id; + } + + + public ParentNode getParent() { + return parent; + } + + + @Override + public String getParentRel() { + return parentName; + } + + public void setParent(ParentNode parent, String name) { + this.parent = parent; + this.parentName = name; + } + + public ParentNode getRootNode() { + return parent != null ? parent.getRootNode() : null; + } + + public void remove() { + if (parent != null) { + parent.removeNode(parentName, this); + } + } + + public void deattach() { + if (parent != null) { + parent.deattachNode(parentName, this); + } + } + + public void init() { + } + + public void cleanup() { + if (parent != null) { + parent.removeNode(parentName, this); + } + } + + @Override + public String toString() { + return getClass().getSimpleName(); + } + + protected ListenerList listeners = new ListenerList(); + + @Override + public void addListener(NodeListener listener) { + listeners.add(listener); + } + + @Override + public void removeListener(NodeListener listener) { + listeners.remove(listener); + } + + @Override + public ListenerList getListeners() { + return listeners; + } + + protected void firePropertyChanged(String id) { + for (NodeListener listener : listeners) { + listener.propertyChanged(this, id); + } + } + +}