OLD | NEW |
1 library; | 1 library; |
2 import self as self; | 2 import self as self; |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 | 4 |
5 class DeltaBlue extends core::Object { | 5 class DeltaBlue extends core::Object { |
6 constructor •() → void | 6 default constructor •() → void |
7 : super core::Object::•() | 7 : super core::Object::•() |
8 ; | 8 ; |
9 method run() → void { | 9 method run() → void { |
10 self::chainTest(100); | 10 self::chainTest(100); |
11 self::projectionTest(100); | 11 self::projectionTest(100); |
12 } | 12 } |
13 } | 13 } |
14 class Strength extends core::Object { | 14 class Strength extends core::Object { |
15 final field core::int value; | 15 final field core::int value; |
16 final field core::String name; | 16 final field core::String name; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 this.direction = self::NONE; | 187 this.direction = self::NONE; |
188 } | 188 } |
189 } | 189 } |
190 class ScaleConstraint extends self::BinaryConstraint { | 190 class ScaleConstraint extends self::BinaryConstraint { |
191 final field self::Variable scale; | 191 final field self::Variable scale; |
192 final field self::Variable offset; | 192 final field self::Variable offset; |
193 constructor •(self::Variable src, self::Variable scale, self::Variable offset,
self::Variable dest, self::Strength strength) → void | 193 constructor •(self::Variable src, self::Variable scale, self::Variable offset,
self::Variable dest, self::Strength strength) → void |
194 : self::ScaleConstraint::scale = scale, self::ScaleConstraint::offset = offs
et, super self::BinaryConstraint::•(src, dest, strength) | 194 : self::ScaleConstraint::scale = scale, self::ScaleConstraint::offset = offs
et, super self::BinaryConstraint::•(src, dest, strength) |
195 ; | 195 ; |
196 method addToGraph() → void { | 196 method addToGraph() → void { |
197 this.{=self::BinaryConstraint::addToGraph}(); | 197 super.{self::BinaryConstraint::addToGraph}(); |
198 this.scale.addConstraint(this); | 198 this.scale.addConstraint(this); |
199 this.offset.addConstraint(this); | 199 this.offset.addConstraint(this); |
200 } | 200 } |
201 method removeFromGraph() → void { | 201 method removeFromGraph() → void { |
202 this.{=self::BinaryConstraint::removeFromGraph}(); | 202 super.{self::BinaryConstraint::removeFromGraph}(); |
203 if(!this.scale.==(null)) | 203 if(!this.scale.==(null)) |
204 this.scale.removeConstraint(this); | 204 this.scale.removeConstraint(this); |
205 if(!this.offset.==(null)) | 205 if(!this.offset.==(null)) |
206 this.offset.removeConstraint(this); | 206 this.offset.removeConstraint(this); |
207 } | 207 } |
208 method markInputs(core::int mark) → void { | 208 method markInputs(core::int mark) → void { |
209 this.{=self::BinaryConstraint::markInputs}(mark); | 209 super.{self::BinaryConstraint::markInputs}(mark); |
210 this.scale.mark = this.offset.mark = mark; | 210 this.scale.mark = this.offset.mark = mark; |
211 } | 211 } |
212 method execute() → void { | 212 method execute() → void { |
213 if(this.direction.==(self::FORWARD)) { | 213 if(this.direction.==(self::FORWARD)) { |
214 this.v2.value = this.v1.value.*(this.scale.value).+(this.offset.value); | 214 this.v2.value = this.v1.value.*(this.scale.value).+(this.offset.value); |
215 } | 215 } |
216 else { | 216 else { |
217 this.v1.value = this.v2.value.-(this.offset.value).~/(this.scale.value); | 217 this.v1.value = this.v2.value.-(this.offset.value).~/(this.scale.value); |
218 } | 218 } |
219 } | 219 } |
(...skipping 29 matching lines...) Expand all Loading... |
249 this.constraints.add(c); | 249 this.constraints.add(c); |
250 } | 250 } |
251 method removeConstraint(self::Constraint c) → void { | 251 method removeConstraint(self::Constraint c) → void { |
252 this.constraints.remove(c); | 252 this.constraints.remove(c); |
253 if(this.determinedBy.==(c)) | 253 if(this.determinedBy.==(c)) |
254 this.determinedBy = null; | 254 this.determinedBy = null; |
255 } | 255 } |
256 } | 256 } |
257 class Planner extends core::Object { | 257 class Planner extends core::Object { |
258 field core::int currentMark = 0; | 258 field core::int currentMark = 0; |
259 constructor •() → void | 259 default constructor •() → void |
260 : super core::Object::•() | 260 : super core::Object::•() |
261 ; | 261 ; |
262 method incrementalAdd(self::Constraint c) → void { | 262 method incrementalAdd(self::Constraint c) → void { |
263 core::int mark = this.newMark(); | 263 core::int mark = this.newMark(); |
264 for (self::Constraint overridden = c.satisfy(mark); !overridden.==(null); ov
erridden = overridden.satisfy(mark)) | 264 for (self::Constraint overridden = c.satisfy(mark); !overridden.==(null); ov
erridden = overridden.satisfy(mark)) |
265 ; | 265 ; |
266 } | 266 } |
267 method incrementalRemove(self::Constraint c) → void { | 267 method incrementalRemove(self::Constraint c) → void { |
268 self::Variable out = c.output(); | 268 self::Variable out = c.output(); |
269 c.markUnsatisfied(); | 269 c.markUnsatisfied(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 self::Constraint determining = v.determinedBy; | 346 self::Constraint determining = v.determinedBy; |
347 for (core::int i = 0; i.<(v.constraints.length); i = i.+(1)) { | 347 for (core::int i = 0; i.<(v.constraints.length); i = i.+(1)) { |
348 self::Constraint c = v.constraints.[](i); | 348 self::Constraint c = v.constraints.[](i); |
349 if(!c.==(determining) && c.isSatisfied()) | 349 if(!c.==(determining) && c.isSatisfied()) |
350 coll.add(c); | 350 coll.add(c); |
351 } | 351 } |
352 } | 352 } |
353 } | 353 } |
354 class Plan extends core::Object { | 354 class Plan extends core::Object { |
355 field core::List<self::Constraint> list = <self::Constraint>[]; | 355 field core::List<self::Constraint> list = <self::Constraint>[]; |
356 constructor •() → void | 356 default constructor •() → void |
357 : super core::Object::•() | 357 : super core::Object::•() |
358 ; | 358 ; |
359 method addConstraint(self::Constraint c) → void { | 359 method addConstraint(self::Constraint c) → void { |
360 this.list.add(c); | 360 this.list.add(c); |
361 } | 361 } |
362 method size() → core::int | 362 method size() → core::int |
363 return this.list.length; | 363 return this.list.length; |
364 method execute() → void { | 364 method execute() → void { |
365 for (core::int i = 0; i.<(this.list.length); i = i.+(1)) { | 365 for (core::int i = 0; i.<(this.list.length); i = i.+(1)) { |
366 this.list.[](i).execute(); | 366 this.list.[](i).execute(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 441 } |
442 static method change(self::Variable v, core::int newValue) → void { | 442 static method change(self::Variable v, core::int newValue) → void { |
443 self::EditConstraint edit = new self::EditConstraint::•(v, self::PREFERRED); | 443 self::EditConstraint edit = new self::EditConstraint::•(v, self::PREFERRED); |
444 self::Plan plan = self::planner.extractPlanFromConstraints(<self::EditConstrai
nt>[edit]); | 444 self::Plan plan = self::planner.extractPlanFromConstraints(<self::EditConstrai
nt>[edit]); |
445 for (core::int i = 0; i.<(10); i = i.+(1)) { | 445 for (core::int i = 0; i.<(10); i = i.+(1)) { |
446 v.value = newValue; | 446 v.value = newValue; |
447 plan.execute(); | 447 plan.execute(); |
448 } | 448 } |
449 edit.destroyConstraint(); | 449 edit.destroyConstraint(); |
450 } | 450 } |
OLD | NEW |