123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM IBM Cognos Products: BI Cloud (C)
- * Copyright IBM Corp. 2016, 2017 US Government Users Restricted Rights - Use,
- * duplication or disclosure restricted by GSA ADP Schedule Contract with IBM
- * Corp.
- */
- define(['./PanAndZoomLayout', 'text!./templates/PanAndZoom.html', 'text!./templates/PanAndZoomItems.html'], function (BaseClass, PanAndZoomTemplate, PanAndZoomItemsTemplate) {
- var LayoutTemplate = BaseClass.extend({
- changePageSize: function changePageSize(event) {
- var info = {
- scenePadding: 10,
- height: event.value.height,
- width: event.value.width
- };
- info.offsetWidth = info.width + info.scenePadding;
- info.offsetHeight = info.height + info.scenePadding;
- info.halfOffsetWidth = info.offsetWidth / 2;
- info.halfOffsetHeight = info.offsetHeight / 2;
- this._boxLayoutInfo = info;
- // 0011
- // 0011
- // 2222
- // 2222
- // 2222
- // 2222
- this.sceneLocations = [{
- // 0
- x: 0,
- y: 0,
- scale: 1
- }, {
- // 1
- x: info.offsetWidth,
- y: 0,
- scale: 1
- }, {
- // 2
- x: info.halfOffsetWidth,
- y: info.offsetHeight + info.halfOffsetHeight,
- scale: this._computeTemplateScale(info.width, info.height, info.scenePadding, 2)
- }];
- },
- /**
- * Called to get the location of the center of the specified scene
- *
- * @param index -
- * index of the scene.
- * @param viewport -
- * viewport to scale the scene to
- * @param sceneModel -
- * model to retrieve the size from
- * @return an object with an x, y, and a scale
- *
- */
- _getSceneLocation: function _getSceneLocation(index, viewport) {
- var info = this._boxLayoutInfo;
- var repeatCount = Math.floor(index / 3);
- var layoutBox = this.sceneLocations[index % 3];
- var yOffset = (this.sceneLocations[2].y + info.halfOffsetHeight * 3) * repeatCount;
- var viewportScale = this._computeViewportScale(viewport, info.offsetHeight, info.offsetWidth);
- return {
- x: layoutBox.x * viewportScale,
- y: (layoutBox.y + yOffset) * viewportScale,
- scale: layoutBox.scale,
- height: info.height * viewportScale,
- width: info.width * viewportScale
- };
- },
- /**
- * Called to get the location of the center of the overview
- *
- * @param sceneCount -
- * the number of scenes in the overview.
- * @param viewport -
- * the viewport the overview has to be scaled to.
- * @return an object with an x, y, and a scale
- *
- */
- _getOverviewLocation: function _getOverviewLocation(viewport) {
- var info = this._boxLayoutInfo;
- // first scene is always upper left
- var x1 = info.halfOffsetWidth * -1;
- var y1 = info.halfOffsetHeight * -1;
- var x2 = 0;
- var y2 = 0;
- // The pattern can have 2 widths.
- // 1 scene and 2+ scenes
- if (this.model.items.length === 1) {
- x2 = info.halfOffsetWidth;
- } else {
- x2 = this.sceneLocations[1].x + info.halfOffsetWidth * this.sceneLocations[1].scale;
- }
- // use last scene to figure out how far down we are.
- var lastScene = this._getSceneLocation(this.model.items.length - 1);
- y2 = lastScene.y + info.halfOffsetHeight * lastScene.scale;
- var x = (x2 + x1) / 2;
- var y = (y2 + y1) / 2;
- var xScale = (x2 - x1) / info.offsetWidth;
- var yScale = (y2 - y1) / info.offsetHeight;
- var viewportScale = this._computeViewportScale(viewport, info.offsetHeight, info.offsetWidth);
- return {
- scale: Math.max(xScale, yScale),
- x: x * viewportScale,
- y: y * viewportScale
- };
- }
- });
- /* used by HtmlTemplates.js */
- LayoutTemplate.getTemplate = function () {
- return [PanAndZoomTemplate, PanAndZoomItemsTemplate];
- };
- return LayoutTemplate;
- });
- //# sourceMappingURL=PanAndZoomLayout5.js.map
|