📄 zdefaultcell.java
字号:
/*
* Copyright 2002 EZCell , Inc. All rights reserved.
* Version 1.0.
* Author W.John
*/
package ezcell;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2001</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
class ZDefaultCell extends ZBase implements Serializable, Comparable, Cloneable, ZCell {
private int cookie;
private boolean focused;
private int mergeX;
private int mergeY;
/**
* put your documentation comment here
* @param ZDefaultSheet sheet
*/
public ZDefaultCell(ZDefaultSheet sheet) {
super(sheet);
}
/**
* put your documentation comment here
* @param ZDefaultSheet sheet
* @param int row
* @param int col
*/
public ZDefaultCell(ZDefaultSheet sheet, int row, int col) {
super(sheet);
setRow(row);
setCol(col);
}
/**
* put your documentation comment here
* @return
*/
public ZBrush getBackBrush() {
return getBackBrush(row, col);
}
/**
*
* @param border
*
* @return
*/
public int getBorderZorder(int border) {
int zo = -1;
switch (border) {
case PTY_LeftBorder:
if (hasProperty(PTY_LeftBorder)) {
zo = leftBorder.getZorder();
}
break;
case PTY_TopBorder:
if (hasProperty(PTY_TopBorder)) {
zo = topBorder.getZorder();
}
break;
case PTY_RightBorder:
if (hasProperty(PTY_RightBorder)) {
zo = rightBorder.getZorder();
}
break;
case PTY_BottomBorder:
if (hasProperty(PTY_BottomBorder)) {
zo = bottomBorder.getZorder();
}
break;
}
return zo;
}
/**
*
* @return
*/
public ZPen getBottomBorder() {
boolean thisBottom = hasProperty(PTY_BottomBorder);
ZDefaultCell cellNext = sheet.getExistCell(row + 1, col);
boolean nextTop = (cellNext != null && cellNext.hasProperty(PTY_TopBorder));
if (!thisBottom && !nextTop) {
return null;
} else if (thisBottom && !nextTop) {
return getBottomBorder0();
} else if (!thisBottom && nextTop) {
return cellNext.getTopBorder0();
} else {
ZPen penThis = getBottomBorder0();
ZPen penNext = cellNext.getTopBorder0();
if (penThis.getZorder() > penNext.getZorder()) {
return penThis;
} else {
return penNext;
}
}
}
/**
*
* @return
*/
public ZPen getBottomBorder0() {
return bottomBorder;
}
/**
* put your documentation comment here
* @return
*/
public boolean isChild() {
return (property & PTY_MergeAsChild) != 0;
}
/**
*
* @param cookie
*/
public void setCookie(int cookie) {
this.cookie = cookie;
}
/**
*
* @return
*/
public int getCookie() {
return cookie;
}
/**
* put your documentation comment here
* @param focused
*/
public void setFocused(boolean focused) {
this.focused = focused;
}
/**
* put your documentation comment here
* @return
*/
public boolean isFocused() {
return focused;
}
/**
* put your documentation comment here
* @return
*/
public ZFont getFont() {
return getFont(row, col);
}
/**
* put your documentation comment here
* @return
*/
public String getFormat() {
return getFormat(row, col);
}
/**
*
* @return
*/
public boolean isHead() {
return (row == 0 || col == 0);
}
/**
*
* @return
*/
public int getHeight() {
return sheet.getRowHeight(row);
}
/**
* put your documentation comment here
* @return
*/
public boolean isHide() {
return isHide(row, col);
}
/**
* put your documentation comment here
* @return
*/
public int getHorzAlign() {
return getHorzAlign(row, col);
}
/**
*
* @return
*/
public ZPen getLeftBorder() {
boolean thisLeft = hasProperty(PTY_LeftBorder);
ZDefaultCell cellPrior = sheet.getExistCell(row, col - 1);
boolean priorRight = (cellPrior != null && cellPrior.hasProperty(PTY_RightBorder));
if (!thisLeft && !priorRight) {
return null;
} else if (thisLeft && !priorRight) {
return getLeftBorder0();
} else if (!thisLeft && priorRight) {
return cellPrior.getRightBorder0();
} else {
ZPen penThis = getLeftBorder0();
ZPen penPrior = cellPrior.getRightBorder0();
if (penThis.getZorder() > penPrior.getZorder()) {
return penThis;
} else {
return penPrior;
}
}
}
/**
* put your documentation comment here
* @return
*/
public ZPen getLeftBorder0() {
return getLeftBorder0(row, col);
}
/**
* put your documentation comment here
* @param x
* @param y
*/
public void setMergeAsChild(int x, int y) {
if (hasProperty(PTY_MergeAsParent)) {
sheet.removeParentCell(this);
clearProperty(PTY_MergeAsParent);
}
mergeX = x;
mergeY = y;
setProperty(PTY_MergeAsChild);
}
/**
* put your documentation comment here
* @return
*/
/**
* put your documentation comment here
* @return
*/
/**
* put your documentation comment here
* @param x
* @param y
*/
public void setMergeAsParent(int x, int y) {
clearProperty(PTY_MergeAsChild);
mergeX = x;
mergeY = y;
setProperty(PTY_MergeAsParent);
sheet.addParentCell(this);
}
/**
* put your documentation comment here
* @param mergeX
*/
public void setMergeX(int mergeX) {
this.mergeX = mergeX;
}
/**
* put your documentation comment here
* @return
*/
public int getMergeX() {
return mergeX;
}
/**
* put your documentation comment here
* @param mergeY
*/
public void setMergeY(int mergeY) {
this.mergeY = mergeY;
}
/**
* put your documentation comment here
* @return
*/
public int getMergeY() {
return mergeY;
}
/**
*
* @return
*
* @throws Exception
* @throws ZException
*/
public ZCell getParent() throws Exception {
if (hasProperty(PTY_MergeAsChild)) {
return sheet.getCell(row - mergeY, col - mergeX);
} else {
throw new ZException("the cell is not one's child");
}
}
/**
* put your documentation comment here
* @return
*/
public boolean isParent() {
return (property & PTY_MergeAsParent) != 0;
}
/**
* put your documentation comment here
* @return
*/
public boolean isReadOnly() {
return isReadOnly(row, col);
}
public boolean isWordWrap(){
return isWordWrap(row,col);
}
/**
*
* @return
*/
public ZPen getRightBorder() {
boolean thisRight = hasProperty(PTY_RightBorder);
ZDefaultCell cellNext = sheet.getExistCell(row, col + 1);
boolean nextLeft = (cellNext != null && cellNext.hasProperty(PTY_LeftBorder));
if (!thisRight && !nextLeft) {
return null;
} else if (thisRight && !nextLeft) {
return getRightBorder0();
} else if (!thisRight && nextLeft) {
return cellNext.getLeftBorder0();
} else {
ZPen penThis = getRightBorder0();
ZPen penNext = cellNext.getLeftBorder0();
if (penThis.getZorder() > penNext.getZorder()) {
return penThis;
} else {
return penNext;
}
}
}
/**
*
* @return
*/
public ZPen getRightBorder0() {
return rightBorder;
}
/**
* put your documentation comment here
* @return
*/
public ZRect getSpan() {
if (!isParent()) {
return null;
} else {
return new ZRect(col, row, (col + mergeX) - 1, (row + mergeY) - 1);
}
}
/**
* put your documentation comment here
* @param text
*/
public void setText(String text) {
this.text = text;
setProperty(PTY_Text);
}
/**
* put your documentation comment here
* @return
*/
public String getText(int row, int col) {
return text;
}
/**
* put your documentation comment here
* @return
*/
public String getText() {
return text;
}
/**
* put your documentation comment here
* @return
*/
public ZBrush getTextBrush() {
return getTextBrush(row, col);
}
/**
*
* @return
*/
public ZPen getTopBorder() {
int or = row;
boolean thisTop = hasProperty(PTY_TopBorder);
ZDefaultCell cellPrior = sheet.getExistCell(row - 1, col);
boolean priorBottom = (cellPrior != null && cellPrior.hasProperty(PTY_BottomBorder));
if (!thisTop && !priorBottom) {
return null;
} else if (thisTop && !priorBottom) {
return getTopBorder0();
} else if (!thisTop && priorBottom) {
return cellPrior.getBottomBorder0();
} else {
ZPen penThis = getTopBorder0();
ZPen penPrior = cellPrior.getBottomBorder0();
if (penThis.getZorder() > penPrior.getZorder()) {
return penThis;
} else {
return penPrior;
}
}
}
/**
* put your documentation comment here
* @return
*/
public ZPen getTopBorder0() {
return getTopBorder0(row, col);
}
/**
* put your documentation comment here
* @return
*/
public int getVertAlign() {
return getVertAlign(row, col);
}
/**
*
* @return
*/
public int getWidth() {
return sheet.getColWidth(col);
}
/**
* put your documentation comment here
* @return
*/
public Object clone() {
ZBase obj = null;
try {
obj = (ZBase) super.clone();
obj.leftBorder = hasProperty(PTY_LeftBorder) ? (ZPen) leftBorder.clone() : null;
obj.topBorder = hasProperty(PTY_TopBorder) ? (ZPen) topBorder.clone() : null;
obj.rightBorder = hasProperty(PTY_RightBorder) ? (ZPen) rightBorder.clone() : null;
obj.bottomBorder = hasProperty(PTY_BottomBorder) ? (ZPen) bottomBorder.clone() : null;
return obj;
} catch (Exception e) {
}
return obj;
}
/**
*
* @param sheet
* @param row
* @param col
*
* @return
*/
public ZCell clone(ZSheet sheet, int row, int col) {
this.sheet = (ZDefaultSheet) sheet;
this.row = row;
this.col = col;
return this;
}
/**
* put your documentation comment here
* @param o
* @return
*/
public int compareTo(Object o) {
int result = 0;
ZDefaultCell cell = (ZDefaultCell) o;
if (ZBase.compareByRow) {
if (row > cell.row) {
result = 1;
} else if (row < cell.row) {
result = -1;
} else {
if (col > cell.col) {
result = 1;
} else if (col < cell.col) {
result = -1;
} else {
result = 0;
}
}
} else {
if (col > cell.col) {
result = 1;
} else if (col < cell.col) {
result = -1;
} else {
if (row > cell.row) {
result = 1;
} else if (row < cell.row) {
result = -1;
} else {
result = 0;
}
}
}
if (ZBase.compareReverse) {
result *= -1;
}
return result;
}
/**
*
* @return
*/
public String toString() {
return "cell(" + row + "," + col + ")";
}
/**
* put your documentation comment here
* @return
*/
public int type() {
return ZBase.CELL;
}
/**
* put your documentation comment here
* @param row
* @param col
* @return
*/
public ZBase underLayer(int row, int col) {
if (sheet.getExistRow(row) != null) {
return sheet.getExistRow(row);
} else if (sheet.getExistCol(col) != null) {
return sheet.getExistCol(col);
} else {
return sheet.defaultBase;
}
}
/**
* put your documentation comment here
* @param ois
* @exception ClassNotFoundException, IOException
*/
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
_readObject(ois);
if (hasProperty(PTY_MergeAsParent | PTY_MergeAsChild)) {
mergeX = ois.readInt();
mergeY = ois.readInt();
}
}
/**
* put your documentation comment here
* @param oos
* @exception ClassNotFoundException, IOException
*/
private void writeObject(ObjectOutputStream oos) throws ClassNotFoundException, IOException {
_writeObject(oos);
if (hasProperty(PTY_MergeAsParent | PTY_MergeAsChild)) {
oos.writeInt(mergeX);
oos.writeInt(mergeY);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -