X-Git-Url: http://jaekl.net/gitweb/?p=frank.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Ffrank%2FSchedule.java;h=eb8cb2bce26cee168d800d2baef13770ff96c580;hp=edd1b398a602afff7e23aa734d892ee5de6c8a1f;hb=2dcf5c21337e4b12e56c3520828edfc062ce7338;hpb=07c8e189128f4fb3be7f49db75b48cf9e2e3de6e diff --git a/prod/net/jaekl/frank/Schedule.java b/prod/net/jaekl/frank/Schedule.java index edd1b39..eb8cb2b 100644 --- a/prod/net/jaekl/frank/Schedule.java +++ b/prod/net/jaekl/frank/Schedule.java @@ -13,13 +13,15 @@ import net.jaekl.frank.octranspo.StopInfo; import net.jaekl.frank.octranspo.Trip; public class Schedule { - Locale m_locale; - FrankBundle m_bundle; DateFormat m_hourMinFmt; DateFormat m_hourMinSecFmt; + FrankBundle m_bundle; + Locale m_locale; + Style m_style; public Schedule(Locale locale) { m_locale = locale; + m_style = new Style(); m_bundle = FrankBundle.getInst(locale); m_hourMinFmt = new SimpleDateFormat("hh:mma", locale); m_hourMinSecFmt = new SimpleDateFormat("hh:mm:ssa", locale); @@ -40,17 +42,7 @@ public class Schedule { String mapUrl(double latitude, double longitude) { return "http://www.openstreetmap.org/?mlat=" + latitude + "&mlon=" + longitude + "&zoom=15"; } - - void writeStyle(PrintWriter pw) { - pw.println(""); - } - + // Countdown timer that updates time remaining until each bus is expected. void writeScript(PrintWriter pw, String remainArray, int remainCount) { String min = trans(FrankBundle.MINUTES); @@ -70,7 +62,7 @@ public class Schedule { pw.println(" if (remain_delta <= 0) {"); pw.println(" element.innerHTML = \"----\";"); pw.println(" } else {"); - pw.println(" element.innerHTML = (Math.floor(remain_delta / 60)) + \"" + trans(min) + "\";"); + pw.println(" element.innerHTML = (Math.floor(remain_delta / 60)) + \"" + min + "\";"); pw.println(" }"); pw.println(" }"); pw.println("}"); @@ -82,7 +74,7 @@ public class Schedule { pw.println(""); pw.println(""); pw.println("" + title + ""); - writeStyle(pw); + new Style().writeStyle(pw); pw.println(""); } @@ -115,7 +107,7 @@ public class Schedule { Route route = stopInfo.getRoute(routeIdx); for (int tripIdx = 0; tripIdx < route.getNumTrips(); ++tripIdx) { Trip trip = route.getTrip(tripIdx); - boolean isGhost = ((-1) == trip.getAdjAge()); + boolean isGhost = (trip.getAdjAge() < 0); if (isGhost) { // GPS is off. This bus may not exist. pw.println(" "); @@ -133,7 +125,7 @@ public class Schedule { remainArray.append(trip.getAdjTime()); remainCount++; - if (trip.getAdjAge() < 0) { + if (isGhost) { pw.println(" " + trans(FrankBundle.GPS_OFF) + ""); } else {