| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * 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: |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.geometry.data3d.ui.jme3.adapters; |
| |
| import org.eclipse.apogy.common.geometry.data3d.CartesianCoordinatesSet; |
| import org.eclipse.apogy.common.geometry.data3d.ui.jme3.scene_objects.CartesianCoordinatesSetJME3Object; |
| import org.eclipse.apogy.common.topology.ContentNode; |
| import org.eclipse.apogy.common.topology.Node; |
| import org.eclipse.apogy.common.topology.ui.jme3.JME3Adapter; |
| import org.eclipse.apogy.common.topology.ui.jme3.JME3RenderEngineDelegate; |
| import org.eclipse.apogy.common.topology.ui.jme3.JME3SceneObject; |
| |
| /** |
| * JME3 Adapter for ContentNode<CartesianCoordinatesSet> nodes. |
| * |
| * @author pallard |
| */ |
| public class CartesianCoordinateSetJME3Adapter implements JME3Adapter { |
| |
| public CartesianCoordinateSetJME3Adapter() { |
| } |
| |
| @SuppressWarnings("unchecked") |
| @Override |
| public JME3SceneObject getAdapter(Node obj, Object context) { |
| |
| JME3SceneObject object = null; |
| |
| if (isAdapterFor(obj)) { |
| // Context should be an Application |
| if (!(context instanceof JME3RenderEngineDelegate)) { |
| throw new IllegalArgumentException("Context must be a JME3RenderEngineDelegate."); |
| } |
| |
| ContentNode<CartesianCoordinatesSet> cNode = (ContentNode<CartesianCoordinatesSet>) obj; |
| object = new CartesianCoordinatesSetJME3Object<CartesianCoordinatesSet>(cNode, |
| (JME3RenderEngineDelegate) context); |
| } |
| |
| return object; |
| } |
| |
| @Override |
| public boolean isAdapterFor(Node obj) { |
| |
| boolean matches = false; |
| |
| if (obj instanceof ContentNode) { |
| ContentNode<?> node = (ContentNode<?>) obj; |
| matches = node.getContent() instanceof CartesianCoordinatesSet; |
| } |
| |
| return matches; |
| } |
| |
| @Override |
| public Class<?> getAdaptedClass() { |
| return CartesianCoordinatesSet.class; |
| } |
| } |