123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- '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;
- this.sceneLocations = [{
- x: 0,
- y: 0,
- scale: 1
- }];
- },
- /**
- * 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) {
- // we are making this, going up to infinity and beyond:
- // (where the number is the scene index/number)
- // (ignore the . they are there for spacing
- // ..45
- // .23
- // 01
- //
- var info = this._boxLayoutInfo;
- var layoutBox = this.sceneLocations[0];
- var x = Math.floor((index + 1) / 2) * info.offsetWidth;
- var y = Math.floor(index / 2) * info.offsetHeight * -1;
- var viewportScale = this._computeViewportScale(viewport, info.offsetHeight, info.offsetWidth);
- return {
- x: x * viewportScale,
- y: y * 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) {
- // first scene is always bottom left
- var x1 = this._boxLayoutInfo.halfOffsetWidth * -1;
- var y1 = this._boxLayoutInfo.halfOffsetHeight;
- // use last scene to figure out how far up/right we are.
- var lastScene = this._getSceneLocation(this.model.items.length - 1);
- var x2 = lastScene.x + this._boxLayoutInfo.halfOffsetWidth;
- var y2 = lastScene.y - this._boxLayoutInfo.halfOffsetHeight;
- var xScale = (x2 - x1) / this._boxLayoutInfo.offsetWidth;
- var yScale = (y2 - y1) / this._boxLayoutInfo.offsetHeight;
- var x = (x2 + x1) / 2;
- var y = (y2 + y1) / 2;
- var viewportScale = this._computeViewportScale(viewport, this._boxLayoutInfo.offsetHeight, this._boxLayoutInfo.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=PanAndZoomLayout2.js.map
|