obo
2 years ago
3 changed files with 36 additions and 42 deletions
@ -1,40 +1,16 @@
|
||||
package com.fr.design.utils; |
||||
|
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Image; |
||||
import java.awt.image.ImageObserver; |
||||
|
||||
/** |
||||
* SVG图标绘制器 |
||||
* 绘制SVG图标的函数式接口 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2023/3/24 |
||||
*/ |
||||
public abstract class SvgPainter { |
||||
|
||||
private final Graphics graphics; |
||||
public SvgPainter(Graphics g) { |
||||
graphics = g; |
||||
} |
||||
|
||||
protected abstract void doPaint(); |
||||
protected void drawImage(Image image, int x, int y, ImageObserver imageObserver) { |
||||
//如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整
|
||||
graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); |
||||
} |
||||
public interface SvgPainter<T> { |
||||
|
||||
/** |
||||
* 执行完整的svg绘制逻辑 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2023/3/24 |
||||
*/ |
||||
public void paint() { |
||||
SvgPaintUtils.beforePaint((Graphics2D) graphics); |
||||
doPaint(); |
||||
SvgPaintUtils.afterPaint((Graphics2D) graphics); |
||||
} |
||||
* 绘制svg图标的具体逻辑,方法体 |
||||
* */ |
||||
void drawSVG(); |
||||
} |
||||
|
Loading…
Reference in new issue