1 /* 2 * Copyright (C) 2010 Unreal Visualizer Authors 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 package nl.tudelft.goal.ut2004.visualizer.util; 18 19 import java.util.ArrayList; 20 import java.util.Collection; 21 22 import javax.swing.JList; 23 24 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint; 25 import cz.cuni.amis.pogamut.ut2004.communication.worldview.map.Waypoint; 26 27 /** 28 * Wrapper around {@link NavPoint} to make it more human readable in {@link JList}. 29 * 30 * @author Lennard de Rijk 31 * 32 */ 33 public class SelectableNavPoint { 34 35 /** 36 * The {@link NavPoint} wrapped in this object. 37 */ 38 private final Waypoint navPoint; 39 40 /** 41 * 42 * @param navPoint 43 * The {@link NavPoint} to wrap in this object. 44 */ 45 public SelectableNavPoint(Waypoint navPoint) { 46 this.navPoint = navPoint; 47 48 } 49 50 /** 51 * @return the navPoint wrapped in this class. 52 */ 53 public Waypoint getNavPoint() { 54 return navPoint; 55 } 56 57 /** 58 * Represents a {@link NavPoint} in a human readable form. 59 */ 60 @Override 61 public String toString() { 62 String ret = "NavPoint(" + navPoint.getID() + ") Location(" 63 + navPoint.getLocation() + ")"; 64 65 return ret; 66 } 67 68 /** 69 * Transforms a {@link Collection} of {@link NavPoint} into an Array of {@link SelectableNavPoint}. 70 * 71 * @param navCollection 72 * The {@link Collection} of {@link NavPoint} to transform 73 * @return An Array of {@link SelectableNavPoint} 74 */ 75 public static Collection<SelectableNavPoint> getFromNavPointCollection( 76 Collection<Waypoint> navCollection) { 77 Collection<SelectableNavPoint> selectablePoints = new ArrayList<SelectableNavPoint>(navCollection.size()); 78 79 for (Waypoint navPoint : navCollection) { 80 selectablePoints.add(new SelectableNavPoint(navPoint)); 81 } 82 83 return selectablePoints; 84 } 85 86 }