/* WalkingtoolsGpx: XML, APIs, and Apps for Walking Artists Copyright (C) 2007-2012 Walkingtoools project/B.A.N.G Lab UCSD This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package edu.ucsd.calit2.TransBorderTool; import java.io.IOException; import javax.microedition.location.Coordinates; import javax.microedition.lcdui.Image; /** * The TBCoordinates class extends javax.microedition.location.Coordinates * to include various MetaData * @author Brett Stalbaum and Jason Najarro * @version 0.5.5 */ public class TBCoordinates extends Coordinates { public final int WATER = 0; public final int BEACON = 1; public final int CITY = 2; private String name = ""; private String type = ""; public TBCoordinates(double latitude, double longitude, float altitude, String name, String type) { super(latitude, longitude, altitude); this.name = name; this.type = type; } public TBCoordinates() { super(0, 0, 0); name = ""; type = ""; } // Convert Coordinates to TBCoordinates // /** * @param c * @return */ public static TBCoordinates toMetaCoords(Coordinates c, String name, String type) { TBCoordinates mc = new TBCoordinates(c.getLatitude(), c.getLongitude(), c.getAltitude(), name, type); return mc; } // Convert Coordinates to TBCoordinates // /** * @param c * @return */ public static TBCoordinates toMetaCoords(Coordinates c) { TBCoordinates mc = toMetaCoords(c, "", ""); return mc; } public void setName(String n) { name = n; } /** Set TBCoordinates type * e.g water station, safety beacon, etc. */ public void setType(String t) { type = t; } public String getName() { return name; } public String getType() { return type; } /** Returns image pertaining to MetaCoordinate type */ public Image getIcon() { Image icon = null; try { //System.out.println(this.getType()); if (this.getType().toLowerCase().endsWith("water")) { // matching "Water", "Drinking Water", "N Water...." icon = Image.createImage("/img/water_icon_sm.png"); } else if (this.getType().equalsIgnoreCase("beacon")) { icon = Image.createImage("/img/beacon_icon_sm.png"); } else if (this.getType().equalsIgnoreCase("city")) { icon = Image.createImage("/img/generic_icon_sm.png"); } else { icon = Image.createImage("/img/generic_icon_sm.png"); } } catch (IOException ioe) { System.err.println(ioe); } return icon; } }