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.vtk.common;
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.simantics.db.Resource;
16 import org.simantics.g3d.scenegraph.IG3DNode;
17 import org.simantics.g3d.scenegraph.base.INode;
18 import org.simantics.objmap.structural.StructuralResource;
22 public class VTKSelectionItem<DBObject> implements IAdaptable{
26 private DBObject resource;
28 public VTKSelectionItem(vtkProp prop, INode node, DBObject res) {
35 public <T> T getAdapter(Class<T> adapter) {
36 if (adapter.isAssignableFrom(Resource.class))
37 if (resource instanceof Resource)
38 return adapter.cast(resource);
41 if (adapter.isAssignableFrom(StructuralResource.class))
42 if (resource instanceof StructuralResource)
43 return adapter.cast(resource);
46 if (adapter.isAssignableFrom(vtkProp.class))
47 return adapter.cast(prop);
48 if (adapter.isAssignableFrom(IG3DNode.class) && node instanceof IG3DNode)
49 return adapter.cast(node);
50 if (adapter.isAssignableFrom(INode.class))
51 return adapter.cast(node);
55 @SuppressWarnings("rawtypes")
57 public boolean equals(Object obj) {
60 if (obj.getClass() != this.getClass())
62 VTKSelectionItem other = (VTKSelectionItem)obj;
64 if (!prop.equals(other.prop))
67 if (!node.equals(other.node))
70 return resource.equals(other.resource);