forked from fanruan/design
kerry
3 years ago
4 changed files with 52 additions and 6 deletions
@ -0,0 +1,42 @@
|
||||
package com.fr.design.icon; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.gui.itree.filetree.FileTreeIcon; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.awt.Component; |
||||
import java.awt.Graphics; |
||||
|
||||
/** |
||||
* Created by kerry on 2021/11/11 |
||||
*/ |
||||
public class LocalFileIcon implements Icon { |
||||
private static final Icon FILE_LOCKED_ICON = BaseUtils.readIcon(FileTreeIcon.FILE_LOCKED_ICON_PATH); |
||||
private static final int OFFSET_X = 9; |
||||
private static final int OFFSET_Y = 8; |
||||
private final Icon mainIcon; |
||||
private final boolean showLock; |
||||
|
||||
public LocalFileIcon(Icon mainIcon, boolean showLock) { |
||||
this.mainIcon = mainIcon; |
||||
this.showLock = showLock; |
||||
} |
||||
|
||||
@Override |
||||
public void paintIcon(Component c, Graphics g, int x, int y) { |
||||
mainIcon.paintIcon(c, g, x, y); |
||||
if (showLock) { |
||||
FILE_LOCKED_ICON.paintIcon(c, g, OFFSET_X, OFFSET_Y); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public int getIconWidth() { |
||||
return mainIcon.getIconWidth(); |
||||
} |
||||
|
||||
@Override |
||||
public int getIconHeight() { |
||||
return mainIcon.getIconHeight(); |
||||
} |
||||
} |
After Width: | Height: | Size: 225 B |
Loading…
Reference in new issue