⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zdocument.java

📁 用Java写的报表.功能如下: 0.内建网络打印,网络预览功能! 1.文件操作。包括url 指定的文件。 2.全功能打印支持。包括打印预览。 3.Undo 和 redo。 4.合并单元格。 5.Cel
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @param page
     * @return
     */
    public int getPageNumber(ZPage page) {
        return (pages.indexOf(page));
    }

    /**
     * put your documentation comment here
     * @param index
     * @return
     * @exception IndexOutOfBoundsException
     */
    public Printable getPrintable(int index) throws IndexOutOfBoundsException {
        return getPage(index);
    }

    /**
     * put your documentation comment here
     * @return
     */
    public String getTitle() {
        return book.getTitle();
    }

    /**
     * put your documentation comment here
     * @param lst
     */
    public void addListener(ChangeListener lst) {
        listeners.add(lst);
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int recreatePages() {
        pages.clear();

        Point curPos = new Point();
        ZRect imageable = getBodyArea();

        if (imageable.bottom <= imageable.top) {
            return 0;
        }

        for (int i = 0; i < book.getCount(); i++) {
            ZSheet sheet = book.getSheet(i);
            ZRect printableCells = sheet.getPrintableCells();

            if (printableCells == null) {
                continue;
            }

            int row = printableCells.top;
            int col = printableCells.left;

            for (int col1 = col; col1 <= printableCells.right; col1++) {
                // work out how many columns should be printed in this page
                curPos.x = 0;

                while (col1 <= printableCells.right) {
                    curPos.x += sheet.getColWidth(col1);

                    if (curPos.x > imageable.getWidth()) {
                        break;
                    }

                    col1++;
                }

                col1--;

                // work out how many rows in this page
                for (int row1 = row; row1 <= printableCells.bottom; row1++) {
                    curPos.y = 0;

                    while (row1 <= printableCells.bottom) {
                        curPos.y += sheet.getRowHeight(row1);

                        if (curPos.y > imageable.getHeight()) {
                            break;
                        }

                        row1++;
                    }

                    row1--;

                    ZPrintableCells pcs = new ZPrintableCells(sheet, new ZRect(col, row, col1, row1), imageable);

                    if ((printableCells.left == col) && (printableCells.top == row)) {
                        header = pcs;
                        footer = pcs;
                    }

                    pages.add(new ZPage(this, pcs));
                    row = row1 + 1;
                }

                col = col1 + 1;
                row = printableCells.top;
            }
        }

        ZScriptEngine.getSharedInstance().put(ZScriptEngine.PAGE_COUNT, String.valueOf(pages.size()));

        updateFormat();

        return pages.size();
    }

    /**
     * put your documentation comment here
     * @param lst
     */
    public void removeListener(ChangeListener lst) {
        listeners.remove(lst);
    }

    /**
     * put your documentation comment here
     * @param comp
     */
    void setComponent(JComponent comp) {
        if (headerCanvas != null) {
            headerCanvas.setComponent(comp);
        }

        if (bodyCanvas != null) {
            bodyCanvas.setComponent(comp);
        }

        if (footerCanvas != null) {
            footerCanvas.setComponent(comp);
        }

        updateFormat();
    }

    /**
     * put your documentation comment here
     * @param control
     */
    void setControl(ZSheetStateControl control) {
        this.control = control;
    }

    /**
     * put your documentation comment here
     * @param page
     */
    void setPage(ZPage page) {
        if (bodyModal == null) {
            return;
        }

        ZPrintableCells cells = page.getBody();
        bodyModal.setSheet(cells.getSheet());
        bodyModal.setVisibleCells(cells.getVisibleCells());

        ZScriptEngine.getSharedInstance().put(ZScriptEngine.PAGE_NO, String.valueOf(this.getPageNumber(page) + 1));
    }

    /**
     * put your documentation comment here
     * @param scale
     */
    void setScale(float scale) {
        if (this.scale == scale) {
            return;
        }

        this.scale = scale;

        if (headerModal != null) {
            headerModal.setScale(scale);
        }

        if (bodyModal != null) {
            bodyModal.setScale(scale);
        }

        if (footerModal != null) {
            footerModal.setScale(scale);
        }

        updateFormat();
    }

    /**
     * put your documentation comment here
     * @return
     */
    float getScale() {
        return scale;
    }

    /**
     * put your documentation comment here
     * @param g2
     */
    void paint(Graphics2D g2) {
        Shape cs = g2.getClip();
        ZRect clip = null;

/*       if (headerCanvas != null) {
            if (headerModal == editingModel) {
                clip = (ZRect) headerModal.getClip().clone();
                clip.left += 1;
                clip.top += 1;
            } else {
                clip = (ZRect) headerModal.getClip();
            }

            g2.clipRect(clip.left, clip.top, clip.getWidth(), clip.getHeight());
            headerCanvas.paint(g2);

            g2.setClip(cs);
        }*/

        if (bodyCanvas != null) {
           clip = bodyModal.getClip();
           g2.clipRect(clip.left, clip.top, clip.getWidth(), clip.getHeight());
           g2.setClip(0,0,1000,1000);
           bodyCanvas.paint(g2);
          // g2.setClip(cs);
        }

   /*     if (footerCanvas != null) {
            if (footerModal == editingModel) {
                clip = (ZRect) footerModal.getClip().clone();
                clip.left += 1;
                clip.top += 1;
            } else {
                clip = (ZRect) footerModal.getClip();
            }

            g2.clipRect(clip.left, clip.top, clip.getWidth(), clip.getHeight());
            footerCanvas.paint(g2);
        }
        g2.setClip(cs);*/
    }

    /**
     * put your documentation comment here
     * @param rect
     * @return
     */
    private ZRect getScaledRect(ZRect rect) {
        rect.left = (int) (rect.left * scale);
        rect.top = (int) (rect.top * scale);
        rect.right = (int) (rect.right * scale);
        rect.bottom = (int) (rect.bottom * scale);

        return rect;
    }

    /**
     * put your documentation comment here
     */
    private void fireStateChanged() {
        if (listeners.isEmpty()) {
            return;
        }

        ChangeEvent e = new ChangeEvent(this);

        for (int i = 0; i < listeners.size(); i++) {
            ChangeListener lst = (ChangeListener) listeners.get(i);
            lst.stateChanged(e);
        }
    }

    /**
     * put your documentation comment here
     */
    private void updateFormat() {
        ZRect imageable;

        if (headerModal != null) {
            imageable = getHeaderArea(); // in logical unit
            headerModal.setOffset(imageable.left, imageable.top); //
            headerModal.setClip(getScaledRect(imageable)); // note : only set the modal 's clip in device unit
        }

        if (bodyModal != null) {
            imageable = getBodyArea(); // in logical unit
            bodyModal.setOffset(imageable.left, imageable.top);
            bodyModal.setClip(getScaledRect(imageable));
        }

        if (footerModal != null) {
            imageable = getFooterArea(); // in logical unit
            footerModal.setOffset(imageable.left, imageable.top);
            footerModal.setClip(getScaledRect(imageable));
        }

        fireStateChanged();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -