• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<!--
3Copyright (c) 2015 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/model/location.html">
9<link rel="import" href="/tracing/model/annotation.html">
10<link rel="import" href="/tracing/ui/annotations/rect_annotation_view.html">
11
12<script>
13'use strict';
14
15tr.exportTo('tr.model', function() {
16
17  function RectAnnotation(start, end) {
18    tr.model.Annotation.apply(this, arguments);
19
20    this.startLocation_ = start; // Location of top-left corner.
21    this.endLocation_ = end; // Location of bottom-right corner.
22    this.fillStyle = 'rgba(255, 180, 0, 0.3)';
23  }
24
25  RectAnnotation.fromDict = function(dict) {
26    var args = dict.args;
27    var startLoc =
28        new tr.model.Location(args.start.xWorld, args.start.yComponents);
29    var endLoc =
30        new tr.model.Location(args.end.xWorld, args.end.yComponents);
31    return new tr.model.RectAnnotation(startLoc, endLoc);
32  }
33
34  RectAnnotation.prototype = {
35    __proto__: tr.model.Annotation.prototype,
36
37    get startLocation() {
38      return this.startLocation_;
39    },
40
41    get endLocation() {
42      return this.endLocation_;
43    },
44
45    toDict: function() {
46      return {
47        typeName: 'rect',
48        args: {
49          start: this.startLocation.toDict(),
50          end: this.endLocation.toDict()
51        }
52      };
53    },
54
55    createView_: function(viewport) {
56      return new tr.ui.annotations.RectAnnotationView(viewport, this);
57    }
58  };
59
60  tr.model.Annotation.register(RectAnnotation, {typeName: 'rect'});
61
62  return {
63    RectAnnotation: RectAnnotation
64  };
65});
66</script>
67