blob: 972eb242f6a8ec7dac0eeecd61fa7749015cf0b9 [file] [log] [blame]
/*******************************************************************************
* 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,
* Sebastien Gemme - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.core.environment.provider;
import java.text.DecimalFormat;
import org.eclipse.apogy.core.environment.Star;
import org.eclipse.emf.common.notify.AdapterFactory;
public class StarCustomItemProvider extends StarItemProvider {
// FIXME Should be centralized.
public static final String DEGREE_STRING = "\u00b0";
private final DecimalFormat rightAscensionFormat = new DecimalFormat("0.00");
private final DecimalFormat declinationFormat = new DecimalFormat("0.00");
private final DecimalFormat magnitudeFormat = new DecimalFormat("0.00");
public StarCustomItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
@Override
public String getText(Object object) {
Star star = (Star) object;
String label = "";
if (star.getEquatorialCoordinates() != null) {
label += "r.a. " + this.rightAscensionFormat
.format(Math.toDegrees(star.getEquatorialCoordinates().getRightAscension())) + DEGREE_STRING;
label += ", dec. "
+ this.declinationFormat.format(Math.toDegrees(star.getEquatorialCoordinates().getDeclination()))
+ DEGREE_STRING;
}
label += ", mag. " + this.magnitudeFormat.format(star.getMagnitude()) + "";
return label == null || label.length() == 0 ? getString("_UI_Star_type")
: getString("_UI_Star_type") + " " + label;
}
}