Browse Source

REPORT-92440 mac-数据源带叹号的宽度不正常

newui
obo 2 years ago
parent
commit
567d3f67d4
  1. 14
      designer-base/src/main/java/com/fr/design/icon/WarningIcon.java
  2. 10
      designer-base/src/main/java/com/fr/design/utils/SvgPainter.java

14
designer-base/src/main/java/com/fr/design/icon/WarningIcon.java

@ -2,7 +2,7 @@ package com.fr.design.icon;
import com.fr.base.svg.SVGLoader;
import com.fr.base.svg.SystemScaleUtils;
import com.fr.design.utils.SvgPaintWorker;
import com.fr.design.utils.SvgPainter;
import com.fr.log.FineLoggerFactory;
import javax.swing.GrayFilter;
@ -45,20 +45,20 @@ public class WarningIcon extends ImageIcon {
//裁剪绘制svg的位置,以免影响到图标右侧的文字
Graphics2D graphics = (Graphics2D) g.create(x, y, WARNING_IMAGE.getWidth(null), WARNING_IMAGE.getHeight(null));
if (mainImage != null) {
new SvgPaintWorker(graphics) {
new SvgPainter(graphics) {
@Override
protected void doPrint() {
protected void doPaint() {
this.drawImage(mainImage, x, y, null);
}
}.execute();
}.paint();
}
if (WARNING_IMAGE != null) {
new SvgPaintWorker(graphics) {
new SvgPainter(graphics) {
@Override
protected void doPrint() {
protected void doPaint() {
this.drawImage(WARNING_IMAGE, x, y, null);
}
}.execute();
}.paint();
}
graphics.dispose();
}

10
designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java → designer-base/src/main/java/com/fr/design/utils/SvgPainter.java

@ -12,14 +12,14 @@ import java.awt.image.ImageObserver;
* @since 11.0
* Created on 2023/3/24
*/
abstract public class SvgPaintWorker {
public abstract class SvgPainter {
private final Graphics graphics;
public SvgPaintWorker(Graphics g) {
public SvgPainter(Graphics g) {
graphics = g;
}
protected abstract void doPrint();
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);
@ -32,9 +32,9 @@ abstract public class SvgPaintWorker {
* @since 11.0
* Created on 2023/3/24
*/
public void execute() {
public void paint() {
SvgPaintUtils.beforePaint((Graphics2D) graphics);
doPrint();
doPaint();
SvgPaintUtils.afterPaint((Graphics2D) graphics);
}
}
Loading…
Cancel
Save