package com.evsuite.abrp; /** * Fourteen-segment letters, as on the time circuits the Time circuits style is drawn after: the * months and the gear words. Pure Java so it can be tested off the car. * * Segments as bits: the outer seven like {@link SevenSegment} (a top, b upper right, c lower * right, d bottom, e lower left, f upper left), the middle bar in two halves (g1 left, g2 * right), and the inner six: h from the upper left corner to the centre, i up the middle, j to * the upper right corner, k to the lower left, l down the middle, m to the lower right. */ final class Segments14 { static final int A = 1, B = 2, C = 4, D = 8, E = 16, F = 32, G1 = 64, G2 = 128, H = 256, I = 512, J = 1024, K = 2048, L = 4096, M = 8192; private Segments14() {} /** The segments a letter, digit or '-' lights; anything else (a space) lights none. */ static int mask(char ch) { switch (Character.toUpperCase(ch)) { case 'A': return A | B | C | E | F | G1 | G2; case 'B': return A | B | C | D | I | L | G2; case 'C': return A | D | E | F; case 'D': return A | B | C | D | I | L; case 'E': return A | D | E | F | G1 | G2; case 'F': return A | E | F | G1; case 'G': return A | C | D | E | F | G2; case 'H': return B | C | E | F | G1 | G2; case 'I': return A | D | I | L; case 'J': return B | C | D | E; case 'K': return E | F | G1 | J | M; case 'L': return D | E | F; case 'M': return B | C | E | F | H | J; case 'N': return B | C | E | F | H | M; case 'O': return A | B | C | D | E | F; case 'P': return A | B | E | F | G1 | G2; case 'R': return A | B | E | F | G1 | G2 | M; case 'S': return A | C | D | F | G1 | G2; case 'T': return A | I | L; case 'U': return B | C | D | E | F; case 'V': return E | F | J | K; case 'W': return B | C | E | F | K | M; case 'Y': return H | J | L; case '0': return A | B | C | D | E | F | J | K; case '1': return B | C; case '2': return A | B | D | E | G1 | G2; case '3': return A | B | C | D | G2; case '4': return B | C | F | G1 | G2; case '5': return A | C | D | F | G1 | G2; case '6': return A | C | D | E | F | G1 | G2; case '7': return A | B | C; case '8': return A | B | C | D | E | F | G1 | G2; case '9': return A | B | C | D | F | G1 | G2; case '-': return G1 | G2; default: return 0; } } /** The three-letter month as the time circuits show it: JAN … DEC; "---" out of range. */ static String month(int month0) { String[] m = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; return month0 >= 0 && month0 < 12 ? m[month0] : "---"; } /** The gear as a three-letter word for the time circuits: PRK, REV, NTL, DRV; "---" unread. */ static String gearWord(Integer gear) { if (gear == null) return "---"; switch (gear) { case 1: return "PRK"; case 2: return "REV"; case 3: return "NTL"; case 4: return "DRV"; default: return "---"; } } }