| /******************************************************************************* |
| * 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.earth.surface.ui.databindings; |
| |
| import java.util.Date; |
| |
| import org.eclipse.apogy.core.environment.earth.surface.AstronomyUtils; |
| import org.eclipse.core.databinding.conversion.Converter; |
| |
| public class DateToSideralTimeStringConverter extends Converter { |
| private double observerLongitude = 0.0; |
| |
| public DateToSideralTimeStringConverter() { |
| super(Date.class, String.class); |
| } |
| |
| public DateToSideralTimeStringConverter(double observerLongitude) { |
| super(Date.class, String.class); |
| setObserverLongitude(observerLongitude); |
| } |
| |
| public double getObserverLongitude() { |
| return this.observerLongitude; |
| } |
| |
| public void setObserverLongitude(double observerLongitude) { |
| this.observerLongitude = observerLongitude; |
| } |
| |
| @Override |
| public Object convert(Object fromObject) { |
| Date date = (Date) fromObject; |
| double sideralTime = AstronomyUtils.INSTANCE.getLocalSideralTime(date, getObserverLongitude()); |
| return AstronomyUtils.INSTANCE.convertToHHmmssString(sideralTime); |
| } |
| |
| } |