import java.awt.*; import javax.swing.*; import java.util.*; /** * The TeamMap class is a subclass of JPanel. This subclass is used for drawing a map of the United States * that displays a specific teams location, and draws lines to the players respective birth cities. **/ public class TeamMap extends JPanel { /**Stores a list of the people that are on the team.**/ private ArrayListpeopleOnTeam=new ArrayList(); /**Stores a key, team members, and a value, latitude and longitude, for the birthcities of the team members.**/ private HashMappoints=new HashMap(); /**Stores the latitude for the home city of the team.**/ private double latitudeTeam; /**Stores the longitude for the home city of the team.**/ private double longitudeTeam; /**Stores the name for the team.**/ private String teamName; /** * Constructor for this class. * @param name Passes in the teams name. * @param lat Passes in the teams home cities latitude. * @param lon Passes in the teams home cities longitude. * @param people Passes in a list of team members. * @param latLon Passes in a hash map of team member names and their latitudes and longitudes. */ public TeamMap(String name, double lat, double lon, ArrayListpeople, HashMaplatLon) { teamName=name; latitudeTeam=lat; longitudeTeam=lon; peopleOnTeam=people; points=latLon; } /** * The paintComponent(Graphics g) method overrides the JPanel's version of this method. This method * is meant for creating the teams map of players birth cities. *

* Algorithm:
* 1. Creates a map of the United States.
* 2. Runs through the points hash map and gets latitudes and longitudes.
* 3. Converts the latitude and longitude into pixel locations.
* 4. Draws a point on the map from step 3.
* 5. Displays the teams location and name.
*

* */ public void paintComponent(Graphics g) { super.paintComponent(g); ImageIcon mapTeam = new ImageIcon("Map1.PNG"); mapTeam.paintIcon(this,g,0,0); Font font = new Font("Comic Sans Serif",Font.PLAIN,9); g.setFont(font); setBackground(Color.white); g.setColor(Color.black); if(!peopleOnTeam.isEmpty() && ! points.isEmpty()) { for(int i=0; i