/** * Created by guopeng on 16/8/10. */ // 已废弃, 请从report中获取paper对象调用 import {DesignerHost} from "../design/DesignerHost"; import {Report} from "../items/Report"; import {ReportItemBase} from "../items/ReportItemBase"; import {ReportItem} from "../items/ReportItem" import {PageBand} from "../items/band/PageBand" import {RectF, RectUnit, Unit, SizeF, SizeUnit, PointF} from "../drawing/Unit"; let singletonInstance: PaperHeight; export default class PaperHeight { static instance(): PaperHeight{ if (! singletonInstance) { singletonInstance = new PaperHeight(); } return singletonInstance; } /** * 已占用的高度, 上下边距加上所有bands高度 * @returns {number} */ used(): number{ const report = DesignerHost.instance().designReport.report; const items = report.items; let h = 0; items.forEach(function (_band) { const band = _band as ReportItem; h += band.height.pixels; }) h += report.topMargin.pixels; h += report.bottomMargin.pixels; return h; } /** * 是否占满paper高度 * > 0 为还有空间 * @returns {number} */ isFull(): number{ const report = DesignerHost.instance().designReport.report; return report.height.pixels - this.used(); } canMove(item: ReportItem, bandBound: RectF, mousePoint: PointF, offset: SizeF){ const bandEndPosY = bandBound.y + bandBound.height; const itemEndPosY = mousePoint.y -offset.height + item.height.pixels; if(itemEndPosY < bandEndPosY){ return true; }else{ // if(this.used() + itemEndPosY - bandEndPosY - report.height ) if(itemEndPosY - bandEndPosY - this.isFull() < 0){ return true; } } return false; } }