/** * Returns the status color to be used, depending on whether the vehicle is running early, late, * ontime, or if we don't have real-time info (i.e., scheduled) * * @param delay the deviation from the scheduled time - positive means bus is running late, * negative means early * @return the status color to be used, depending on whether the vehicle is running early, late, * ontime, or if we don't have real-time info (i.e., scheduled) */ public static Color computeColorFromDeviation(final long delay) { // Bus is arriving if (delay > 0) { // Arriving delayed return Color.decode("#504caf"); } else if (delay < 0) { // Arriving early return Color.decode("#af504c"); } else { // Arriving on time return Color.decode("#4CAF50"); } }
/** * Returns the status color to be used, depending on whether the vehicle is running early, late, * ontime, or if we don't have real-time info (i.e., scheduled) * * @param scheduled the scheduled time * @param predicted the predicted time * @return the status color to be used, depending on whether the vehicle is running early, late, * ontime, or if we don't have real-time info (i.e., scheduled) */ public static Color computeColor(final long scheduled, final long predicted) { if (predicted != 0) { return computeColorFromDeviation(predicted - scheduled); } else { // Use scheduled color return Color.decode("#777"); } }