| /******************************************************************************* |
| * Copyright (c) 2011 IBM Corporation and others. |
| * 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: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.stem.loggers.imagewriter.logger; |
| |
| import org.eclipse.stem.core.graph.DynamicLabel; |
| import org.eclipse.stem.core.graph.DynamicNodeLabel; |
| import org.eclipse.stem.core.model.Decorator; |
| import org.eclipse.stem.definitions.adapters.spatial.geo.LatLong; |
| import org.eclipse.stem.definitions.adapters.spatial.geo.LatLongProvider; |
| import org.eclipse.stem.definitions.adapters.spatial.geo.LatLongProviderAdapter; |
| import org.eclipse.stem.definitions.adapters.spatial.geo.LatLongProviderAdapterFactory; |
| import org.eclipse.stem.ui.views.geographic.map.StemPolygonsList; |
| |
| public class Utils { |
| public static StemPolygonsList getPolygonsForDecorator(Decorator decorator) { |
| |
| StemPolygonsList retValue = null; |
| LatLongProviderAdapter latLongProvider = null; |
| |
| DynamicNodeLabel nodeLabel = null; |
| if (decorator != null) { |
| retValue = new StemPolygonsList(); |
| for (DynamicLabel obj : decorator.getLabelsToUpdate()) { |
| if (obj instanceof DynamicNodeLabel) { |
| nodeLabel = (DynamicNodeLabel) obj; |
| if (latLongProvider == null) { |
| latLongProvider = (LatLongProviderAdapter) LatLongProviderAdapterFactory.INSTANCE |
| .adapt(nodeLabel, LatLongProvider.class); |
| } |
| |
| latLongProvider.setTarget(nodeLabel.getIdentifiable()); |
| LatLong latLong = latLongProvider.getLatLong(); |
| |
| // Any lat/long data for this label? |
| if (latLong.size() > 0) { |
| // adding it to the list of polygons to be drawn |
| retValue.addAll(new StemPolygonsList(latLong, nodeLabel |
| .getIdentifiable())); |
| } // if Any lat/long data for this label |
| } |
| } |
| |
| } |
| |
| return retValue; |
| |
| } |
| |
| } |