Browse Source
Merge in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0 * commit '39c29ab26d386ca727efbb14eaab7466e275ee9e': REPORT-54122 设计器组件悬停/选中/编辑状态优化feature/10.0
Hades
4 years ago
9 changed files with 230 additions and 14 deletions
After Width: | Height: | Size: 304 B |
After Width: | Height: | Size: 281 B |
@ -0,0 +1,47 @@
|
||||
package com.fr.design.designer.creator; |
||||
|
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.general.IOUtils; |
||||
import java.awt.AlphaComposite; |
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Image; |
||||
import java.awt.Rectangle; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/06/30 |
||||
*/ |
||||
public class SelectedBorderIcon { |
||||
|
||||
private static final Image EDIT_ICON = IOUtils.readImage("/com/fr/design/images/control/show_edit.png"); |
||||
private static final Image SETTING_ICON = IOUtils.readImage("/com/fr/design/images/control/show_setting.png"); |
||||
private static final float ALPHA = 0.7F; |
||||
private static final int TIP_WIDTH = 20; |
||||
private static final int TIP_HEIGHT = 40; |
||||
private static final int ARC_VALUE = 4; |
||||
// 组件到整个提示之间的空隙
|
||||
private static final int CREATOR_TO_TIP_GAP = 5; |
||||
// icon在整个提示背景下缩进
|
||||
private static final int TIP_ICON_GAP = 2; |
||||
|
||||
/** |
||||
* 在bounds范围的右上角绘制特定图标 |
||||
* |
||||
* @param g |
||||
* @param bounds |
||||
*/ |
||||
public void paint(Graphics g, Rectangle bounds) { |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ALPHA); |
||||
g2d.setColor(XCreatorConstants.EDIT_COLOR); |
||||
g2d.setComposite(alphaComposite); |
||||
g2d.fillRoundRect(bounds.x + bounds.width + CREATOR_TO_TIP_GAP, bounds.y, TIP_WIDTH, TIP_HEIGHT, ARC_VALUE, ARC_VALUE); |
||||
g2d.drawImage(EDIT_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_ICON_GAP, EDIT_ICON.getWidth(null), EDIT_ICON.getHeight(null), null); |
||||
g2d.drawImage(SETTING_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + CREATOR_TO_TIP_GAP + EDIT_ICON.getHeight(null), SETTING_ICON.getWidth(null), SETTING_ICON.getHeight(null), null); |
||||
g2d.setColor(Color.WHITE); |
||||
g2d.drawLine(bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_WIDTH, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP + EDIT_ICON.getWidth(null), bounds.y + TIP_WIDTH); |
||||
} |
||||
} |
Loading…
Reference in new issue