tokenizeSymbol static method
Method to tokenize a SignSymbol into a list of tokens.
Implementation
static List<String> tokenizeSymbol(SignSymbol symbol,
{bool boxPosition = false}) {
if (['B', 'L', 'M', 'R'].contains(symbol.symbol)) {
// If the symbol is a box symbol
List<String> tokens = [symbol.symbol]; // Adding box symbol
if (boxPosition) {
tokens.add("p${symbol.position.item1}"); // Adding x-coordinate
tokens.add("p${symbol.position.item2}"); // Adding y-coordinate
} else {
tokens.add("p500"); // Assuming default position of 500x500
tokens.add("p500"); // Assuming default position of 500x500
}
return tokens;
} else {
// If the symbol is a base symbol
List<String> tokens = [
symbol.symbol.substring(0, 4)
]; // Adding base symbol
int num = int.parse(symbol.symbol.substring(4),
radix: 16); // Parsing symbol number
tokens.add("c${(num ~/ 0x10).toRadixString(16)}"); // Adding column
tokens.add("r${(num % 0x10).toRadixString(16)}"); // Adding row
tokens.add("p${symbol.position.item1}"); // Adding x-coordinate
tokens.add("p${symbol.position.item2}"); // Adding y-coordinate
return tokens;
}
}