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
7dcd8115
Commit
7dcd8115
authored
Jun 25, 2015
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid exposing internal classes from the cassowary library
parent
891085b7
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
125 additions
and
125 deletions
+125
-125
cassowary.dart
packages/cassowary/lib/cassowary.dart
+3
-3
constant_member.dart
packages/cassowary/lib/constant_member.dart
+1
-1
equation_member.dart
packages/cassowary/lib/equation_member.dart
+8
-8
expression.dart
packages/cassowary/lib/expression.dart
+11
-11
param.dart
packages/cassowary/lib/param.dart
+1
-1
parser_exception.dart
packages/cassowary/lib/parser_exception.dart
+1
-1
row.dart
packages/cassowary/lib/row.dart
+12
-12
solver.dart
packages/cassowary/lib/solver.dart
+85
-85
symbol.dart
packages/cassowary/lib/symbol.dart
+2
-2
term.dart
packages/cassowary/lib/term.dart
+1
-1
No files found.
packages/cassowary/lib/cassowary.dart
View file @
7dcd8115
// Copyright (c) 2015, <your name>. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// The cassowary library.
library
cassowary
;
part
'constraint.dart'
;
...
...
packages/cassowary/lib/constant_member.dart
View file @
7dcd8115
...
...
@@ -4,7 +4,7 @@
part of
cassowary
;
class
ConstantMember
extends
EquationMember
{
class
ConstantMember
extends
_
EquationMember
{
double
value
=
0.0
;
bool
get
isConstant
=>
true
;
...
...
packages/cassowary/lib/equation_member.dart
View file @
7dcd8115
...
...
@@ -4,26 +4,26 @@
part of
cassowary
;
abstract
class
EquationMember
{
abstract
class
_
EquationMember
{
Expression
asExpression
();
bool
get
isConstant
;
double
get
value
;
Constraint
operator
>=(
EquationMember
m
)
=>
asExpression
()
>=
m
;
Constraint
operator
>=(
_
EquationMember
m
)
=>
asExpression
()
>=
m
;
Constraint
operator
<=(
EquationMember
m
)
=>
asExpression
()
<=
m
;
Constraint
operator
<=(
_
EquationMember
m
)
=>
asExpression
()
<=
m
;
/* Constraint */
operator
==(
EquationMember
m
)
=>
asExpression
()
==
m
;
/* Constraint */
operator
==(
_
EquationMember
m
)
=>
asExpression
()
==
m
;
Expression
operator
+(
EquationMember
m
)
=>
asExpression
()
+
m
;
Expression
operator
+(
_
EquationMember
m
)
=>
asExpression
()
+
m
;
Expression
operator
-(
EquationMember
m
)
=>
asExpression
()
-
m
;
Expression
operator
-(
_
EquationMember
m
)
=>
asExpression
()
-
m
;
Expression
operator
*(
EquationMember
m
)
=>
asExpression
()
*
m
;
Expression
operator
*(
_
EquationMember
m
)
=>
asExpression
()
*
m
;
Expression
operator
/(
EquationMember
m
)
=>
asExpression
()
/
m
;
Expression
operator
/(
_
EquationMember
m
)
=>
asExpression
()
/
m
;
int
get
hashCode
=>
throw
"An equation member is not comparable and cannot be added to collections"
;
...
...
packages/cassowary/lib/expression.dart
View file @
7dcd8115
...
...
@@ -4,7 +4,7 @@
part of
cassowary
;
class
Expression
extends
EquationMember
{
class
Expression
extends
_
EquationMember
{
final
List
<
Term
>
terms
;
final
double
constant
;
...
...
@@ -21,7 +21,7 @@ class Expression extends EquationMember {
Expression
asExpression
()
=>
this
;
Constraint
_createConstraint
(
EquationMember
/* rhs */
value
,
Relation
relation
)
{
_
EquationMember
/* rhs */
value
,
Relation
relation
)
{
if
(
value
is
ConstantMember
)
{
return
new
Constraint
(
new
Expression
(
new
List
.
from
(
terms
),
constant
-
value
.
value
),
...
...
@@ -51,16 +51,16 @@ class Expression extends EquationMember {
return
null
;
}
Constraint
operator
>=(
EquationMember
value
)
=>
Constraint
operator
>=(
_
EquationMember
value
)
=>
_createConstraint
(
value
,
Relation
.
greaterThanOrEqualTo
);
Constraint
operator
<=(
EquationMember
value
)
=>
Constraint
operator
<=(
_
EquationMember
value
)
=>
_createConstraint
(
value
,
Relation
.
lessThanOrEqualTo
);
operator
==(
EquationMember
value
)
=>
operator
==(
_
EquationMember
value
)
=>
_createConstraint
(
value
,
Relation
.
equalTo
);
Expression
operator
+(
EquationMember
m
)
{
Expression
operator
+(
_
EquationMember
m
)
{
if
(
m
is
ConstantMember
)
{
return
new
Expression
(
new
List
.
from
(
terms
),
constant
+
m
.
value
);
}
...
...
@@ -83,7 +83,7 @@ class Expression extends EquationMember {
return
null
;
}
Expression
operator
-(
EquationMember
m
)
{
Expression
operator
-(
_
EquationMember
m
)
{
if
(
m
is
ConstantMember
)
{
return
new
Expression
(
new
List
.
from
(
terms
),
constant
-
m
.
value
);
}
...
...
@@ -109,13 +109,13 @@ class Expression extends EquationMember {
return
null
;
}
EquationMember
_applyMultiplicand
(
double
m
)
{
_
EquationMember
_applyMultiplicand
(
double
m
)
{
var
newTerms
=
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
..
add
(
new
Term
(
term
.
variable
,
term
.
coefficient
*
m
)));
return
new
Expression
(
newTerms
,
constant
*
m
);
}
_Pair
<
Expression
,
double
>
_findMulitplierAndMultiplicand
(
EquationMember
m
)
{
_Pair
<
Expression
,
double
>
_findMulitplierAndMultiplicand
(
_
EquationMember
m
)
{
// At least on of the the two members must be constant for the resulting
// expression to be linear
...
...
@@ -135,7 +135,7 @@ class Expression extends EquationMember {
return
null
;
}
EquationMember
operator
*(
EquationMember
m
)
{
_EquationMember
operator
*(
_
EquationMember
m
)
{
_Pair
<
Expression
,
double
>
args
=
_findMulitplierAndMultiplicand
(
m
);
if
(
args
==
null
)
{
...
...
@@ -147,7 +147,7 @@ class Expression extends EquationMember {
return
args
.
first
.
_applyMultiplicand
(
args
.
second
);
}
EquationMember
operator
/(
EquationMember
m
)
{
_EquationMember
operator
/(
_
EquationMember
m
)
{
if
(!
m
.
isConstant
)
{
throw
new
ParserException
(
"The divisor was not a constant expression"
,
[
this
,
m
]);
...
...
packages/cassowary/lib/param.dart
View file @
7dcd8115
...
...
@@ -4,7 +4,7 @@
part of
cassowary
;
class
Param
extends
EquationMember
{
class
Param
extends
_
EquationMember
{
final
Variable
variable
;
Param
.
withVariable
(
this
.
variable
);
...
...
packages/cassowary/lib/parser_exception.dart
View file @
7dcd8115
...
...
@@ -6,7 +6,7 @@ part of cassowary;
class
ParserException
implements
Exception
{
final
String
message
;
List
<
EquationMember
>
members
;
List
<
_
EquationMember
>
members
;
ParserException
(
this
.
message
,
this
.
members
);
String
toString
()
{
...
...
packages/cassowary/lib/row.dart
View file @
7dcd8115
...
...
@@ -4,18 +4,18 @@
part of
cassowary
;
class
Row
{
final
Map
<
Symbol
,
double
>
cells
;
class
_
Row
{
final
Map
<
_
Symbol
,
double
>
cells
;
double
constant
=
0.0
;
Row
(
this
.
constant
)
:
this
.
cells
=
new
Map
<
Symbol
,
double
>();
Row
.
fromRow
(
Row
row
)
:
this
.
cells
=
new
Map
<
Symbol
,
double
>.
from
(
row
.
cells
),
_Row
(
this
.
constant
)
:
this
.
cells
=
new
Map
<
_
Symbol
,
double
>();
_Row
.
fromRow
(
_
Row
row
)
:
this
.
cells
=
new
Map
<
_
Symbol
,
double
>.
from
(
row
.
cells
),
this
.
constant
=
row
.
constant
;
double
add
(
double
value
)
=>
constant
+=
value
;
void
insertSymbol
(
Symbol
symbol
,
[
double
coefficient
=
1.0
])
{
void
insertSymbol
(
_
Symbol
symbol
,
[
double
coefficient
=
1.0
])
{
double
val
=
_elvis
(
cells
[
symbol
],
0.0
)
+
coefficient
;
if
(
_nearZero
(
val
))
{
...
...
@@ -25,18 +25,18 @@ class Row {
}
}
void
insertRow
(
Row
other
,
[
double
coefficient
=
1.0
])
{
void
insertRow
(
_
Row
other
,
[
double
coefficient
=
1.0
])
{
constant
+=
other
.
constant
*
coefficient
;
other
.
cells
.
forEach
((
s
,
v
)
=>
insertSymbol
(
s
,
v
*
coefficient
));
}
void
removeSymbol
(
Symbol
symbol
)
{
void
removeSymbol
(
_
Symbol
symbol
)
{
cells
.
remove
(
symbol
);
}
void
reverseSign
()
=>
cells
.
forEach
((
s
,
v
)
=>
cells
[
s
]
=
-
v
);
void
solveForSymbol
(
Symbol
symbol
)
{
void
solveForSymbol
(
_
Symbol
symbol
)
{
assert
(
cells
.
containsKey
(
symbol
));
double
coefficient
=
-
1.0
/
cells
[
symbol
];
cells
.
remove
(
symbol
);
...
...
@@ -44,14 +44,14 @@ class Row {
cells
.
forEach
((
s
,
v
)
=>
cells
[
s
]
=
v
*
coefficient
);
}
void
solveForSymbols
(
Symbol
lhs
,
Symbol
rhs
)
{
void
solveForSymbols
(
_Symbol
lhs
,
_
Symbol
rhs
)
{
insertSymbol
(
lhs
,
-
1.0
);
solveForSymbol
(
rhs
);
}
double
coefficientForSymbol
(
Symbol
symbol
)
=>
_elvis
(
cells
[
symbol
],
0.0
);
double
coefficientForSymbol
(
_
Symbol
symbol
)
=>
_elvis
(
cells
[
symbol
],
0.0
);
void
substitute
(
Symbol
symbol
,
Row
row
)
{
void
substitute
(
_Symbol
symbol
,
_
Row
row
)
{
double
coefficient
=
cells
[
symbol
];
if
(
coefficient
==
null
)
{
...
...
packages/cassowary/lib/solver.dart
View file @
7dcd8115
This diff is collapsed.
Click to expand it.
packages/cassowary/lib/symbol.dart
View file @
7dcd8115
...
...
@@ -6,9 +6,9 @@ part of cassowary;
enum
SymbolType
{
invalid
,
external
,
slack
,
error
,
dummy
,
}
class
Symbol
{
class
_
Symbol
{
final
SymbolType
type
;
int
tick
;
Symbol
(
this
.
type
,
this
.
tick
);
_
Symbol
(
this
.
type
,
this
.
tick
);
}
packages/cassowary/lib/term.dart
View file @
7dcd8115
...
...
@@ -4,7 +4,7 @@
part of
cassowary
;
class
Term
extends
EquationMember
{
class
Term
extends
_
EquationMember
{
final
Variable
variable
;
final
double
coefficient
;
...
...
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