blob: b6bd146ce4298b8e652b7ee9ba3ecc904704346c [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 - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.core.environment.surface.provider;
import java.text.DecimalFormat;
import org.eclipse.apogy.core.environment.surface.ImageMapLayerPresentation;
import org.eclipse.emf.common.notify.AdapterFactory;
public class ImageMapLayerPresentationCustomItemProvider extends ImageMapLayerPresentationItemProvider {
public ImageMapLayerPresentationCustomItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
// FIXME Should be centralized.
protected DecimalFormat alphaDecimalFormat = new DecimalFormat("0.00");
@Override
public String getText(Object object) {
ImageMapLayerPresentation imageMapLayerPresentation = (ImageMapLayerPresentation) object;
String label = null;
if (imageMapLayerPresentation.getName() != null && imageMapLayerPresentation.getName().length() > 0) {
label = imageMapLayerPresentation.getName();
} else {
label = getString("_UI_ImageMapLayerPresentation_type");
}
label += " (" + getImageMapLayerPresentationText(imageMapLayerPresentation) + ")";
return label;
}
protected String getImageMapLayerPresentationText(ImageMapLayerPresentation imageMapLayerPresentation) {
String text = getMapLayerPresentationText(imageMapLayerPresentation);
if (text.length() > 0) {
text += ", ";
}
text += this.alphaDecimalFormat.format(imageMapLayerPresentation.getAlpha());
return text;
}
}