Removed boats being able to store colour, this is now down the in the ResizableRaceCanvas. #refactor #story[782]

main
Joseph Gardner 9 years ago
parent f377cf6471
commit 39d3cc7c28

@ -20,8 +20,6 @@ import java.util.*;
public class BoatXMLReader extends XMLReader { public class BoatXMLReader extends XMLReader {
Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>(); Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
Map<Integer, StreamedBoat> participants = new HashMap<>(); Map<Integer, StreamedBoat> participants = new HashMap<>();
private List<Color> colours;
private static int currentColourIndex = 0;
/** /**
* Constructor for Boat XML Reader * Constructor for Boat XML Reader
@ -32,7 +30,6 @@ public class BoatXMLReader extends XMLReader {
*/ */
public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException { public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException {
this(filePath, false); this(filePath, false);
makeColours();
} }
/** /**
@ -45,7 +42,6 @@ public class BoatXMLReader extends XMLReader {
*/ */
public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException { public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException {
super(filePath); super(filePath);
makeColours();
if (read) { if (read) {
read(); read();
} }
@ -82,7 +78,6 @@ public class BoatXMLReader extends XMLReader {
Node boat = nBoats.getChildNodes().item(i); Node boat = nBoats.getChildNodes().item(i);
if (boat.getNodeName().equals("Boat")) { if (boat.getNodeName().equals("Boat")) {
readSingleBoat(boat); readSingleBoat(boat);
currentColourIndex = (currentColourIndex + 1) % colours.size();
} }
} }
} }
@ -109,9 +104,9 @@ public class BoatXMLReader extends XMLReader {
if (!streamedBoatMap.containsKey(sourceID)) { if (!streamedBoatMap.containsKey(sourceID)) {
if (country != null) { if (country != null) {
streamedBoat = new StreamedBoat(sourceID, boatName, colours.get(currentColourIndex), country); streamedBoat = new StreamedBoat(sourceID, boatName, country);
} else { } else {
streamedBoat = new StreamedBoat(sourceID, boatName, colours.get(currentColourIndex), shortName); streamedBoat = new StreamedBoat(sourceID, boatName, shortName);
} }
streamedBoatMap.put(sourceID, streamedBoat); streamedBoatMap.put(sourceID, streamedBoat);
// Override boat with new boat // Override boat with new boat
@ -133,20 +128,6 @@ public class BoatXMLReader extends XMLReader {
// TODO Get relative point before implementing. (GPSposition is based off a relative point). // TODO Get relative point before implementing. (GPSposition is based off a relative point).
} }
private void makeColours() {
colours = new ArrayList<Color>(Arrays.asList(
Color.BLUEVIOLET,
Color.BLACK,
Color.RED,
Color.ORANGE,
Color.DARKOLIVEGREEN,
Color.LIMEGREEN,
Color.PURPLE,
Color.DARKGRAY,
Color.YELLOW
));
}
public void setParticipants(Map<Integer, StreamedBoat> participants) { public void setParticipants(Map<Integer, StreamedBoat> participants) {
this.participants = participants; this.participants = participants;
} }

@ -19,7 +19,7 @@ public class StreamedBoat extends Boat {
this.velocity = 0; this.velocity = 0;
} }
public StreamedBoat(int sourceID, String name, Color colour, String abbrev) { public StreamedBoat(int sourceID, String name, String abbrev) {
super(name, abbrev); super(name, abbrev);
this.sourceID = sourceID; this.sourceID = sourceID;
this.init(); this.init();

Loading…
Cancel
Save