// ********************************************************************** // ********************************************************************** package com.bbn.openmap.layer.location.generic; import java.awt.Image; import com.bbn.openmap.omGraphics.OMGraphic; import com.bbn.openmap.omGraphics.OMRaster; import com.bbn.openmap.layer.location.Location; import com.bbn.openmap.layer.location.BasicLocation; import com.bbn.openmap.layer.location.URLRasterLocation; import com.bbn.openmap.layer.location.ImageIconRasterLocation; /** * This class is responsible for producing LocationData */ public class UnitDataFactory implements LocationDataFactory { public UnitDataFactory() {}; // ---------------------- public String[] getLatLonNameArr() { return UnitData.getLatLonNameArr(); } // ------------------------------------ public LocationDataRecord makeLocationData() { return new UnitData(); } // --------------------------------------------------------------------------------------------- public Location makeLocation(float latitude, float longitude, String name, Image locationMarker) { Location retVal = null; if(locationMarker != null) { //retVal = new ImageIconRasterLocation(latitude, longitude, name, locationMarker); retVal = new BasicLocation(latitude, longitude, name, getIconRaster(latitude, longitude, locationMarker)); } else { retVal = new BasicLocation(latitude, longitude, name, null);} return retVal; } // --------------------------------------------------------------------------------------------- public Location makeLocation(float latitude, float longitude, String name, String locationMarker) { Location retVal = null; if(locationMarker != null) { retVal = new URLRasterLocation(latitude, longitude, name, locationMarker);} else { retVal = new BasicLocation(latitude, longitude, name, null);} return retVal; } // --------------------------------------------------------------------------------------------- /** * Create an OMRaster at a latitude/longitude, from a image URL. * * @param lat latitide in decimal degrees * @param lon longitude in decimal degrees. * @param iconURL a URL for an image */ public static OMRaster getIconRaster(float lat, float lon, Image icon) { OMRaster retVal = null; if (icon != null) { int offX = icon.getWidth(null) / 2; int offY = icon.getHeight(null) / 2; retVal = new OMRaster(lat, lon, -(offX+1), -offY, icon); } return retVal; } }