Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: samples-dev/swarm/swarm_ui_lib/touch/Geometry.dart

Issue 2828603002: Format samples and samples-dev directories. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of touch; 5 part of touch;
6 6
7 /** 7 /**
8 * Represents a point in 2 dimensional space. 8 * Represents a point in 2 dimensional space.
9 */ 9 */
10 class Coordinate { 10 class Coordinate {
11
12 /** 11 /**
13 * X-value 12 * X-value
14 */ 13 */
15 num x; 14 num x;
16 15
17 /** 16 /**
18 * Y-value 17 * Y-value
19 */ 18 */
20 num y; 19 num y;
21 20
22 Coordinate([num this.x = 0, num this.y = 0]) { 21 Coordinate([num this.x = 0, num this.y = 0]) {}
23 }
24 22
25 /** 23 /**
26 * Gets the coordinates of a touch's location relative to the window's 24 * Gets the coordinates of a touch's location relative to the window's
27 * viewport. [input] is either a touch object or an event object. 25 * viewport. [input] is either a touch object or an event object.
28 */ 26 */
29 Coordinate.fromClient(var input) : this(input.client.x, input.client.y); 27 Coordinate.fromClient(var input) : this(input.client.x, input.client.y);
30 28
31 static Coordinate difference(Coordinate a, Coordinate b) { 29 static Coordinate difference(Coordinate a, Coordinate b) {
32 return new Coordinate(a.x - b.x, a.y - b.y); 30 return new Coordinate(a.x - b.x, a.y - b.y);
33 } 31 }
(...skipping 25 matching lines...) Expand all
59 */ 57 */
60 Coordinate clone() => new Coordinate(x, y); 58 Coordinate clone() => new Coordinate(x, y);
61 59
62 String toString() => "($x, $y)"; 60 String toString() => "($x, $y)";
63 } 61 }
64 62
65 /** 63 /**
66 * Represents the interval { x | start <= x < end }. 64 * Represents the interval { x | start <= x < end }.
67 */ 65 */
68 class Interval { 66 class Interval {
69
70 final num start; 67 final num start;
71 final num end; 68 final num end;
72 69
73 Interval(num this.start, num this.end) {} 70 Interval(num this.start, num this.end) {}
74 71
75 num get length { 72 num get length {
76 return end - start; 73 return end - start;
77 } 74 }
78 75
79 bool operator ==(Interval other) { 76 bool operator ==(Interval other) {
80 return other != null && other.start == start && other.end == end; 77 return other != null && other.start == start && other.end == end;
81 } 78 }
82 79
83 int get hashCode => throw new UnimplementedError(); 80 int get hashCode => throw new UnimplementedError();
84 81
85 Interval union(Interval other) { 82 Interval union(Interval other) {
86 return new Interval(Math.min(start, other.start), 83 return new Interval(Math.min(start, other.start), Math.max(end, other.end));
87 Math.max(end, other.end));
88 } 84 }
89 85
90 bool contains(num value) { 86 bool contains(num value) {
91 return value >= start && value < end; 87 return value >= start && value < end;
92 } 88 }
93 89
94 String toString() { 90 String toString() {
95 return '(${start}, ${end})'; 91 return '(${start}, ${end})';
96 } 92 }
97 } 93 }
OLDNEW
« no previous file with comments | « samples-dev/swarm/swarm_ui_lib/touch/FxUtil.dart ('k') | samples-dev/swarm/swarm_ui_lib/touch/InfiniteScroller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698