import 'package:jadb/_data_ingestion/sql_writable.dart'; /// Enum set in the kvg:position attribute, used by `` elements in the KanjiVG SVG files. enum KanjiPathGroupPosition { upperA, upperB, lower1, lower2, bottom, kamae, kamaec, left, middle, nyo, nyoc, right, tare, tarec, top; static KanjiPathGroupPosition? fromString(String? str) { if (str == null) return null; switch (str) { case '⿵A': return KanjiPathGroupPosition.upperA; case '⿵B': return KanjiPathGroupPosition.upperB; case '⿶1': return KanjiPathGroupPosition.lower1; case '⿶2': return KanjiPathGroupPosition.lower2; case 'bottom': return KanjiPathGroupPosition.bottom; case 'kamae': return KanjiPathGroupPosition.kamae; case 'kamaec': return KanjiPathGroupPosition.kamaec; case 'left': return KanjiPathGroupPosition.left; case 'middle': return KanjiPathGroupPosition.middle; case 'nyo': return KanjiPathGroupPosition.nyo; case 'nyoc': return KanjiPathGroupPosition.nyoc; case 'right': return KanjiPathGroupPosition.right; case 'tare': return KanjiPathGroupPosition.tare; case 'tarec': return KanjiPathGroupPosition.tarec; case 'top': return KanjiPathGroupPosition.top; default: throw ArgumentError('Unknown position: $str'); } } } enum KanjiVGRadical { general, jis, nelson, tradit; static KanjiVGRadical? fromString(String? str) { if (str == null) return null; switch (str) { case 'general': return KanjiVGRadical.general; case 'jis': return KanjiVGRadical.jis; case 'nelson': return KanjiVGRadical.nelson; case 'tradit': return KanjiVGRadical.tradit; default: throw ArgumentError('Unknown radical: $str'); } } } /// Contents of a \ element in the KanjiVG SVG files. class KanjiPathGroupTreeNode extends SQLWritable { final int id; final List children; final String? element; final String? original; final KanjiPathGroupPosition? position; final KanjiVGRadical? radical; final int? part; // Currently unused data. final bool radicalForm; final bool tradForm; final bool partial; final String? variant; KanjiPathGroupTreeNode({ required this.id, this.children = const [], this.element, this.original, this.position, this.radical, this.part, this.variant, this.radicalForm = false, this.tradForm = false, this.partial = false, }); @override Map get sqlValue => { 'groupId': id, 'element': element, 'original': original, 'position': position?.name, 'radical': radical?.name, 'part': part, }; } /// Contents of a `` element in the StrokeNumber's group in the KanjiVG SVG files class KanjiStrokeNumber extends SQLWritable { final int num; final double x; final double y; KanjiStrokeNumber(this.num, this.x, this.y); @override Map get sqlValue => {'strokeNum': num, 'x': x, 'y': y}; } /// Contents of a `` element in the KanjiVG SVG files class KanjiVGPath extends SQLWritable { final int id; final int groupId; final String? type; final String svgPath; KanjiVGPath({ required this.id, required this.groupId, required this.type, required this.svgPath, }); @override Map get sqlValue => { 'pathId': id, 'groupId': groupId, 'type': type, 'svgPath': svgPath, }; } class KanjiVGItem extends SQLWritable { final String character; final List paths; final List strokeNumbers; final List pathGroups; KanjiVGItem({ required this.character, required this.paths, required this.strokeNumbers, required this.pathGroups, }); @override Map get sqlValue => {'character': character}; }