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

Side by Side Diff: runtime/bin/vmstats/bargraph.dart

Issue 16154017: Rename RuntimeError to CyclicIntializationError, as per spec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart.vmstats; 5 part of dart.vmstats;
6 6
7 class BarGraph { 7 class BarGraph {
8 CanvasElement _canvas; 8 CanvasElement _canvas;
9 GraphModel _model; 9 GraphModel _model;
10 List<Element> _elements; 10 List<Element> _elements;
(...skipping 13 matching lines...) Expand all
24 BarGraph(this._canvas, this._elements) { 24 BarGraph(this._canvas, this._elements) {
25 var maxElements = 25 var maxElements =
26 (_canvas.width - LEFT_MARGIN - RIGHT_MARGIN) ~/ SAMPLE_WIDTH; 26 (_canvas.width - LEFT_MARGIN - RIGHT_MARGIN) ~/ SAMPLE_WIDTH;
27 _model = new GraphModel(maxElements); 27 _model = new GraphModel(maxElements);
28 _model.addListener(drawGraph, null); 28 _model.addListener(drawGraph, null);
29 drawBarGraph(); 29 drawBarGraph();
30 } 30 }
31 31
32 void addSample(List<int> segments) { 32 void addSample(List<int> segments) {
33 if (segments.length != _elements.length) { 33 if (segments.length != _elements.length) {
34 throw new RuntimeError('invalid sample size for graph'); 34 throw new ArgumentError('invalid sample size for graph');
35 } 35 }
36 _model.addSample(segments); 36 _model.addSample(segments);
37 } 37 }
38 38
39 void drawBarGraph() { 39 void drawBarGraph() {
40 // Draw chart's outer box. 40 // Draw chart's outer box.
41 var context = _canvas.context2D; 41 var context = _canvas.context2D;
42 context.beginPath(); 42 context.beginPath();
43 context.strokeStyle = 'black'; 43 context.strokeStyle = 'black';
44 // The '2's are the width of the line, even though 1 is specified. 44 // The '2's are the width of the line, even though 1 is specified.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 int get length => _segments.length; 217 int get length => _segments.length;
218 int operator[](int i) => _segments[i]; 218 int operator[](int i) => _segments[i];
219 219
220 Iterator<int> get iterator => _segments.iterator; 220 Iterator<int> get iterator => _segments.iterator;
221 221
222 int total() { 222 int total() {
223 return _segments.fold(0, (int prev, int element) => prev + element); 223 return _segments.fold(0, (int prev, int element) => prev + element);
224 } 224 }
225 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698