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

📄 rectangle.java

📁 源码包含生成 PDF 和 HTML 的类库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 *            the type of border	 * @return a boolean	 */	public boolean hasBorder(int type) {		return border != UNDEFINED && (border & type) == type;	}		/**	 * Enables/Disables the border on the specified sides. The border is	 * specified as an integer bitwise combination of the constants: <CODE>	 * LEFT, RIGHT, TOP, BOTTOM</CODE>.	 * 	 * @see #enableBorderSide(int)	 * @see #disableBorderSide(int)	 * @param value	 *            the new value	 */	public void setBorder(int value) {		border = value;	}	/**	 * Enables the border on the specified side.	 * 	 * @param side	 *            the side to enable. One of <CODE>LEFT, RIGHT, TOP, BOTTOM	 *            </CODE>	 */	public void enableBorderSide(int side) {		if (border == UNDEFINED) {			border = 0;		}		border |= side;	}	/**	 * Disables the border on the specified side.	 * 	 * @param side	 *            the side to disable. One of <CODE>LEFT, RIGHT, TOP, BOTTOM	 *            </CODE>	 */	public void disableBorderSide(int side) {		if (border == UNDEFINED) {			border = 0;		}		border &= ~side;	}	// borderwidth	/**	 * Gets the borderwidth.	 * 	 * @return a value	 */	public float getBorderWidth() {		return borderWidth;	}		/**	 * Sets the borderwidth of the table.	 * 	 * @param value	 *            the new value	 */	public void setBorderWidth(float value) {		borderWidth = value;	}	// bordercolor	/**	 * Gets the color of the border.	 * 	 * @return a value	 */	public Color getBorderColor() {		return borderColor;	}		/**	 * Sets the color of the border.	 * 	 * @param value	 *            the new value	 */	public void setBorderColor(Color value) {		borderColor = value;	}	// backgroundcolor	/**	 * Gets the backgroundcolor.	 * 	 * @return a value	 */	public Color getBackgroundColor() {		return backgroundColor;	}		/**	 * Sets the backgroundcolor of the rectangle.	 * 	 * @param value	 *            the new value	 */	public void setBackgroundColor(Color value) {		backgroundColor = value;	}	/**	 * Gets the grayscale.	 * 	 * @return a value	 */	public float getGrayFill() {        if (backgroundColor instanceof GrayColor)            return ((GrayColor)backgroundColor).getGray();        else            return 0;	}	/**	 * Sets the grayscale of the rectangle.	 * 	 * @param value	 *            the new value	 */	public void setGrayFill(float value) {        backgroundColor = new GrayColor(value);	}	// variable borders		/**	 * Indicates whether variable width borders are being used. Returns true if	 * <CODE>setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, or	 * setBorderWidthBottom</CODE> has been called.	 * 	 * @return true if variable width borders are in use	 *  	 */	public boolean isUseVariableBorders() {		return useVariableBorders;	}	/**	 * Sets a parameter indicating if the rectangle has variable borders	 * 	 * @param useVariableBorders	 *            indication if the rectangle has variable borders	 */	public void setUseVariableBorders(boolean useVariableBorders) {		this.useVariableBorders = useVariableBorders;	}		// variable border width	/** Gives the border width of a specific side. */	private float getVariableBorderWidth(float variableWidthValue, int side) {		if ((border & side) != 0) {			return variableWidthValue != UNDEFINED ? variableWidthValue					: borderWidth;		} else {			return 0;		}	}	/**	 * Updates the border flag for a side based on the specified width. A width	 * of 0 will disable the border on that side. Any other width enables it.	 * 	 * @param width	 *            width of border	 * @param side	 *            border side constant	 */	private void updateBorderBasedOnWidth(float width, int side) {		useVariableBorders = true;		if (width > 0) {			enableBorderSide(side);		} else {			disableBorderSide(side);		}	}	/**	 * Gets the width of a border.	 * 	 * @return a width	 */	public float getBorderWidthLeft() {		return getVariableBorderWidth(borderWidthLeft, LEFT);	}	/**	 * Sets the width of a border	 * 	 * @param borderWidthLeft	 *            a width	 */	public void setBorderWidthLeft(float borderWidthLeft) {		this.borderWidthLeft = borderWidthLeft;		updateBorderBasedOnWidth(borderWidthLeft, LEFT);	}	/**	 * Gets the width of a border.	 * 	 * @return a width	 */	public float getBorderWidthRight() {		return getVariableBorderWidth(borderWidthRight, RIGHT);	}	/**	 * Sets the width of a border	 * 	 * @param borderWidthRight	 *            a width	 */	public void setBorderWidthRight(float borderWidthRight) {		this.borderWidthRight = borderWidthRight;		updateBorderBasedOnWidth(borderWidthRight, RIGHT);	}	/**	 * Gets the width of a border.	 * 	 * @return a width	 */	public float getBorderWidthTop() {		return getVariableBorderWidth(borderWidthTop, TOP);	}	/**	 * Sets the width of a border	 * 	 * @param borderWidthTop	 *            a width	 */	public void setBorderWidthTop(float borderWidthTop) {		this.borderWidthTop = borderWidthTop;		updateBorderBasedOnWidth(borderWidthTop, TOP);	}	/**	 * Gets the width of a border.	 * 	 * @return a width	 */	public float getBorderWidthBottom() {		return getVariableBorderWidth(borderWidthBottom, BOTTOM);	}	/**	 * Sets the width of a border	 * 	 * @param borderWidthBottom	 *            a width	 */	public void setBorderWidthBottom(float borderWidthBottom) {		this.borderWidthBottom = borderWidthBottom;		updateBorderBasedOnWidth(borderWidthBottom, BOTTOM);	}	// variable border color		/**	 * Gets the color of a border.	 * 	 * @return a color value	 */	public Color getBorderColorLeft() {		if (borderColorLeft == null) return borderColor;		return borderColorLeft;	}	/**	 * Sets the value of the border color	 * 	 * @param value	 *            a color value	 */	public void setBorderColorLeft(Color value) {		borderColorLeft = value;	}	/**	 * Gets the color of a border.	 * 	 * @return a color value	 */	public Color getBorderColorRight() {		if (borderColorRight == null) return borderColor;		return borderColorRight;	}	/**	 * Sets the value of the border color	 * 	 * @param value	 *            a color value	 */	public void setBorderColorRight(Color value) {		borderColorRight = value;	}	/**	 * Gets the color of a border.	 * 	 * @return a color value	 */	public Color getBorderColorTop() {		if (borderColorTop == null) return borderColor;		return borderColorTop;	}	/**	 * Sets the value of the border color	 * 	 * @param value	 *            a color value	 */	public void setBorderColorTop(Color value) {		borderColorTop = value;	}	/**	 * Gets the color of a border.	 * 	 * @return a color value	 */	public Color getBorderColorBottom() {		if (borderColorBottom == null) return borderColor;		return borderColorBottom;	}	/**	 * Sets the value of the border color	 * 	 * @param value	 *            a color value	 */	public void setBorderColorBottom(Color value) {		borderColorBottom = value;	}	// special methods	/**	 * Gets a Rectangle that is altered to fit on the page.	 * 	 * @param top	 *            the top position	 * @param bottom	 *            the bottom position	 * @return a <CODE>Rectangle</CODE>	 */	public Rectangle rectangle(float top, float bottom) {		Rectangle tmp = new Rectangle(this);		if (getTop() > top) {			tmp.setTop(top);			tmp.disableBorderSide(TOP);		}		if (getBottom() < bottom) {			tmp.setBottom(bottom);			tmp.disableBorderSide(BOTTOM);		}		return tmp;	}	/**	 * Copies all of the parameters from a <CODE>Rectangle</CODE> object	 * except the position.	 * 	 * @param rect	 *            <CODE>Rectangle</CODE> to copy from	 */	public void cloneNonPositionParameters(Rectangle rect) {		this.rotation = rect.rotation;		this.border = rect.border;		this.borderWidth = rect.borderWidth;		this.borderColor = rect.borderColor;		this.backgroundColor = rect.backgroundColor;		this.useVariableBorders = rect.useVariableBorders;		this.borderWidthLeft = rect.borderWidthLeft;		this.borderWidthRight = rect.borderWidthRight;		this.borderWidthTop = rect.borderWidthTop;		this.borderWidthBottom = rect.borderWidthBottom;		this.borderColorLeft = rect.borderColorLeft;		this.borderColorRight = rect.borderColorRight;		this.borderColorTop = rect.borderColorTop;		this.borderColorBottom = rect.borderColorBottom;	}	/**	 * Copies all of the parameters from a <CODE>Rectangle</CODE> object	 * except the position.	 * 	 * @param rect	 *            <CODE>Rectangle</CODE> to copy from	 */	public void softCloneNonPositionParameters(Rectangle rect) {		if (rect.rotation != 0)			this.rotation = rect.rotation;		if (rect.border != UNDEFINED)			this.border = rect.border;		if (rect.borderWidth != UNDEFINED)			this.borderWidth = rect.borderWidth;		if (rect.borderColor != null)			this.borderColor = rect.borderColor;		if (rect.backgroundColor != null)			this.backgroundColor = rect.backgroundColor;		if (useVariableBorders)			this.useVariableBorders = rect.useVariableBorders;		if (rect.borderWidthLeft != UNDEFINED)			this.borderWidthLeft = rect.borderWidthLeft;		if (rect.borderWidthRight != UNDEFINED)			this.borderWidthRight = rect.borderWidthRight;		if (rect.borderWidthTop != UNDEFINED)			this.borderWidthTop = rect.borderWidthTop;		if (rect.borderWidthBottom != UNDEFINED)			this.borderWidthBottom = rect.borderWidthBottom;		if (rect.borderColorLeft != null)			this.borderColorLeft = rect.borderColorLeft;		if (rect.borderColorRight != null)			this.borderColorRight = rect.borderColorRight;		if (rect.borderColorTop != null)			this.borderColorTop = rect.borderColorTop;		if (rect.borderColorBottom != null)			this.borderColorBottom = rect.borderColorBottom;	}		/**	 * @see java.lang.Object#toString()	 */	public String toString() {		StringBuffer buf = new StringBuffer("Rectangle: ");		buf.append(getWidth());		buf.append('x');		buf.append(getHeight());		buf.append(" (rot: ");		buf.append(rotation);		buf.append(" degrees)");		return buf.toString();	}}

⌨️ 快捷键说明

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