| /******************************************************************************* |
| * 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.core.environment.ui.impl; |
| |
| import org.eclipse.apogy.core.environment.ui.Activator; |
| import org.eclipse.apogy.core.environment.ui.ApogyCoreEnvironmentUIPackage; |
| import org.eclipse.apogy.core.environment.ui.preferences.ApogyEnvironmentUIPreferencesConstants; |
| import org.eclipse.apogy.core.environment.ui.scene_objects.StarFieldSceneObject; |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.jface.preference.IPreferenceStore; |
| import org.eclipse.jface.util.IPropertyChangeListener; |
| import org.eclipse.jface.util.PropertyChangeEvent; |
| |
| public class StarFieldPresentationCustomImpl extends StarFieldPresentationImpl { |
| |
| private IPropertyChangeListener iPropertyChangeListener; |
| |
| protected StarFieldPresentationCustomImpl() { |
| super(); |
| |
| Activator.getDefault().getPreferenceStore().addPropertyChangeListener(getIPropertyChangeListener()); |
| } |
| |
| @Override |
| public void setCutOffMagnitude(float newCutOffMagnitude) { |
| super.setCutOffMagnitude(newCutOffMagnitude); |
| |
| StarFieldSceneObject j3DObject = ((StarFieldSceneObject) this.sceneObject); |
| j3DObject.setCutOffMagnitude(newCutOffMagnitude); |
| } |
| |
| @Override |
| public boolean isUseInBoundingCalculation() { |
| return false; |
| } |
| |
| @Override |
| protected void initialSceneObject() { |
| applyPreferences(); |
| super.initialSceneObject(); |
| } |
| |
| @Override |
| protected void applyPreferences() { |
| IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); |
| |
| StarFieldSceneObject starFieldSceneObject = (StarFieldSceneObject) this.sceneObject; |
| starFieldSceneObject.setCutOffMagnitude( |
| preferenceStore.getFloat(ApogyEnvironmentUIPreferencesConstants.DEFAULT_STAR_MAGNITUDE_CUTOFF_ID)); |
| |
| super.applyPreferences(); |
| } |
| |
| @Override |
| protected void updateSceneObject(Notification notification) { |
| if (this.sceneObject != null) { |
| StarFieldSceneObject starFieldSceneObject = (StarFieldSceneObject) this.sceneObject; |
| |
| int featureID = notification.getFeatureID(StarFieldPresentationCustomImpl.class); |
| |
| switch (featureID) { |
| case ApogyCoreEnvironmentUIPackage.STAR_FIELD_PRESENTATION__TRANSPARENCY: |
| starFieldSceneObject.setTransparency(notification.getNewFloatValue()); |
| break; |
| |
| case ApogyCoreEnvironmentUIPackage.STAR_FIELD_PRESENTATION__CUT_OFF_MAGNITUDE: |
| starFieldSceneObject.setCutOffMagnitude(notification.getNewFloatValue()); |
| break; |
| |
| default: |
| break; |
| } |
| } |
| |
| super.updateSceneObject(notification); |
| } |
| |
| protected IPropertyChangeListener getIPropertyChangeListener() { |
| if (this.iPropertyChangeListener == null) { |
| this.iPropertyChangeListener = new IPropertyChangeListener() { |
| @Override |
| public void propertyChange(PropertyChangeEvent event) { |
| applyPreferences(); |
| } |
| }; |
| } |
| |
| return this.iPropertyChangeListener; |
| } |
| |
| } // StarFieldPresentationImpl |