From 045e69a6373714072744d0f891c33fa1f4eb16d3 Mon Sep 17 00:00:00 2001 From: Fan-Wu Yang Date: Wed, 10 May 2017 15:51:55 +1200 Subject: [PATCH] Deleted and Fixed some redundant code - Deleted some unused functions - Fixed NullPointerException for Marks #story[881] #pair[fwy13,jam339] --- .../seng302/Mock/StreamedCourseXMLReader.java | 6 +++- .../main/java/seng302/Mock/StreamedRace.java | 2 +- .../main/java/seng302/Model/BoatInRace.java | 14 --------- .../seng302/Model/ResizableRaceCanvas.java | 30 ------------------- 4 files changed, 6 insertions(+), 46 deletions(-) diff --git a/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java b/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java index c77c716d..c8410562 100644 --- a/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java +++ b/visualiser/src/main/java/seng302/Mock/StreamedCourseXMLReader.java @@ -181,7 +181,11 @@ public class StreamedCourseXMLReader extends XMLReader { } private int getSourceId(Element mark) { - return Integer.parseInt(mark.getAttribute("SourceID")); + String sourceId = mark.getAttribute("SourceID"); + if (sourceId.isEmpty()){ + return 0; + } + return Integer.parseInt(sourceId); } /** diff --git a/visualiser/src/main/java/seng302/Mock/StreamedRace.java b/visualiser/src/main/java/seng302/Mock/StreamedRace.java index a144e0aa..0856cb0c 100644 --- a/visualiser/src/main/java/seng302/Mock/StreamedRace.java +++ b/visualiser/src/main/java/seng302/Mock/StreamedRace.java @@ -113,7 +113,7 @@ public class StreamedRace extends Race { } int sourceID2 = mark.getSourceId2(); BoatLocation boatLocation2 = visualiserInput.getBoatLocationMessage(sourceID2); - if(boatLocation1 != null) { + if(boatLocation2 != null) { double lat = boatLocation2.getLatitudeDouble(); double lon = boatLocation2.getLongitudeDouble(); mark.setCurrentPosition2(new GPSCoordinate(lat, lon)); diff --git a/visualiser/src/main/java/seng302/Model/BoatInRace.java b/visualiser/src/main/java/seng302/Model/BoatInRace.java index 05c58017..274a8000 100644 --- a/visualiser/src/main/java/seng302/Model/BoatInRace.java +++ b/visualiser/src/main/java/seng302/Model/BoatInRace.java @@ -50,20 +50,6 @@ public class BoatInRace extends Boat { position = new SimpleStringProperty("-"); } - /** - * Constructor method. - * - * @param name Name of the boat. - * @param colour Colour the boat will be displayed as on the map - * @param abbrev of boat - */ - public BoatInRace(String name, Color colour, String abbrev) { - super(name, abbrev); - setColour(colour); - currentLegName = new SimpleStringProperty(""); - position = new SimpleStringProperty("-"); - } - /** * Calculates the azimuth of the travel via map coordinates of the raceMarkers * diff --git a/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java b/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java index 83fc7312..e65a45c8 100644 --- a/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java +++ b/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java @@ -31,7 +31,6 @@ public class ResizableRaceCanvas extends ResizableCanvas { private boolean annoPath = true; private List colours; private final List markers; - double[] xpoints = {}, ypoints = {}; private final RaceDataSource raceData; public ResizableRaceCanvas(RaceDataSource raceData) { @@ -77,22 +76,6 @@ public class ResizableRaceCanvas extends ResizableCanvas { this.map = map; } - /** - * Displays the mark of a race as a circle. - * - * @param graphCoordinate Latitude and Longitude in GraphCoordinate that it - * is to be displayed as. - * @param paint Colour the mark is to be coloured. - * @see GraphCoordinate - * @see Color - * @see Paint - */ - public void displayMark(GraphCoordinate graphCoordinate, Paint paint) { - double d = 25; - this.gc.setFill(paint); - gc.fillOval(graphCoordinate.getX() - (d / 2), graphCoordinate.getY() - (d / 2), d, d); - } - private void displayBoat(Boat boat, double angle, Color colour) { if (boat.getCurrentPosition() != null) { GraphCoordinate pos = this.map.convertGPS(boat.getCurrentPosition()); @@ -258,19 +241,6 @@ public class ResizableRaceCanvas extends ResizableCanvas { } } - /** - * Draws a boat at a certain GPSCoordinate - * - * @param colour Colour to colour boat. - * @param gpsCoordinates GPScoordinate that the boat is to be drawn at. - * @see GPSCoordinate - * @see Color - */ - public void drawBoat(Color colour, GPSCoordinate gpsCoordinates) { - GraphCoordinate graphCoordinate = this.map.convertGPS(gpsCoordinates); - displayPoint(graphCoordinate, colour); - } - /** * Toggle the raceAnno value */