Работа кнопок, стрелки вместо линий, обработка ошибок в основном классе,

This commit is contained in:
Морозов Андрей 2021-11-05 18:43:27 +04:00
parent 856b11d028
commit d965d2e038
8 changed files with 337 additions and 123 deletions

View File

@ -2,3 +2,6 @@ CMD — реализация с коммандным интерфейсом
FLUTTER — реализация с помощью Flutter FLUTTER — реализация с помощью Flutter
Currently in work: Flutter.

View File

@ -1 +1 @@
Application to store graph data. Dart app to store string data in graph

View File

@ -2,7 +2,7 @@
НеОриентированный НеОриентированный
Взвешенный Взвешенный
1: 1|10 2|11 3|10 4|10 1: 1|10 2|11 3|10 4|10
2: 1|11 3|20 2: 1|11
3: 1|10 2|20 3:
4: 1|10 4: 1|10
END END

View File

@ -1,3 +1,4 @@
import 'package:arrow_path/arrow_path.dart';
import 'package:graphs/src/graph.dart'; import 'package:graphs/src/graph.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:math'; import 'dart:math';
@ -22,17 +23,25 @@ class CurvePainter extends CustomPainter {
void drawLine(Canvas canvas, Offset p1, Offset p2) { void drawLine(Canvas canvas, Offset p1, Offset p2) {
Paint p = Paint(); Paint p = Paint();
p.color = col; p.color = col;
p.strokeWidth = width; p.strokeWidth = width - 2;
canvas.drawLine(p1, p2, p); canvas.drawLine(p1, p2, p);
} }
void drawDot(Canvas canvas, Offset p1) { void drawDot(Canvas canvas, Offset p1) {
var p = Paint(); var p = Paint();
p.color = col; p.color = col;
p.strokeWidth = width + 1; p.strokeWidth = width;
canvas.drawCircle(p1, rad, p); canvas.drawCircle(p1, rad, p);
} }
void drawSelfConnect(Canvas canvas, Offset p1) {
var p = Paint();
p.color = col;
p.strokeWidth = width - 2;
p.style = PaintingStyle.stroke;
canvas.drawCircle(Offset(p1.dx + rad + 20, p1.dy), rad + 20, p);
}
TextSpan _getTextSpan(String s) => TextSpan(text: s, style: textStyle); TextSpan _getTextSpan(String s) => TextSpan(text: s, style: textStyle);
TextPainter _getTextPainter(String s) => TextPainter( TextPainter _getTextPainter(String s) => TextPainter(
text: _getTextSpan(s), text: _getTextSpan(s),
@ -71,12 +80,37 @@ class CurvePainter extends CustomPainter {
return off; return off;
} }
void drawArrow(Canvas canvas, Offset from, Offset to,
[bool doubleSided = false]) {
Path path;
// The arrows usually looks better with rounded caps.
Paint paint = Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..strokeJoin = StrokeJoin.round
..strokeWidth = width - 1;
/// Draw a single arrow.
path = Path();
path.moveTo(from.dx, from.dy);
path.relativeCubicTo(0, 0, 0, 0, to.dx - from.dx, to.dy - from.dy);
path =
ArrowPath.make(path: path, isDoubleSided: doubleSided, tipLength: 13);
canvas.drawPath(path, paint);
}
void drawConnections(Canvas canvas, List<Dot> dots, Map<int, Offset> off) { void drawConnections(Canvas canvas, List<Dot> dots, Map<int, Offset> off) {
for (var i in dots) { for (var i in dots) {
var list = i.getL(); var list = i.getL();
var beg = off[i.num]; var beg = off[i.num];
for (var d in list.keys) { for (var d in list.keys) {
drawLine(canvas, beg!, off[d]!); if (d == i.num) {
drawSelfConnect(canvas, off[d]!);
} else {
drawArrow(canvas, beg!, off[d]!, !gr.getDoubleSidedBool());
}
} }
} }
} }
@ -88,7 +122,7 @@ class CurvePainter extends CustomPainter {
} else { } else {
circleRad = size.width / 3; circleRad = size.width / 3;
} }
var paint = Paint(); //var paint = Paint();
//drawLine(canvas, Offset(0, size.height / 2), //drawLine(canvas, Offset(0, size.height / 2),
//Offset(size.width, size.height / 2)); //Offset(size.width, size.height / 2));
@ -100,13 +134,8 @@ class CurvePainter extends CustomPainter {
canvas, off[i + 1]!, "${gr.getDots()[i].getName()}:[${i + 1}]"); canvas, off[i + 1]!, "${gr.getDots()[i].getName()}:[${i + 1}]");
} }
drawConnections(canvas, gr.getDots(), off); drawConnections(canvas, gr.getDots(), off);
//drawArrow(canvas, Offset(size.width / 2, size.height / 2),
paint.color = Colors.blue; // Offset(size.width / 2 + 50, size.height / 2 + 200));
paint.style = PaintingStyle.stroke;
//drawDot(canvas, Offset(size.width / 2, size.height / 2));
//drawAboveText(canvas, size, "sssssssssssss");
//_drawTextAt("Assss", Offset(size.width / 2, size.height / 2), canvas);
paint.color = Colors.green;
} }
@override @override

View File

@ -11,7 +11,7 @@ Graphs getGraph() {
d.add(Dot.fromTwoLists("3", [1, 2], [1, 1])); d.add(Dot.fromTwoLists("3", [1, 2], [1, 1]));
d.add(Dot.fromTwoLists("Name1", [], [])); d.add(Dot.fromTwoLists("Name1", [], []));
d.add(Dot.fromTwoLists("Name2", [], [])); d.add(Dot.fromTwoLists("Name2", [], []));
return Graphs.fromList("1", d, false, false); return Graphs.fromList("1", d, false, true);
} }
class DrawingPage extends StatefulWidget { class DrawingPage extends StatefulWidget {
@ -29,6 +29,7 @@ class _DrawingPageState extends State<DrawingPage> {
final _textNumbController = TextEditingController(); final _textNumbController = TextEditingController();
final _textDestController = TextEditingController(); final _textDestController = TextEditingController();
final _textLnthController = TextEditingController(); final _textLnthController = TextEditingController();
final _textGrNmController = TextEditingController();
void clearTextControllers() { void clearTextControllers() {
_textDestController.clear(); _textDestController.clear();
@ -40,29 +41,37 @@ class _DrawingPageState extends State<DrawingPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
screenSize = MediaQuery.of(context).size.width; screenSize = MediaQuery.of(context).size.width;
_textGrNmController.text = data.getName();
return MaterialApp( return MaterialApp(
home: Scaffold( home: Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text("Graph", title: const Align(
style: TextStyle(fontSize: 30, color: Colors.white)), alignment: Alignment.topLeft,
toolbarHeight: 110, // Set this height child: Text("Graph\n\n",
style: TextStyle(
fontSize: 18,
color: Colors.white,
))),
toolbarHeight: 110,
flexibleSpace: Container( flexibleSpace: Container(
color: Colors.blue, color: Colors.blue,
child: Column(children: <Widget>[ child: Column(children: <Widget>[
const SizedBox(height: 5), const SizedBox(height: 5),
Row(children: [ Row(children: [
addSpaceW(screenSize / 8), addSpaceW(screenSize / 8 + 21),
createButton("\nAdd dot\n", addDotPushed), createButton("\nAdd dot\n", addDotPushed),
createInputBox("Dot name", screenSize / 4 - 25, Icons.label, createInputBox("Dot name", screenSize / 4 - 25, Icons.label,
_textNameController), _textNameController),
addSpaceW(20), addSpaceW(18),
createButton("\nDel dot \n", delDotPushed), createButton("\nDel dot \n", delDotPushed),
createInputBox("Dot number", screenSize / 4 - 25, createInputBox("Dot number", screenSize / 4 - 25,
Icons.fiber_manual_record, _textNumbController), Icons.fiber_manual_record, _textNumbController),
]), ]),
addSpaceH(3), addSpaceH(3),
Row(children: [ Row(children: [
addSpaceW(screenSize / 8 - 4), createInputBox(
"Name", screenSize / 8 - 25, null, _textGrNmController),
//addSpaceW(screenSize / 8 - 4),
createButton("\nAdd path\n", addPathPushed), createButton("\nAdd path\n", addPathPushed),
createInputBox("Input length", screenSize / 4 - 25, createInputBox("Input length", screenSize / 4 - 25,
Icons.arrow_right_alt_outlined, _textLnthController), Icons.arrow_right_alt_outlined, _textLnthController),
@ -87,7 +96,12 @@ class _DrawingPageState extends State<DrawingPage> {
child: ButtonBar( child: ButtonBar(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
createButton("Save to file", () {}), createButton(data.getUseLengthStr(), changeLength),
createButton(data.getDoubleSidedStr(), changeOriented),
/*Text(_textGrNmController.text,
style:
TextStyle(fontSize: 15, color: Colors.blueGrey.shade900)),*/
createButton("Save to file", fileSaver),
createButton("Load from file", fileOpener), createButton("Load from file", fileOpener),
], ],
), ),
@ -109,8 +123,29 @@ class _DrawingPageState extends State<DrawingPage> {
); );
} }
Container createInputBox(String text, double wid, IconData icon, Container createInputBox(String text, double wid, IconData? icon,
TextEditingController controller) { TextEditingController? controller) {
if (icon == null) {
return Container(
width: wid,
height: 40,
margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: TextField(
controller: controller,
textAlign: TextAlign.center,
onChanged: (name) => data.setName(name),
decoration: InputDecoration(
contentPadding:
const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
filled: true,
fillColor: Colors.white,
//prefixIcon: Icon(icon, color: Colors.black),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(40))),
hintStyle: const TextStyle(color: Colors.black38),
hintText: text),
));
}
return Container( return Container(
width: wid, width: wid,
height: 40, height: 40,
@ -142,56 +177,46 @@ class _DrawingPageState extends State<DrawingPage> {
void addDotPushed() { void addDotPushed() {
//showPopUp("Test", "Test message"); //showPopUp("Test", "Test message");
//var inp = int.tryParse(_textNameController.text); //var inp = int.tryParse(_textNameController.text);
if (_textNameController.text == "") { setState(() {
showPopUp("Error", "No name in \"Dot name\" box"); if (_textNameController.text == "") {
} else { showPopUp("Error", "No name in \"Dot name\" box");
String? res = data.addIsolated(_textNameController.text);
if (res != null) {
showPopUp("Error", res);
}
}
clearTextControllers();
}
void addPathPushed() {
if (_textDestController.text == "") {
showPopUp("Error", "No name in \"Dot name\" box");
} else {
String? res = data.addIsolated(_textNameController.text);
if (res != null) {
showPopUp("Error", res);
}
}
clearTextControllers();
}
void delPathPushed() {
if (_textDestController.text == "") {
showPopUp("Error", "No name in \"Dot name\" box");
} else {
String? res = data.addIsolated(_textNameController.text);
if (res != null) {
showPopUp("Error", res);
}
}
clearTextControllers();
}
void delDotPushed() {
if (_textNumbController.text == "") {
showPopUp("Error", "No number in \"Dot number\" box");
} else {
int? dot = int.tryParse(_textNumbController.text);
if (dot == null) {
showPopUp("Error", "Can't parse input.\nInts only allowed");
} else { } else {
String? res = data.delDot(dot); String? res = data.addIsolated(_textNameController.text);
if (res != null) { if (res != null) {
showPopUp("Error", res); showPopUp("Error", res);
} }
} }
} clearTextControllers();
clearTextControllers(); });
}
void addPathPushed() {
setState(() {
if (_textNumbController.text == "") {
showPopUp("Error", "No number in \"Dot number\" box");
} else if (_textDestController.text == "") {
showPopUp("Error", "No name in \"Dot name\" box");
} else if (_textLnthController.text == "" && data.getUseLengthBool()) {
showPopUp("Error", "No length in \"Input length\" box");
} else {
int? from = int.tryParse(_textNumbController.text);
int? to = int.tryParse(_textDestController.text);
int? len = int.tryParse(_textLnthController.text);
if (from == null ||
to == null ||
(len == null && data.getUseLengthBool())) {
showPopUp("Error",
"Can't parse input.\nInts only allowed in \"Dot number\", \"Destination number\" and \"Input length\"");
} else {
if (data.getUseLengthBool() && len == null) len = 0;
String? res = data.addPath(from, to, len!);
if (res != null) {
showPopUp("Error", res);
}
}
}
clearTextControllers();
});
} }
void addLenPushed() { void addLenPushed() {
@ -201,6 +226,62 @@ class _DrawingPageState extends State<DrawingPage> {
clearTextControllers(); clearTextControllers();
} }
void changeOriented() {
setState(() {
String? res = data.flipUseOrientation();
if (res != null) showPopUp("Error", res);
});
}
void changeLength() {
setState(() {
String? res = data.flipUseLength();
if (res != null) showPopUp("Error", res);
});
}
void delPathPushed() {
setState(() {
if (_textNumbController.text == "") {
showPopUp("Error", "No number in \"Dot number\" box");
} else if (_textDestController.text == "") {
showPopUp("Error", "No name in \"Dot name\" box");
} else {
int? from = int.tryParse(_textNumbController.text);
int? to = int.tryParse(_textDestController.text);
if (from == null || to == null) {
showPopUp("Error",
"Can't parse input.\nInts only allowed in \"Dot number\" and \"Destination number\"");
} else {
String? res = data.delPath(from, to);
if (res != null) {
showPopUp("Error", res);
}
}
}
clearTextControllers();
});
}
void delDotPushed() {
setState(() {
if (_textNumbController.text == "") {
showPopUp("Error", "No number in \"Dot number\" box");
} else {
int? dot = int.tryParse(_textNumbController.text);
if (dot == null) {
showPopUp("Error", "Can't parse input.\nInts only allowed");
} else {
String? res = data.delDot(dot);
if (res != null) {
showPopUp("Error", res);
}
}
}
clearTextControllers();
});
}
void showPopUp(String alertTitle, String err) => showDialog<String>( void showPopUp(String alertTitle, String err) => showDialog<String>(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
@ -216,14 +297,34 @@ class _DrawingPageState extends State<DrawingPage> {
); );
void fileOpener() async { void fileOpener() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(); FilePickerResult? result =
await FilePicker.platform.pickFiles(allowedExtensions: ["txt"]);
setState(() {
if (result != null) {
//print(result.files.single.path!);
String? res = data.replaceDataFromFile(result.files.single.path!);
if (res != null) showPopUp("Error", res);
} else {
showPopUp("Error", "No file selected");
// User canceled the picker
}
});
}
if (result != null) { void fileSaver() async {
print(result.files.single.path!); String? outputFile = await FilePicker.platform.saveFile(
data.replaceDataFromFile(result.files.single.path!); dialogTitle: 'Please select an output file:',
} else { fileName: 'output-file.txt',
showPopUp("Error", "No file selected"); allowedExtensions: ["txt"]);
if (outputFile == null) {
showPopUp("Error", "Save cancelled");
// User canceled the picker // User canceled the picker
} else {
if (!outputFile.endsWith(".txt")) {
outputFile += ".txt";
}
data.printToFile(outputFile);
} }
} }

View File

@ -1,15 +1,15 @@
import 'dart:io'; import 'dart:io';
class Separators { class Separators {
final String dotToConnections = ": "; static const String dotToConnections = ": ";
final String dotToLength = "|"; static const String dotToLength = "|";
final String space = " "; static const String space = " ";
final String hasLength = "Взвешенный\n"; static const String hasLength = "Взвешенный";
final String hasNoLength = "НеВзвешенный\n"; static const String hasNoLength = "НеВзвешенный";
final String isOriented = "Ориентированный\n"; static const String isOriented = "Ориентированный";
final String isNotOriented = "НеОриентированный\n"; static const String isNotOriented = "НеОриентированный";
final String nL = "\n"; static const String nL = "\n";
final String end = "END"; static const String end = "END";
Separators(); Separators();
} }
@ -25,6 +25,7 @@ class Dot {
String getName() => _name; String getName() => _name;
bool hasConnection(int n) => _ln.containsKey(n); bool hasConnection(int n) => _ln.containsKey(n);
Map<int, int> getL() => _ln; Map<int, int> getL() => _ln;
int getLength(int x) { int getLength(int x) {
if (hasConnection(x)) { if (hasConnection(x)) {
return _ln[x]!; return _ln[x]!;
@ -146,15 +147,15 @@ class Graphs {
//*********************Add************************ //*********************Add************************
//*********Delete********* //*********Delete*********
bool delPath(int from, int to) { String? delPath(int from, int to) {
if (from <= 0 || from > _amount || to <= 0 && to > _amount) { if (from <= 0 || from > _amount || to <= 0 && to > _amount) {
return false; return "Can't find specified path";
} }
_dots[from - 1].delPath(to); _dots[from - 1].delPath(to);
if (!_oriented) { if (!_oriented) {
_dots[to - 1].delPath(from); _dots[to - 1].delPath(from);
} }
return true; return null;
} }
String? delDot(int inn) { String? delDot(int inn) {
@ -175,7 +176,11 @@ class Graphs {
return null; return null;
} }
void flushData() => _dots = <Dot>[]; void flushData() {
_dots = <Dot>[];
_amount = 0;
_nameTable = <int, String>{};
}
//*********Delete********* //*********Delete*********
//******Helper******* //******Helper*******
@ -246,50 +251,115 @@ class Graphs {
//*****Setters******* //*****Setters*******
void setName(String name) => _name = name; void setName(String name) => _name = name;
String? flipUseOrientation() {
if (_amount != 0) {
return "Can change use of orientation only in empty graph";
}
_oriented = !_oriented;
return null;
}
String? flipUseLength() {
if (_amount != 0) {
return "Can change use of length only in empty graph";
}
_useLength = !_useLength;
return null;
}
String? replaceDataFromFile(String path) { String? replaceDataFromFile(String path) {
Separators sep = Separators();
File file = File(path); File file = File(path);
List<String> lines = file.readAsLinesSync(); List<String> lines = file.readAsLinesSync();
_name = lines.removeAt(0); if (lines.length < 3) {
_oriented = lines.removeAt(0) == sep.isOriented.trim(); return "Not enough lines in file";
_useLength = lines.removeAt(0) == sep.hasLength.trim(); }
_dots = <Dot>[]; String name = lines.removeAt(0);
bool oriented;
switch (lines.removeAt(0)) {
case Separators.isOriented:
oriented = true;
break;
case Separators.isNotOriented:
oriented = false;
break;
default:
return "Error on parsing \"IsOriented\"";
}
bool useLength;
switch (lines.removeAt(0).trim()) {
case Separators.hasLength:
useLength = true;
break;
case Separators.hasNoLength:
useLength = false;
break;
default:
return "Error on parsing \"HasLength\"";
}
List<Dot> dots = <Dot>[];
for (var l in lines) { for (var l in lines) {
l = l.trimRight(); l = l.trimRight();
if (l != sep.end) { if (l != Separators.end) {
var spl = l.split(sep.space); var spl = l.split(Separators.space);
List<int> dot = <int>[]; List<int> dot = <int>[];
List<int> len = <int>[]; List<int> len = <int>[];
String name = spl.removeAt(0); String name = spl.removeAt(0);
name = name.substring(0, name.length - 1); name = name.substring(0, name.length - 1);
for (var splitted in spl) { for (var splitted in spl) {
if (splitted != "") { if (splitted != "") {
var dt = splitted.split(sep.dotToLength); var dt = splitted.split(Separators.dotToLength);
if (dt.length == 2) { if (dt.length == 2) {
dot.add(int.parse(dt[0])); int? parsed = int.tryParse(dt[0]);
if (_useLength) { if (parsed == null) {
len.add(int.parse(dt[1])); return "Error while parsing file\nin parsing int in \"${dt[0]}\"";
}
dot.add(parsed);
if (useLength) {
parsed = int.tryParse(dt[1]);
if (parsed == null) {
return "Error while parsing file\nin parsing int in \"${dt[1]}\"";
}
len.add(parsed);
} else { } else {
len.add(0); len.add(0);
} }
} else if (dt.length == 1) { } else if (dt.length == 1) {
dot.add(int.parse(splitted)); int? parsed = int.tryParse(splitted);
if (parsed == null) {
return "Error while parsing file\nin parsing int in \"$splitted\"";
}
dot.add(parsed);
len.add(0); len.add(0);
} }
} }
} }
_dots.add(Dot.fromTwoLists(name, dot, len)); dots.add(Dot.fromTwoLists(name, dot, len));
} }
} }
_name = name;
_oriented = oriented;
_useLength = useLength;
_dots = dots;
_syncNum(); _syncNum();
_syncNameTable(); _syncNameTable();
if (!_oriented) _fullFix(); if (!_oriented) _fullFix();
return null;
} }
//*****Setters******* //*****Setters*******
//*****Getters******* //*****Getters*******
bool getDoubleSided() => _oriented; bool getDoubleSidedBool() => _oriented;
bool getUseLength() => _useLength; String getDoubleSidedStr() {
if (_oriented) return Separators.isOriented;
return Separators.isNotOriented;
}
bool getUseLengthBool() => _useLength;
String getUseLengthStr() {
if (_useLength) return Separators.hasLength;
return Separators.hasNoLength;
}
List<Dot> getDots() => _dots; List<Dot> getDots() => _dots;
String getName() => _name; String getName() => _name;
String? getNameByNum(int n) => _nameTable[n]; String? getNameByNum(int n) => _nameTable[n];
@ -349,31 +419,34 @@ class Graphs {
} }
void printToFile(String name) { void printToFile(String name) {
Separators sep = Separators();
var file = File(name); var file = File(name);
file.writeAsStringSync("$_name\n"); file.writeAsStringSync("$_name\n");
if (_oriented) { if (_oriented) {
file.writeAsStringSync(sep.isOriented, mode: FileMode.append); file.writeAsStringSync("${Separators.isOriented}\n",
mode: FileMode.append);
} else { } else {
file.writeAsStringSync(sep.isNotOriented, mode: FileMode.append); file.writeAsStringSync("${Separators.isNotOriented}\n",
mode: FileMode.append);
} }
if (_useLength) { if (_useLength) {
file.writeAsStringSync(sep.hasLength, mode: FileMode.append); file.writeAsStringSync("${Separators.hasLength}\n",
mode: FileMode.append);
} else { } else {
file.writeAsStringSync(sep.hasNoLength, mode: FileMode.append); file.writeAsStringSync("${Separators.hasNoLength}\n",
mode: FileMode.append);
} }
for (int i = 0; i < _amount; i++) { for (int i = 0; i < _amount; i++) {
file.writeAsStringSync((i + 1).toString() + sep.dotToConnections, file.writeAsStringSync((i + 1).toString() + Separators.dotToConnections,
mode: FileMode.append); mode: FileMode.append);
var d = _dots[i].getL(); var d = _dots[i].getL();
for (var j in d.keys) { for (var j in d.keys) {
file.writeAsStringSync( file.writeAsStringSync(
j.toString() + sep.dotToLength + d[j].toString() + " ", j.toString() + Separators.dotToLength + d[j].toString() + " ",
mode: FileMode.append); mode: FileMode.append);
} }
file.writeAsStringSync(sep.nL, mode: FileMode.append); file.writeAsStringSync(Separators.nL, mode: FileMode.append);
} }
file.writeAsStringSync(sep.end, mode: FileMode.append); file.writeAsStringSync(Separators.end, mode: FileMode.append);
} }
//******Print****** //******Print******
@ -399,22 +472,22 @@ class Graphs {
if (!_oriented) _fullFix(); if (!_oriented) _fullFix();
} }
Graphs.fromFile(String path) { Graphs.fromFile(String path) {
Separators sep = Separators(); replaceDataFromFile(path);
File file = File(path); /*File file = File(path);
List<String> lines = file.readAsLinesSync(); List<String> lines = file.readAsLinesSync();
_name = lines.removeAt(0); _name = lines.removeAt(0);
_oriented = lines.removeAt(0) == sep.isOriented.trim(); _oriented = lines.removeAt(0) == Separators.isOriented.trim();
_useLength = lines.removeAt(0) == sep.hasLength.trim(); _useLength = lines.removeAt(0) == Separators.hasLength.trim();
_dots = <Dot>[]; _dots = <Dot>[];
for (var l in lines) { for (var l in lines) {
if (l != sep.end) { if (l != Separators.end) {
var spl = l.split(sep.space); var spl = l.split(Separators.space);
List<int> dot = <int>[]; List<int> dot = <int>[];
List<int> len = <int>[]; List<int> len = <int>[];
String name = spl.removeAt(0); String name = spl.removeAt(0);
name = name.substring(0, name.length - 1); name = name.substring(0, name.length - 1);
for (var splitted in spl) { for (var splitted in spl) {
var dt = splitted.split(sep.dotToLength); var dt = splitted.split(Separators.dotToLength);
if (dt.length == 2) { if (dt.length == 2) {
dot.add(int.parse(dt[0])); dot.add(int.parse(dt[0]));
if (_useLength) { if (_useLength) {
@ -432,7 +505,7 @@ class Graphs {
} }
_syncNum(); _syncNum();
_syncNameTable(); _syncNameTable();
if (!_oriented) _fullFix(); if (!_oriented) _fullFix();*/
} }
//*******Constructor******** //*******Constructor********
@ -440,8 +513,8 @@ class Graphs {
Graphs.clone(Graphs a) { Graphs.clone(Graphs a) {
_name = a.getName(); _name = a.getName();
_dots = a.getDots(); _dots = a.getDots();
_oriented = a.getDoubleSided(); _oriented = a.getDoubleSidedBool();
_useLength = a.getUseLength(); _useLength = a.getUseLengthBool();
_amount = _dots.length; _amount = _dots.length;
_syncNameTable(); _syncNameTable();
} }

View File

@ -1,6 +1,13 @@
# Generated by pub # Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
arrow_path:
dependency: "direct main"
description:
name: arrow_path
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
async: async:
dependency: transitive dependency: transitive
description: description:

View File

@ -30,6 +30,7 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
file_picker: ^4.2.0 file_picker: ^4.2.0
arrow_path: ^2.0.0
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.