obo
2 years ago
2 changed files with 47 additions and 5 deletions
@ -0,0 +1,33 @@ |
|||||||
|
package com.fr.design.utils; |
||||||
|
|
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
import java.awt.Image; |
||||||
|
import java.awt.image.ImageObserver; |
||||||
|
|
||||||
|
/** |
||||||
|
* SVG图标绘制器 |
||||||
|
* |
||||||
|
* @author obo |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/3/24 |
||||||
|
*/ |
||||||
|
abstract public class SvgPaintWorker { |
||||||
|
|
||||||
|
private final Graphics graphics; |
||||||
|
public SvgPaintWorker(Graphics g) { |
||||||
|
graphics = g; |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void doPrint(); |
||||||
|
protected void drawImage(Image image, int x, int y, ImageObserver imageObserver) { |
||||||
|
//如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整
|
||||||
|
graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); |
||||||
|
} |
||||||
|
|
||||||
|
public void execute() { |
||||||
|
SvgPaintUtils.beforePaint((Graphics2D) graphics); |
||||||
|
doPrint(); |
||||||
|
SvgPaintUtils.afterPaint((Graphics2D) graphics); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue