📄 imagecharicon.java
字号:
/*
* Created on 2005-3-18
*/
package jcase.lianliankan;
import java.awt.*;
public class ImageCharIcon extends SimpleCharIcon {
/* 根据不同的字符绘制不同的图标
* @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, int, int)
*/
public void paintIcon(Component c, Graphics g, int x, int y) {
Font dfont = g.getFont();
Color dcolor =g.getColor();
g.setFont(charFont);
if(isSelected()){
g.setColor(Color.RED);
g.drawRect(x,y,getIconWidth(),getIconHeight());
}
Image icon = Configuration.getImage(getChar());
int w=icon.getWidth(c);
int h=icon.getHeight(c);
double xscale=getIconWidth()*1.0/w;
double yscale=getIconHeight()*1.0/h;
double scale;
scale=Math.min(xscale,yscale);
w*=scale;
x+=(getIconWidth()-w)/2;
h*=scale;
y+=(getIconHeight()-h)/2;
g.drawImage(icon,x,y,w,h,c);
g.setColor(dcolor);
g.setFont(dfont);
}
/**
*
*/
public ImageCharIcon() {
super();
}
/**
* @param c
*/
public ImageCharIcon(char c) {
super(c);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -