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

📄 zbase.java

📁 用Java写的报表.功能如下: 0.内建网络打印,网络预览功能! 1.文件操作。包括url 指定的文件。 2.全功能打印支持。包括打印预览。 3.Undo 和 redo。 4.合并单元格。 5.Cel
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright 2002 EZCell , Inc. All rights reserved.
 * Version  1.0.
 * Author   W.John
 */
package ezcell;

import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;


/**
 * ZBase is the base class for all sheet elements(ZCell,ZRow,ZCol), It provides basic services
 * which all of them need to do.
 *
 * Those basic services mainly include  setter and getter of the properties such as background,
 * alignment and so on.
 *
 * Also provided are other services for serialization.
 *
 * @version 1.00
 * @author W.John
 */
public class ZBase {
    final static int PTY_Text = 0x00000001;
    final static int PTY_Hide = 0x00000002;
    final static int PTY_BackBrush = 0x00000004;
    final static int PTY_BackStyle = 0x00000008;
    final static int PTY_Format = 0x00000010;
    final static int PTY_WordWrap = 0x00000020;
    final static int PTY_HorzAlign = 0x00000040;
    final static int PTY_VertAlign = 0x00000080;
    final static int PTY_Font = 0x00000100;
    final static int PTY_DefObject = 0x00002000;
    final static int PTY_LeftBorder = 0x00040000;
    final static int PTY_TopBorder = 0x00080000;
    final static int PTY_Bookmark = 0x00010000;
    final static int PTY_TextBrush = 0x00200000;
    final static int PTY_Formula = 0x00400000;
    final static int PTY_ReadOnly = 0x00800000;
    final static int PTY_BaseAll = 0x00FFFFFF;
    final static int PTY_MergeAsParent = 0x01000000;
    final static int PTY_MergeAsChild = 0x02000000;
    final static int PTY_Width = 0x04000000;
    final static int PTY_Height = 0x08000000;
    final static int PTY_RightBorder = 0x10000000;
    final static int PTY_BottomBorder = 0x20000000;
    final static int PTY_CellAll = PTY_BaseAll | PTY_MergeAsParent | PTY_MergeAsChild;
    final static int PTY_RowAll = PTY_BaseAll | PTY_Height;
    final static int PTY_ColAll = PTY_BaseAll | PTY_Width;
    final static int PTY_All = 0xFFFFFFFF;
    final static int CELL = 0xCCCCCCCC;
    final static int ROW = 0xBBBBBBBB;
    final static int COLUMN = 0xDDDDDDDD;
    final static int UNKNOWN = 0xAAAAAAAA;
    public final static int XCENTER = 0x00000001;
    public final static int LEFT = 0x00000002;
    public final static int RIGHT = 0x00000004;
    public final static int YCENTER = 0x00010000;
    public final static int TOP = 0x00020000;
    public final static int BOTTOM = 0x00040000;
    public static boolean compareByRow;
    public static boolean compareReverse;
    protected int row = -1;
    protected int col = -1;
    protected String text = "";
    protected int property;
    protected int noPropUnder;
    protected boolean readOnly;
    protected boolean wordWrap ;
    protected ZDefaultSheet sheet;
    protected boolean hide;
    protected String format;
    protected String bookmark;
    protected boolean defObject;
    protected int horzAlign = XCENTER;
    protected int vertAlign = TOP;
    protected ZFont font = new ZFont();
    protected ZPen leftBorder = new ZPen();
    protected ZPen topBorder = new ZPen();
    protected ZPen rightBorder; // for copy
    protected ZPen bottomBorder; // for copy
    protected ZBrush backBrush = new ZColorBrush(Color.white);
    protected ZBrush textBrush = new ZColorBrush(Color.black);


    /**
     * Creates a new ZBase.
     * Nothing done.
     */
    public ZBase() {
    }

    /**
     * Creates a new ZBase and specifies which sheet it belongs to .
     *
     * @param     ZDefaultSheet sheet .The sheet contains the object.
     */
    public ZBase(ZDefaultSheet sheet) {
        this.sheet = sheet;
    }

    /**
     * Sets the background brush.
     * @param backBrush the new brush.
     */
    public void setBackBrush(ZBrush backBrush) {
        this.backBrush = backBrush;
        setProperty(PTY_BackBrush);
    }

    /**
     * Sets the bookmark .
     * @param bookmark
     */
    public void setBookmark(String bookmark) {
        this.bookmark = bookmark;
    }

    /**
     * put your documentation comment here
     * @param bottomBorder
     */
    public void setBottomBorder(ZPen bottomBorder) {
        this.bottomBorder = bottomBorder;

        ZDefaultCell cell = sheet.getExistCell(row + 1, col);

        if ((cell != null) && cell.hasProperty(PTY_TopBorder)) {
            bottomBorder.setZorder(cell.getTopBorder0().getZorder() + 1);
        }

        setProperty(PTY_BottomBorder);
    }

    /**
     * put your documentation comment here
     * @param col
     */
    public void setCol(int col) {
        this.col = col;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int getCol() {
        return col;
    }

    /**
     * put your documentation comment here
     * @param defObject
     */
    public void setDefObject(boolean defObject) {
        this.defObject = defObject;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public boolean isDefObject() {
        return defObject;
    }

    /**
     * put your documentation comment here
     * @param font
     */
    public void setFont(ZFont font) {
        this.font = font;
        fontChanged();
    }

    /**
     * put your documentation comment here
     * @param fontBold
     */
    public void setFontBold(boolean fontBold) {
        font = (ZFont) getFont(row, col).clone();
        font.setBold(fontBold);
        fontChanged();
    }

    /**
     * put your documentation comment here
     * @param fontItalic
     */
    public void setFontItalic(boolean fontItalic) {
        font = (ZFont) getFont(row, col).clone();
        font.setItalic(fontItalic);
        fontChanged();
    }

    /**
     * put your documentation comment here
     * @param fontName
     */
    public void setFontName(String fontName) {
        font = (ZFont) getFont(row, col).clone();
        font.setName(fontName);
        fontChanged();
    }

    /**
     * $fileName$
     *
     * @param fontOutline
     */
    public void setFontOutline(boolean fontOutline) {
        font = (ZFont) getFont(row, col).clone();
        font.setOutline(fontOutline);
        fontChanged();
    }

    /**
     * put your documentation comment here
     * @param fontSize
     */
    public void setFontSize(int fontSize) {
        font = (ZFont) getFont(row, col).clone();
        font.setSize(fontSize);
        fontChanged();
    }

    /**
     * put your documentation comment here
     * @param format
     */
    public void setFormat(String format) {
        this.format = format;
        setProperty(PTY_Format);
    }

    public void setWordWrap (boolean wordWrap)
    {


      this.wordWrap = wordWrap;
      setProperty(PTY_WordWrap);
    }

    /**
     * put your documentation comment here
     * @param hide
     */
    public void setHide(boolean hide) {
        this.hide = hide;
    }

    /**
     * put your documentation comment here
     * @param horzAlign
     */
    public void setHorzAlign(int horzAlign) {
        this.horzAlign = horzAlign;

        if (horzAlign == sheet.defaultBase.horzAlign) {
            setNoPropUnder(PTY_HorzAlign);
            clearProperty(PTY_HorzAlign);
        } else {
            setProperty(PTY_HorzAlign);
        }
    }

    /**
     * put your documentation comment here
     * @param leftBorder
     */
    public void setLeftBorder(ZPen leftBorder) {
        this.leftBorder = leftBorder;

        ZDefaultCell cell = sheet.getExistCell(row, col - 1);

        if ((cell != null) && cell.hasProperty(PTY_RightBorder)) {
            leftBorder.setZorder(cell.getRightBorder0().getZorder() + 1);
        }

        setProperty(PTY_LeftBorder);
    }

    /**
     * put your documentation comment here
     * @param prop
     */
    public void setNoPropUnder(int prop) {
        noPropUnder |= prop;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int getNoPropUnder() {
        return noPropUnder;
    }

    /**
     * put your documentation comment here
     * @param property
     */
    public void setProperty(int prop) {
        this.property |= prop;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int getProperty() {
        return property;
    }

    /**
     * $fileName$
     *
     * @param prop
     */
    public void setProperty2(int prop) {
        this.property = prop;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int getProperty2() {
        return property | noPropUnder;
    }

    /**
     * put your documentation comment here
     * @param readOnly
     */
    public void setReadOnly(boolean readOnly) {
        this.readOnly = readOnly;

        if (readOnly == sheet.defaultBase.readOnly) {
            setNoPropUnder(PTY_ReadOnly);
            clearProperty(PTY_ReadOnly);
        } else {
            setProperty(PTY_ReadOnly);
        }
    }

    /**
     * put your documentation comment here
     * @param rightBorder
     */
    public void setRightBorder(ZPen rightBorder) {
        this.rightBorder = rightBorder;

        ZDefaultCell cell = sheet.getExistCell(row, col + 1);

        if ((cell != null) && cell.hasProperty(PTY_LeftBorder)) {
            rightBorder.setZorder(cell.getLeftBorder0().getZorder() + 1);
        }

        setProperty(PTY_RightBorder);
    }

    /**
     * put your documentation comment here
     * @param row
     */
    public void setRow(int row) {
        this.row = row;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int getRow() {
        return row;
    }

    /**
     * put your documentation comment here
     * @param sheet
     */
    public void setSheet(ZDefaultSheet sheet) {
        this.sheet = sheet;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public ZDefaultSheet getSheet() {
        return sheet;
    }

    /**
     * put your documentation comment here
     * @param textBrush
     */
    public void setTextBrush(ZBrush textBrush) {
        this.textBrush = textBrush;

        if (textBrush == sheet.defaultBase.textBrush) {
            setNoPropUnder(PTY_TextBrush);
            clearProperty(PTY_TextBrush);
        } else {
            setProperty(PTY_TextBrush);
        }
    }

    /**
     * put your documentation comment here
     * @param topBorder
     */
    public void setTopBorder(ZPen topBorder) {
        this.topBorder = topBorder;

        ZDefaultCell cell = sheet.getExistCell(row - 1, col);

        if ((cell != null) && cell.hasProperty(PTY_BottomBorder)) {
            topBorder.setZorder(cell.getBottomBorder0().getZorder() + 1);
        }

        setProperty(PTY_TopBorder);
    }

    /**
     * put your documentation comment here
     * @param vertAlign
     */
    public void setVertAlign(int vertAlign) {
        this.vertAlign = vertAlign;

        if (vertAlign == sheet.defaultBase.vertAlign) {
            setNoPropUnder(PTY_VertAlign);
            clearProperty(PTY_VertAlign);
        } else {
            setProperty(PTY_VertAlign);
        }
    }

    /**
     * put your documentation comment here
     * @param prop
     */
    public void clearNoPropUnder(int prop) {
        noPropUnder &= ~prop;
    }

    /**
     * put your documentation comment here
     * @param prop
     * @return
     */
    public void clearProperty(int prop) {
        property &= ~prop;
    }

    /**
     * put your documentation comment here
     * @param source
     */
    public void copyFrom(ZBase source) {
        int prop = getProperty() | getNoPropUnder();

        if (prop == PTY_BaseAll) {
            return;
        }

        prop |= source.getProperty(); // after this call, the base has all "prop" properties
        noPropUnder |= source.getNoPropUnder();

⌨️ 快捷键说明

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