Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
2f3e5aa7
Commit
2f3e5aa7
authored
Jun 25, 2015
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add toString() overrides to internal solver members
parent
9d075ada
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
135 additions
and
1 deletion
+135
-1
constraint.dart
packages/cassowary/lib/constraint.dart
+25
-0
expression.dart
packages/cassowary/lib/expression.dart
+13
-0
param.dart
packages/cassowary/lib/param.dart
+3
-0
row.dart
packages/cassowary/lib/row.dart
+11
-0
solver.dart
packages/cassowary/lib/solver.dart
+36
-0
symbol.dart
packages/cassowary/lib/symbol.dart
+22
-0
term.dart
packages/cassowary/lib/term.dart
+15
-0
variable.dart
packages/cassowary/lib/variable.dart
+10
-1
No files found.
packages/cassowary/lib/constraint.dart
View file @
2f3e5aa7
...
...
@@ -24,4 +24,29 @@ class Constraint {
required
?
requiredPriority
:
p
.
clamp
(
0.0
,
requiredPriority
-
1.0
);
Constraint
operator
|(
double
p
)
=>
this
..
priority
=
p
;
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
write
(
expression
.
toString
());
switch
(
relation
)
{
case
Relation
.
equalTo
:
buffer
.
write
(
" <= 0 "
);
break
;
case
Relation
.
greaterThanOrEqualTo
:
buffer
.
write
(
" >= 0 "
);
break
;
case
Relation
.
lessThanOrEqualTo
:
buffer
.
write
(
" <= 0 "
);
break
;
}
buffer
.
write
(
" | priority =
${priority}
"
);
if
(
required
)
{
buffer
.
write
(
" (required)"
);
}
return
buffer
.
toString
();
}
}
packages/cassowary/lib/expression.dart
View file @
2f3e5aa7
...
...
@@ -156,4 +156,17 @@ class Expression extends _EquationMember {
return
this
.
_applyMultiplicand
(
1.0
/
m
.
value
);
}
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
();
terms
.
forEach
((
t
)
=>
buffer
.
write
(
"
${t}
"
));
if
(
constant
!=
0.0
)
{
buffer
.
write
(
constant
.
sign
>
0.0
?
"+"
:
"-"
);
buffer
.
write
(
constant
.
abs
());
}
return
buffer
.
toString
();
}
}
packages/cassowary/lib/param.dart
View file @
2f3e5aa7
...
...
@@ -14,5 +14,8 @@ class Param extends _EquationMember {
double
get
value
=>
variable
.
value
;
String
get
name
=>
variable
.
name
;
set
name
(
String
name
)
=>
variable
.
name
=
name
;
Expression
asExpression
()
=>
new
Expression
([
new
Term
(
variable
,
1.0
)],
0.0
);
}
packages/cassowary/lib/row.dart
View file @
2f3e5aa7
...
...
@@ -61,4 +61,15 @@ class _Row {
cells
.
remove
(
symbol
);
insertRow
(
row
,
coefficient
);
}
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
write
(
constant
);
cells
.
forEach
((
symbol
,
value
)
=>
buffer
.
write
(
" + "
+
value
.
toString
()
+
" * "
+
symbol
.
toString
()));
return
buffer
.
toString
();
}
}
packages/cassowary/lib/solver.dart
View file @
2f3e5aa7
...
...
@@ -550,6 +550,42 @@ class Solver {
return
_elvis
(
entering
,
new
_Symbol
(
_SymbolType
.
invalid
,
0
));
}
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
();
String
separator
=
"
\n
~~~~~~~~~"
;
// Objective
buffer
.
writeln
(
separator
+
" Objective"
);
buffer
.
writeln
(
_objective
.
toString
());
// Tableau
buffer
.
writeln
(
separator
+
" Tableau"
);
_rows
.
forEach
((
symbol
,
row
)
{
buffer
.
write
(
symbol
.
toString
());
buffer
.
write
(
" | "
);
buffer
.
writeln
(
row
.
toString
());
});
// Infeasible
buffer
.
writeln
(
separator
+
" Infeasible"
);
_infeasibleRows
.
forEach
((
symbol
)
=>
buffer
.
writeln
(
symbol
.
toString
()));
// Variables
buffer
.
writeln
(
separator
+
" Variables"
);
_vars
.
forEach
((
variable
,
symbol
)
=>
buffer
.
writeln
(
"
${variable.toString()}
=
${symbol.toString()}
"
));
// Edit Variables
buffer
.
writeln
(
separator
+
" Edit Variables"
);
_edits
.
forEach
((
variable
,
editinfo
)
=>
buffer
.
writeln
(
variable
));
// Constraints
buffer
.
writeln
(
separator
+
" Constraints"
);
_constraints
.
forEach
((
constraint
,
_
)
=>
buffer
.
writeln
(
constraint
));
return
buffer
.
toString
();
}
}
class
_Tag
{
...
...
packages/cassowary/lib/symbol.dart
View file @
2f3e5aa7
...
...
@@ -11,4 +11,26 @@ class _Symbol {
int
tick
;
_Symbol
(
this
.
type
,
this
.
tick
);
String
toString
()
{
String
typeString
=
"unknown"
;
switch
(
type
)
{
case
_SymbolType
.
invalid
:
typeString
=
"i"
;
break
;
case
_SymbolType
.
external
:
typeString
=
"v"
;
break
;
case
_SymbolType
.
slack
:
typeString
=
"s"
;
break
;
case
_SymbolType
.
error
:
typeString
=
"e"
;
break
;
case
_SymbolType
.
dummy
:
typeString
=
"d"
;
break
;
}
return
"
${typeString}${tick}
"
;
}
}
packages/cassowary/lib/term.dart
View file @
2f3e5aa7
...
...
@@ -16,4 +16,19 @@ class Term extends _EquationMember {
Expression
asExpression
()
=>
new
Expression
([
new
Term
(
this
.
variable
,
this
.
coefficient
)],
0.0
);
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
write
(
coefficient
.
sign
>
0.0
?
"+"
:
"-"
);
if
(
coefficient
.
abs
()
!=
1.0
)
{
buffer
.
write
(
coefficient
.
abs
());
buffer
.
write
(
"*"
);
}
buffer
.
write
(
variable
);
return
buffer
.
toString
();
}
}
packages/cassowary/lib/variable.dart
View file @
2f3e5aa7
...
...
@@ -6,7 +6,16 @@ part of cassowary;
class
Variable
{
double
value
=
0.0
;
Variable
(
this
.
value
);
String
name
;
int
_tick
;
static
int
_total
=
0
;
Variable
(
this
.
value
)
:
_tick
=
_total
++;
// TODO(csg): Add external variable update callbacks here
String
get
debugName
=>
_elvis
(
name
,
"variable
${_tick}
"
);
String
toString
()
=>
"
${debugName}
(=
${value}
)"
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment