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

Side by Side Diff: packages/charted/lib/core/utils/rect.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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 // 1 //
2 // Copyright 2014 Google Inc. All rights reserved. 2 // Copyright 2014 Google Inc. All rights reserved.
3 // 3 //
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at 5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd 6 // https://developers.google.com/open-source/licenses/bsd
7 // 7 //
8 8
9 part of charted.core.utils; 9 part of charted.core.utils;
10 10
11 /// Interface representing size and position of an element 11 /// Interface representing size and position of an element
12 class Rect { 12 class Rect {
13 final num x; 13 final num x;
14 final num y; 14 final num y;
15 final num width; 15 final num width;
16 final num height; 16 final num height;
17 17
18 const Rect([this.x = 0, this.y = 0, this.width = 0, this.height = 0]); 18 const Rect([this.x = 0, this.y = 0, this.width = 0, this.height = 0]);
19 const Rect.size(this.width, this.height) : x = 0, y = 0; 19 const Rect.size(this.width, this.height)
20 const Rect.position(this.x, this.y) : width = 0, height = 0; 20 : x = 0,
21 21 y = 0;
22 bool operator==(other) => 22 const Rect.position(this.x, this.y)
23 other is Rect && isSameSizeAs(other) && isSamePositionAs(other); 23 : width = 0,
24 height = 0;
24 25
25 bool isSameSizeAs(Rect other) => 26 bool isSameSizeAs(Rect other) =>
26 other != null && width == other.width && height == other.height; 27 other != null && width == other.width && height == other.height;
27 28
28 bool isSamePositionAs(Rect other) => 29 bool isSamePositionAs(Rect other) =>
29 other != null && x == other.x && y == other.y; 30 other != null && x == other.x && y == other.y;
30 31
31 bool contains(num otherX, num otherY) => 32 bool contains(num otherX, num otherY) =>
32 otherX >= x && otherX <= x + width && 33 otherX >= x && otherX <= x + width && otherY >= y && otherY <= y + height;
33 otherY >= y && otherY <= y + height;
34 34
35 String toString() => '$x, $y, $width, $height'; 35 String toString() => '$x, $y, $width, $height';
36
37 @override
38 bool operator ==(other) =>
39 other is Rect && isSameSizeAs(other) && isSamePositionAs(other);
40
41 @override
42 int get hashCode => hash4(x, y, width, height);
36 } 43 }
37 44
38 /// Mutable version of [Rect] class. 45 /// Mutable version of [Rect] class.
39 class MutableRect extends Rect { 46 class MutableRect extends Rect {
40 num x; 47 num x;
41 num y; 48 num y;
42 num width; 49 num width;
43 num height; 50 num height;
44 51
45 MutableRect(this.x, this.y, this.width, this.height); 52 MutableRect(this.x, this.y, this.width, this.height);
46 MutableRect.size(this.width, this.height); 53 MutableRect.size(this.width, this.height);
47 MutableRect.position(this.x, this.y); 54 MutableRect.position(this.x, this.y);
48 } 55 }
49 56
50 class AbsoluteRect { 57 class AbsoluteRect {
51 final num start; 58 final num start;
52 final num end; 59 final num end;
53 final num top; 60 final num top;
54 final num bottom; 61 final num bottom;
55 62
56 const AbsoluteRect(this.top, this.end, this.bottom, this.start); 63 const AbsoluteRect(this.top, this.end, this.bottom, this.start);
57 64
58 bool operator==(other) => 65 @override
59 other is AbsoluteRect && 66 bool operator ==(other) => other is AbsoluteRect &&
60 start == other.start && end == other.end && 67 start == other.start &&
61 top == other.top && bottom == other.bottom; 68 end == other.end &&
62 } 69 top == other.top &&
70 bottom == other.bottom;
71
72 @override
73 int get hashCode => hash4(start, end, top, bottom);
74 }
OLDNEW
« no previous file with comments | « packages/charted/lib/core/utils/object_factory.dart ('k') | packages/charted/lib/layout/src/hierarchy_layout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698