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

📄 pvborder.java

📁 导出ORACLE数据库对象DDL语句的程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.icbcsdc.ddlexp.ui.model;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
/**
Draw border and shadow.
@version 6.01 04/30/02
@author Viktor Snezhko
*/
public class PVBorder
{
	/**
	Constant to set no border.
	Value is equal to 0.
	@see #set
	*/
	public static final int NONE = 0;
	/**
	Constant to set symmetric borders.
	Value is equal to 1.<br>
	It can be used with additional integer in the range of 1-9, and width-multiplier in the range of 256*(1-7).<br>
	<I>Example:</I> <code>PVBorder.PLANE + 4 + 256</code>.
	<br>Values for additional styles:
		<UL>
		<LI>PLANE+0 == 1 line by the border color
		<LI>PLANE+1 == 1 line black
		<LI>PLANE+2 == 2 lines wide
		<LI>PLANE+3 == 4 lines wide
		<LI>PLANE+4 == 6 lines wide
		<LI>PLANE+5 == 7 lines wide
		<LI>PLANE+6 == 9 lines wide
		<LI>PLANE+7 == 10 lines wide
		<LI>PLANE+8 == 10 lines wide
		<LI>PLANE+9 == 10 lines wide
		</UL>
	@see #set
	*/
	public static final int PLANE = 1;
	/**
	Constant to set raised borders.
	Value is equal to 11.<br>
	It can be used with additional integer in the range of 1-9, and width-multiplier in the range of 256*(1-7).<br>
	<I>Example:</I> <code>PVBorder.RAISED + 4 + 256 * 3</code>.
	<br>Values for additional styles:
		<UL>
		<LI>RAISED+0 == 1 line wide, black-white
		<LI>RAISED+1 == 1 line wide
		<LI>RAISED+2 == 2 lines wide
		<LI>RAISED+3 == 3 lines wide
		<LI>RAISED+4 == 4 lines wide
		<LI>RAISED+5 == 6 lines wide
		<LI>RAISED+6 == 6 lines wide
		<LI>RAISED+7 == 8 lines wide, double raised
		<LI>RAISED+8 == 10 lines wide, double raised
		<LI>RAISED+9 == 10 lines wide, triple raised
		</UL>
	@see #set
	*/
	public static final int RAISED = 11;
	/**
	Constant to set sunken borders.
	Value is equal to 21.<br>
	It can be used with additional integer in the range of 1-9, and width-multiplier in the range of 256*(1-7).<br>
	<I>Example:</I> <code>PVBorder.SUNKEN + 4 + 256</code>.
	<br>Values for additional styles:
		<UL>
		<LI>SUNKEN+0 == 1 line wide, black-white
		<LI>SUNKEN+1 == 1 line wide
		<LI>SUNKEN+2 == 2 lines wide
		<LI>SUNKEN+3 == 3 lines wide
		<LI>SUNKEN+4 == 4 lines wide
		<LI>SUNKEN+5 == 5 lines wide
		<LI>SUNKEN+6 == 6 lines wide
		<LI>SUNKEN+7 == 7 lines wide, double sunken
		<LI>SUNKEN+8 == 10 lines wide, double sunken
		<LI>SUNKEN+9 == 10 lines wide, triple sunken
		</UL>
	@see #set
	*/
	public static final int SUNKEN = 21;
	/**
	Constant to set outdent borders.
	Value is equal to 31.<br>
	It can be used with additional integer in the range of 1-9, and width-multiplier in the range of 256*(1-7).<br>
	<I>Example:</I> <code>PVBorder.OUTDENT + 4 + 256 * 4</code>.
	<br>Values for additional styles:
		<UL>
		<LI>OUTDENT+0 == 2 lines wide
		<LI>OUTDENT+1 == 2 lines wide, black-white
		<LI>OUTDENT+2 == 3 lines wide, black-white
		<LI>OUTDENT+3 == 4 lines wide, black-white
		<LI>OUTDENT+4 == 5 lines wide
		<LI>OUTDENT+5 == 6 lines wide
		<LI>OUTDENT+6 == 7 lines wide
		<LI>OUTDENT+7 == 8 lines wide
		<LI>OUTDENT+8 == 9 lines wide
		<LI>OUTDENT+9 == 10 lines wide
		</UL>
	@see #set
	*/
	public static final int OUTDENT = 31;
	/**
	Constant to set indent borders.
	Value is equal to 41.<br>
	<I>Note:</I> It is the same as inverted <code>OUTDENT</code> border.
	@see #set
	*/
	public static final int INDENT = 41;
	/**
	Constant to set picture borders.
	Value is equal to 51.<br>
	It can be used with additional integer in the range of 1-9, and width-multiplier in the range of 256*(1-7).<br>
	<I>Example:</I> <code>PVBorder.PICTURE + 4 + 256 * 2</code>.
	<br>The width of that border with any additional style (0..9) is 10 lines.
	@see #set
	*/
	public static final int PICTURE = 51;
	/**
	Constant to set double/triple line raised borders.
	Value is equal to 61.<br>
	It can be used with additional integer in the range of 1-9, and width-multiplier in the range of 256*(1-7).<br>
	<I>Example:</I> <code>PVBorder.RAISED2 + 4 + 256</code>.
	<br>Values for additional styles:
		<UL>
		<LI>RAISED2+0 == 3 lines wide, black-white
		<LI>RAISED2+1 == 3 lines wide, black-white outter lines
		<LI>RAISED2+2 == 3 lines wide
		<LI>RAISED2+3 == 4 lines wide, black-white
		<LI>RAISED2+4 == 4 lines wide, black-white outter lines
		<LI>RAISED2+5 == 4 lines wide
		<LI>RAISED2+6 == 5 lines wide, tripple black-white
		<LI>RAISED2+7 == 5 lines wide, tripple black-white outter lines
		<LI>RAISED2+8 == 5 lines wide, tripple
		<LI>RAISED2+9 == 6 lines wide, tripple black-white
		</UL>
	@see #set
	*/
	public static final int RAISED2 = 61;
	/**
	Constant to set double/triple line sunken borders.
	Value is equal to 71.<br>
	<I>Note:</I> It is the same as inverted <code>RAISED2</code> border.
	@see #set
	*/
	public static final int SUNKEN2 = 71;
	/**
	Constant to set border that has black or white bottom-right lines
	and top-left lines with original "border" color.
	Value is equal to 81.<br>
	It can be used with additional integer in the range of 1-9, and width-multiplier in the range of 256*(1-7).<br>
	<I>Example:</I> <code>PVBorder.BOTTOM_RIGHT + 256</code>.
	<br>Values for additional styles:
		<UL>
		<LI>BOTTOM_RIGHT+0 == 1 line wide, black
		<LI>BOTTOM_RIGHT+1 == 1 line wide, dark
		<LI>BOTTOM_RIGHT+2 == 2 lines wide, black
		<LI>BOTTOM_RIGHT+3 == 3 lines wide, black
		<LI>BOTTOM_RIGHT+4 == 3 lines wide, black with full black outline
		<LI>BOTTOM_RIGHT+5 == 1 line wide, white
		<LI>BOTTOM_RIGHT+6 == 1 line wide, light
		<LI>BOTTOM_RIGHT+7 == 2 lines wide, white
		<LI>BOTTOM_RIGHT+8 == 3 lines wide, white
		<LI>BOTTOM_RIGHT+9 == 3 lines wide, white with full white outline
		</UL>
	@see #set
	*/
	public static final int BOTTOM_RIGHT = 81;
	/**
	Constant to set border that has black or white top-left lines
	and bottom-right lines with original "border" color.
	Value is equal to 81.<br>
	<I>Note:</I> It is the same as inverted <code>BOTTOM_RIGHT</code> border.
	@see #set
	*/
	public static final int TOP_LEFT = 91;
	/**
	Constant to set dotted border.
	Value is equal to 256.<br>
	It can be used with additional multiplier in the range of 2-7.<br>
	<I>Example:</I> <code>PVBorder.FOCUS * 3</code>.
	*/
	public static final int FOCUS = 0x100;
	/**
	Draw border.
	<br><strong>Notes for advanced use:</strong>
	<br>Depending on the value of the style, there are possible two cases:
		<OL>
		<LI>If <code>((style &AMP 0700000) == 0)</code>, then it is a wrapper for:<br>
		<code>PVBorder(g, r, set(style, !invert), set(style, invert), style &GT&GT&GT 8, c)</code>.<br>
		This style is easy to use, because it automatically selects a predifined
		built-in border style (see #set).<br>
		Lower byte <code>0x00ff</code> contains actual border style.<br>
		Second byte <code>0x0f00</code> contains width factor,- number of repetitions of every line.<br>
		<I>Examples:</I>
			<OL>
			<LI>Simple standard-windows-edit-field border<br>
			<code>pv.util.PVBorder.draw(g, r, 23, null, false);</code>
			<LI>Golden picture-border.<br>
			<code>pv.util.PVBorder.draw(g, r, 51, Color.orange, false);</code>
			<LI>The same as above but inverted and with the width increased in 3 times.<br>
			<code>pv.util.PVBorder.draw(g, r, 51+0x200, Color.orange, true);</code>
			</OL>
		<LI>If <code>((style &AMP 0700000) != 0)</code>, then it is a wrapper for:<br>
		<code>PVBorder(g, r, style &AMP 077777, (style &GT&GT 15) &AMP 077777, style &GT&GT&GT 30, c)</code><br>
		or<br>
		<code>PVBorder(g, r, (style &GT&GT 15) &AMP 077777, style &AMP 077777, style &GT&GT&GT 30, c)</code><br>
		depending on value of the "invert"<br>
		Such borders are used by the JPVButton and JPVDatePlus classes.<br>
		This border style can be used to draw any custom combination
		of shadowed border lines that are beyound 60 predifined styles.<br>
		It allows to paint border by up to 5 shadowed lines. Colors of lines
		can have 6 levels of darkness/lightness that are built using the
		"c" as the base color.<br>
		The top/left and bottom/right sets of lines can be set individually.
		Every line can be repeated by up to 4 times using the thickness factor.<br>
		<br>
		The following rules should be considered:
			<OL>
			<LI>Bits 0..15 contain the set of colors for right/bottom lines.
			<LI>Bits 15..30 contain the set of colors for left/top lines.
			<LI>Bits 31..32 contain thickness factor.
			<LI>Lines are counted from the end of blocks of 15 bits.
			<LI>Lines are painted starting from the outter edge of rectangle and moving
			inside of it.
			<LI>Every octal digit (1..7) in a block is a flag for the darknes/lightness
			of the color of lines. Values:
				<UL>
				<LI>0 - flag to stop painting
				<LI>1 - black color
				<LI>2..5 - shadowed colors using the based RGB from
				the following calculations:
					<UL>
					<LI>"red" = <code>170 + (color.getRed() - 170) / 2</code>
					<LI>"green" = <code>170 + (color.getGreen() - 170) / 2</code>
					<LI>"blue" = <code>170 + (color.getBlue() - 170) / 2</code>
					</UL>
				<LI>6 - white color
				<LI>7 - original color as it is
				</UL>
			</OL>
		<I>Examples:</I>
			<UL>
			<LI>To draw flat border with the width equal to 3 pixels by solid black
			lines, you may use value <code>00011100111</code> or <code>020000100001</code>.
			<LI>To draw flat border by the original border color with the width
			equal to 4 pixels, you may use value <code>0777707777</code> or <code>030000700007</code>.
			<LI>To draw raised border with the width equal to 4 pixels, you may
			use value <code>00345601234</code>.
			</UL>
		</OL>
	@param g graphics. In case of null, the border is not painted;
	though, the rectangle of the client area is calculated.
	It can be used to estimate the width of a particular border style.<br>
	<I>Example:</I><br>
	<code>
	Rectangle r = new Rectangle(0, 0, 100, 100);<br>
	int iStyle = 1234567890; // ? a value of border style<br>
	pv.util.PVBorder.draw(null, r, iStyle, null, false);<br>
	int iBorderWidth = r.x;
	</code>
	@param r rectangle. Returned value is adjusted to client area.
	@param style style of border, or two sets of lines.
	@param c border color.
	@see #set
	@see #draw(Graphics,Rectangle,int,int,int,Color)
	*/
	public static void draw(Graphics g, Rectangle r, int style, Color c, boolean invert)
	{ draw(g, r, set(style, !invert), set(style, invert), 7 & (((style & 0700000) == 0) ? (style >>> 8) : (style >>> 30)), c); }
	/**
	Draw border.
	<br>It is the same as "draw(g, r, style, c, false)".
	<br><I>Examples:</I>
		<UL>
		<LI>Assume that "g" is graphics, "r" - rectangle to draw into.
		<LI>Sunken#1 (simple thin) border by light gray color<br>
		<code>pv.util.PVBorder.draw(g, r, pv.util.PVBorder.SUNKEN, null)</code>
		<LI>Picture#1 border by green color<br>
		<code>pv.util.PVBorder.draw(g, r, pv.util.PVBorder.PICTURE, Color.green)</code>
		<LI>Raised#7 border by red color<br>
		<code>pv.util.PVBorder.draw(g, r, pv.util.PVBorder.RAISED + 6, Color.red)</code>
		<LI>Raised#7 border with tripled width by red color<br>
		<code>pv.util.PVBorder.draw(g, r, pv.util.PVBorder.RAISED + 6 + 256 * 2, Color.red)</code>
		</UL>
	@param g graphics.
	@param r rectangle. Returned value is adjusted to client area.
	@param style style of border, or two sets of lines.
	@param c border color.
	@see #set
	@see #draw(Graphics,Rectangle,int,Color,boolean)
	*/
	public static void draw(Graphics g, Rectangle r, int style, Color c){ draw(g, r, style, c, false); }
	/**
	Draw border on graphics inside of rectangle and adjust rectangle for client area.
	@param g graphics. In case of null, the border is not painted;
	though, the rectangle of the client area is calculated.
	@param r rectangle. Returned value is adjusted to client area.

⌨️ 快捷键说明

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