Browse Source

REPORT-70446 svg绘制去掉抗锯齿

release/11.0
hades 3 years ago
parent
commit
8194145fde
  1. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java

14
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java

@ -9,7 +9,6 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import javax.swing.JPanel;
/**
@ -25,11 +24,6 @@ public class QuestionPane extends JPanel {
private static final Image QUESTION_BACKGROUND_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/groupbackgroud.svg");
private static final int WIDTH = 40;
private static final int HEIGHT = 40;
public QuestionPane() {
this.setBackground(new Color(0, 0, 0, 0));
}
@ -38,22 +32,20 @@ public class QuestionPane extends JPanel {
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
SvgPaintUtils.beforePaint(g2);
// 宽高保持
int width = SystemScaleUtils.isJreHiDPIEnabled() ? (int) (getWidth() * SVGLoader.SYSTEM_SCALE) : getWidth();
int height = SystemScaleUtils.isJreHiDPIEnabled() ? (int) (getHeight() * SVGLoader.SYSTEM_SCALE) : getHeight();
if (AlphaFineUtil.unread()) {
g2.drawImage(NEW_MESSAGE_IMAGE, 0, 0, width, height, this);
g2.drawImage(NEW_MESSAGE_IMAGE, 0, 0, this);
} else {
g2.drawImage(QUESTION_BACKGROUND_IMAGE, 0, 0, width, height, this);
g2.drawImage(QUESTION_BACKGROUND_IMAGE, 0, 0, this);
}
int imageWidth = QUESTION_IMAGE.getWidth(this);
int imageHeight = QUESTION_IMAGE.getHeight(this);
g2.drawImage(QUESTION_IMAGE, (width - imageWidth) / 2, (height - imageHeight) / 2, imageWidth, imageHeight,this);
g2.drawImage(QUESTION_IMAGE, (width - imageWidth) / 2 - 2, (height - imageHeight) / 2 - 2,this);
SvgPaintUtils.afterPaint(g2);
}

Loading…
Cancel
Save