blob: 605f8ab2add10a59533d0fd583f8c20dc8346ea9 [file] [log] [blame]
<!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="/core/trace_model/annotation.html">
<link rel="import" href="/core/tracks/rect_annotation_view.html">
<script>
'use strict';
tv.exportTo('tv.c.trace_model', function() {
function RectAnnotation(start, end) {
tv.c.trace_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 tv.c.Location(args.start.xWorld, args.start.yComponents);
var endLoc =
new tv.c.Location(args.end.xWorld, args.end.yComponents);
return new tv.c.trace_model.RectAnnotation(startLoc, endLoc);
}
RectAnnotation.prototype = {
__proto__: tv.c.trace_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 tv.c.annotations.RectAnnotationView(viewport, this);
}
};
tv.c.trace_model.Annotation.register(RectAnnotation, {typeName: 'rect'});
return {
RectAnnotation: RectAnnotation
};
});
</script>