| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/core/location.html"> |
| <link rel="import" href="/model/annotation.html"> |
| <link rel="import" href="/core/tracks/rect_annotation_view.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tr.exportTo('tr.model', function() { |
| |
| function RectAnnotation(start, end) { |
| tr.model.Annotation.apply(this, arguments); |
| |
| this.startLocation_ = start; // Location of top-left corner. |
| this.endLocation_ = end; // Location of bottom-right corner. |
| this.fillStyle = 'rgba(255, 180, 0, 0.3)'; |
| } |
| |
| RectAnnotation.fromDict = function(dict) { |
| var args = dict.args; |
| var startLoc = |
| new tr.c.Location(args.start.xWorld, args.start.yComponents); |
| var endLoc = |
| new tr.c.Location(args.end.xWorld, args.end.yComponents); |
| return new tr.model.RectAnnotation(startLoc, endLoc); |
| } |
| |
| RectAnnotation.prototype = { |
| __proto__: tr.model.Annotation.prototype, |
| |
| get startLocation() { |
| return this.startLocation_; |
| }, |
| |
| get endLocation() { |
| return this.endLocation_; |
| }, |
| |
| toDict: function() { |
| return { |
| typeName: 'rect', |
| args: { |
| start: this.startLocation.toDict(), |
| end: this.endLocation.toDict() |
| } |
| }; |
| }, |
| |
| createView_: function(viewport) { |
| return new tr.c.annotations.RectAnnotationView(viewport, this); |
| } |
| }; |
| |
| tr.model.Annotation.register(RectAnnotation, {typeName: 'rect'}); |
| |
| return { |
| RectAnnotation: RectAnnotation |
| }; |
| }); |
| </script> |