public class BEUtils
extends java.lang.Object
| 构造器和说明 |
|---|
BEUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
componentsOpaque(java.awt.Component[] comps,
boolean opaque)
设置对象集的透明性,如果该组件是Container及其子类则递归设
置该组件内的所有子组件的透明性,直到组件中的任何组件都被设置完毕.
|
static java.awt.TexturePaint |
createTexturePaint(java.awt.Image image)
获得一个可按指定图片进行纹理填充方式的对象,利用此对象可实现图片填充背景效果。
|
static void |
draw4RecCorner(java.awt.Graphics g,
int x,
int y,
int w,
int h,
int β,
java.awt.Color c)
给一个距形区域绘制4个角效果,形状和坐标如下:
A(x,y)----B(x+β) C(x+(w-β),y)---D(x+w,y)
| |
| |
| |
E(x,y+β) L(x+w,y+β)
F(x,y+(h-β)) K(x+w,y+(h-β))
| |
| |
| |
G(x,y+h)----H(x+β,y+h) I(x+(w-β),y+h)----J(x+w,y+h)
|
static void |
drawDashedRect(java.awt.Graphics g,
int x,
int y,
int width,
int height)
绘制虚线框(本方法适用于对4个边的可选绘制情况下,可能会有4舍5入的小误差
,除了要可选绘制4个边外,一般不推荐使用).
|
static void |
drawDashedRect(java.awt.Graphics g,
int x,
int y,
int width,
int height,
int step,
boolean top,
boolean left,
boolean bottom,
boolean right)
Draw dashed rect.
|
static void |
drawDashedRect(java.awt.Graphics g,
int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight,
int separator_solid,
int separator_space)
绘制虚线框(本方法适用于对4个边的可选绘制情况下,可能会有4舍5入的小误差
,除了要可选绘制4个边外,一般不推荐使用).
|
static void |
fillTextureRoundRec(java.awt.Graphics2D g2,
java.awt.Color baseColor,
int x,
int y,
int w,
int h,
int arc)
在指定的区域内填充出厚重质感立体效果.
|
static void |
fillTextureRoundRec(java.awt.Graphics2D g2,
java.awt.Color baseColor,
int x,
int y,
int w,
int h,
int arc,
int colorDelta)
在指定的区域内填充出厚重质感立体效果.
|
static void |
fillTriangle(java.awt.Graphics g,
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
java.awt.Color c)
填充3角形区域.
|
static javax.swing.ImageIcon |
filterWithRescaleOp(javax.swing.ImageIcon iconBottom,
float redFilter,
float greenFilter,
float blueFilter,
float alphaFilter)
使用RescaleOp对图片进行滤镜处理.
|
static java.awt.Color |
getColor(java.awt.Color basic,
int r,
int g,
int b)
对基准颜色的RGB通道进行加减后得到的新色调.
|
static java.awt.Color |
getColor(java.awt.Color basic,
int r,
int g,
int b,
int a)
对基准颜色的RGBA通道进行加减后得到的新色调.
|
static int |
getColorInt(int rgb)
Gets the color int.
|
static int |
getInt(java.lang.Object key,
int defaultValue)
Gets the int.
|
static int |
getStrPixWidth(java.awt.FontMetrics fm,
java.lang.String str)
获得字符串的像素宽度.
|
static int |
getStrPixWidth(java.awt.Font f,
java.lang.String str)
获得字符串的像素宽度.
|
static void |
setAntiAliasing(java.awt.Graphics2D g2,
boolean antiAliasing)
图形绘制反走样设置.
|
public static javax.swing.ImageIcon filterWithRescaleOp(javax.swing.ImageIcon iconBottom,
float redFilter,
float greenFilter,
float blueFilter,
float alphaFilter)
iconBottom - 原图redFilter - 红色通道滤镜值,1.0f表示保持不变greenFilter - 绿色通道滤镜值,1.0f表示保持不变blueFilter - 蓝色通道滤镜值,1.0f表示保持不变alphaFilter - alpha通道滤镜值,1.0f表示保持不变public static void draw4RecCorner(java.awt.Graphics g,
int x,
int y,
int w,
int h,
int β,
java.awt.Color c)
给一个距形区域绘制4个角效果,形状和坐标如下:
A(x,y)----B(x+β) C(x+(w-β),y)---D(x+w,y)
| |
| |
| |
E(x,y+β) L(x+w,y+β)
F(x,y+(h-β)) K(x+w,y+(h-β))
| |
| |
| |
G(x,y+h)----H(x+β,y+h) I(x+(w-β),y+h)----J(x+w,y+h)
g - x - 距形区的X坐标y - 距形区的Y坐标w - 距形区的宽h - 距形区的高β - 每个角的角长public static void componentsOpaque(java.awt.Component[] comps,
boolean opaque)
comps - 对象集opaque - true表示要设置成不透明,否则表示要设置成透明public static void setAntiAliasing(java.awt.Graphics2D g2,
boolean antiAliasing)
g2 - the g2antiAliasing - 是否反走样public static void fillTriangle(java.awt.Graphics g,
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
java.awt.Color c)
g - the gx1 - 3个点之一的x坐标y1 - 3个点之一的y坐标x2 - 3个点之一的x坐标y2 - 3个点之一的y坐标x3 - 3个点之一的x坐标y3 - 3个点之一的y坐标c - the cpublic static void drawDashedRect(java.awt.Graphics g,
int x,
int y,
int width,
int height)
g - the gx - the xy - the ywidth - the widthheight - the heightpublic static void drawDashedRect(java.awt.Graphics g,
int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight,
int separator_solid,
int separator_space)
g - the gx - the xy - the ywidth - the widthheight - the heightarcWidth - the arc widtharcHeight - the arc heightseparator_solid - 虚线段实线长度separator_space - 虚线段空白长度
add by js,2009-08-30public static void drawDashedRect(java.awt.Graphics g,
int x,
int y,
int width,
int height,
int step,
boolean top,
boolean left,
boolean bottom,
boolean right)
g - the gx - the xy - the ywidth - the widthheight - the heightstep - the steptop - the topleft - the leftbottom - the bottomright - the rightpublic static java.awt.Color getColor(java.awt.Color basic,
int r,
int g,
int b)
basic - 基准色调r - Red通道的增加值(可以是负)g - Geen通道的增加值(可以是负)b - Blue通道的增加值(可以是负)public static java.awt.Color getColor(java.awt.Color basic,
int r,
int g,
int b,
int a)
basic - 基准色调r - Red通道的增加值(可以是负)g - Geen通道的增加值(可以是负)b - Blue通道的增加值(可以是负)a - Alpha通道的增加值(可以是负)public static int getColorInt(int rgb)
rgb - the rgbpublic static int getStrPixWidth(java.awt.FontMetrics fm,
java.lang.String str)
fm - the fmstr - the strFontMetrics.stringWidth(String)public static int getStrPixWidth(java.awt.Font f,
java.lang.String str)
f - the fstr - the strgetStrPixWidth(FontMetrics, String)public static java.awt.TexturePaint createTexturePaint(java.awt.Image image)
示例如下(在这个例子里将实现一个以指定图片填充效果为背景的面板对象):
private FixedLayoutPane inputPane = new FixedLayoutPane() {
//给它弄一个图片平铺的背景
private TexturePaint paint = createTexturePaint(LaunchIconFactory.getInstance()
.getImage("/login_background.png").getImage());
//重写本方法实现图片平铺的背景
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(paint);
g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
}
};
image - 填充图片,该图片一宽1像素高N像素(据这1像素宽进行重复填充即可达到目的)public static int getInt(java.lang.Object key,
int defaultValue)
key - the keydefaultValue - the default valuepublic static void fillTextureRoundRec(java.awt.Graphics2D g2,
java.awt.Color baseColor,
int x,
int y,
int w,
int h,
int arc)
g2 - the g2baseColor - the base colorx - the xy - the yw - the wh - the harc - the arcpublic static void fillTextureRoundRec(java.awt.Graphics2D g2,
java.awt.Color baseColor,
int x,
int y,
int w,
int h,
int arc,
int colorDelta)
g2 - the g2baseColor - the base colorx - the xy - the yw - the wh - the harc - the arccolorDelta - 渐变起色(上)与渐变止色(下)的RGB色差(矢量),正表示变淡,负表示加深