| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | let JV = require('../jpc_value_define');let JpcAreaHelper = {    outputArea: function(areaNode, band, unitFactor, rowAmount, rowIdx, colAmount, colIdx, multipleDispCol, multipleColIdx,syncHeight, syncWidth) {        let rst = {}, maxMultiColumns = 3;        if (multipleDispCol > 0 && multipleDispCol <= maxMultiColumns) {            //1. calculate left/right            let areaWidth = 1.0 * (band[JV.PROP_RIGHT] - band[JV.PROP_LEFT]) / multipleDispCol;            areaWidth = areaWidth / colAmount;            let innerLeft = 0.0, innerRight = areaWidth;            switch (areaNode[JV.PROP_H_CALCULATION]) {                case JV.CAL_TYPE[JV.CAL_TYPE_PERCENTAGE] :                    innerLeft = (1.0 * areaNode[JV.PROP_LEFT] * areaWidth / JV.HUNDRED_PERCENT);                    innerRight = (1.0 * areaNode[JV.PROP_RIGHT] * areaWidth / JV.HUNDRED_PERCENT) ;                    break;                case JV.CAL_TYPE[JV.CAL_TYPE_ABSTRACT] :                    innerLeft = 1.0 * areaNode[JV.PROP_LEFT] * unitFactor;                    innerRight = 1.0 * areaNode[JV.PROP_RIGHT] * unitFactor ;                    break;            }            //2. calculate top/bottom            let  areaHeight = 1.0 * (band[JV.PROP_BOTTOM] - band[JV.PROP_TOP]);            areaHeight = areaHeight / rowAmount;            let innerTop = 0.0, innerBottom = areaHeight;            switch (areaNode[JV.PROP_V_CALCULATION]) {                case JV.CAL_TYPE[JV.CAL_TYPE_PERCENTAGE] :                    innerTop = (1.0 * areaNode[JV.PROP_TOP] * areaHeight / JV.HUNDRED_PERCENT);                    innerBottom = (1.0 * areaNode[JV.PROP_BOTTOM] * areaHeight / JV.HUNDRED_PERCENT) ;                    break;                case JV.CAL_TYPE[JV.CAL_TYPE_ABSTRACT] :                    innerTop = 1.0 * areaNode[JV.PROP_TOP] * unitFactor;                    innerBottom = 1.0 * areaNode[JV.PROP_BOTTOM] * unitFactor ;                    break;            }            //            let rstLeft = 0.0, rstRight = 0.0, rstTop = 0.0, rstBottom = 0.0;            if (syncHeight) {                rstBottom = Math.round(1.0 * band[JV.PROP_TOP] + areaHeight * (rowIdx + 1) + innerTop);            } else {                rstBottom = Math.round(1.0 * band[JV.PROP_TOP] + areaHeight * rowIdx + innerBottom);            }            if (syncWidth) {                rstRight = Math.round(1.0 * band[JV.PROP_LEFT] + areaWidth * (colIdx + 1) + innerLeft + multipleColIdx * areaWidth);            } else {                rstRight = Math.round(1.0 * band[JV.PROP_LEFT] + areaWidth * colIdx + innerRight + multipleColIdx * areaWidth);            }            rstLeft = Math.round(1.0 * band[JV.PROP_LEFT] + areaWidth * colIdx + innerLeft + multipleColIdx * areaWidth);            rstTop = Math.round(1.0 * band[JV.PROP_TOP] + areaHeight * rowIdx + innerTop);            rst[JV.PROP_LEFT] = rstLeft;            rst[JV.PROP_RIGHT] = rstRight;            rst[JV.PROP_TOP] = rstTop;            rst[JV.PROP_BOTTOM] = rstBottom;        }        return rst;    }};module.exports = JpcAreaHelper;
 |