Browse Source

REPORT-92439 mac下-展开收起图标的问题

release/11.0
obo 2 years ago
parent
commit
d7d7fd5326
  1. 17
      designer-base/src/main/java/com/fr/base/svg/SVGIcon.java
  2. 12
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  3. 44
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java
  4. 12
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  5. 22
      designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java

17
designer-base/src/main/java/com/fr/base/svg/SVGIcon.java

@ -1,9 +1,12 @@
package com.fr.base.svg;
import com.fr.design.utils.SvgPaintWorker;
import com.fr.general.IOUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.Icon;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -34,10 +37,12 @@ public class SVGIcon implements Icon {
public void paintIcon(Component c, Graphics g, int x, int y) {
if (HI_DPI_SURPORT) {
Graphics2D graphics = (Graphics2D) g.create(x, y, image.getWidth(null), image.getHeight(null));
float scale = SYSTEM_SCALE;
graphics.scale(1 / scale, 1 / scale);
graphics.drawImage(image, 0, 0, null);
graphics.scale(1.0D, 1.0D);
new SvgPaintWorker(graphics) {
@Override
protected void doPrint() {
this.drawImage(image, 0, 0, null);
}
}.execute();
graphics.dispose();
} else {
g.drawImage(image, x, y, null);

12
designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java

@ -5,7 +5,7 @@ import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.SvgPaintUtils;
import com.fr.design.utils.SvgPaintWorker;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.JComponent;
@ -18,7 +18,6 @@ import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.LayoutManager;
import java.awt.event.MouseAdapter;
@ -338,10 +337,13 @@ public class UIEastResizableContainer extends JPanel {
button = UIConstants.DRAG_RIGHT_PRESS;
}
}
SvgPaintUtils.beforePaint((Graphics2D) g);
//如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整
g.drawImage(button, SvgPaintUtils.calculatePositionX(10), SvgPaintUtils.calculatePositionY(7), null);
SvgPaintUtils.afterPaint((Graphics2D) g);
new SvgPaintWorker(g) {
@Override
protected void doPrint() {
this.drawImage(button, 10, 7, null);
}
}.execute();
}
}
}

44
designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java

@ -3,7 +3,7 @@ package com.fr.design.gui.icontainer;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.SvgPaintUtils;
import com.fr.design.utils.SvgPaintWorker;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.Constants;
@ -17,7 +17,6 @@ import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.LayoutManager;
import java.awt.event.MouseAdapter;
@ -422,12 +421,24 @@ public class UIResizableContainer extends JPanel {
Image upButton = (upModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_UP_NORMAL : UIConstants.DRAG_UP_PRESS);
Image downButton = (downModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_DOWN_NORMAL : UIConstants.DRAG_DOWN_PRESS);
g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, getWidth(), getHeight(), null);
SvgPaintUtils.beforePaint((Graphics2D) g);
//如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整
g.drawImage(UIConstants.DRAG_LINE, SvgPaintUtils.calculatePositionX((getWidth() - toolPaneHeight) / 2), SvgPaintUtils.calculatePositionY(3), null);
g.drawImage(upButton, ARROW_MARGIN, 0, null);
g.drawImage(downButton, SvgPaintUtils.calculatePositionX(getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null);
SvgPaintUtils.afterPaint((Graphics2D) g);
new SvgPaintWorker(g) {
@Override
protected void doPrint() {
this.drawImage(UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null);
}
}.execute();
new SvgPaintWorker(g) {
@Override
protected void doPrint() {
this.drawImage(upButton, ARROW_MARGIN, 0, null);
}
}.execute();
new SvgPaintWorker(g) {
@Override
protected void doPrint() {
this.drawImage(downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null);
}
}.execute();
}
}
@ -524,10 +535,12 @@ public class UIResizableContainer extends JPanel {
button = UIConstants.DRAG_LEFT_PRESS;
}
}
SvgPaintUtils.beforePaint((Graphics2D) g);
//如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整
g.drawImage(button, SvgPaintUtils.calculatePositionX(-6), SvgPaintUtils.calculatePositionY(ARROW_MARGIN_VERTICAL), this);
SvgPaintUtils.afterPaint((Graphics2D) g);
new SvgPaintWorker(g) {
@Override
protected void doPrint() {
this.drawImage(button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this);
}
}.execute();
} else {
g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null);
if (containerWidth == toolPaneHeight) {
@ -543,7 +556,12 @@ public class UIResizableContainer extends JPanel {
button = UIConstants.DRAG_RIGHT_PRESS;
}
}
g.drawImage(button, SvgPaintUtils.calculatePositionX(10), ARROW_MARGIN_VERTICAL, this);
new SvgPaintWorker(g) {
@Override
protected void doPrint() {
this.drawImage(button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.this);
}
}.execute();
}
if (isLeftRightDragEnabled) {
g.drawImage(UIConstants.DRAG_DOT_VERTICAL, 2, getHeight() / 2, 5, toolPaneHeight, null);

12
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -19,7 +19,7 @@ import com.fr.design.notification.SnapChat;
import com.fr.design.notification.SnapChatFactory;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.SvgPaintUtils;
import com.fr.design.utils.SvgPaintWorker;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.log.FineLoggerFactory;
@ -1314,10 +1314,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} else {
button = UIConstants.POP_BUTTON_UP;
}
SvgPaintUtils.beforePaint((Graphics2D) g);
//如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整
g.drawImage(button, SvgPaintUtils.calculatePositionX(ARROW_RANGE_START + 8), SvgPaintUtils.calculatePositionY(4), null);
SvgPaintUtils.afterPaint((Graphics2D) g);
new SvgPaintWorker(g) {
@Override
protected void doPrint() {
this.drawImage(button, (ARROW_RANGE_START + 8), 4, null);
}
}.execute();
}
}

22
designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java

@ -24,26 +24,16 @@ public class SvgPaintUtils {
public static void afterPaint(Graphics2D g2) {
if (HI_DPI_ENABLED) {
g2.scale(1.0D, 1.0D);
g2.scale(SVGLoader.SYSTEM_SCALE, SVGLoader.SYSTEM_SCALE);
}
}
/**
* 计算高缩放下绘制svg图标时新的的位置x
* @param x 旧x的值
* @return 新的x
* 计算高缩放下绘制svg图标时新的的位置x,y
* @param position 旧坐标的值
* @return 新的position
* */
public static int calculatePositionX(int x) {
return HI_DPI_ENABLED ? (int) (x * SVGLoader.SYSTEM_SCALE) : x;
public static int calculatePosition(int position) {
return HI_DPI_ENABLED ? (int) (position * SVGLoader.SYSTEM_SCALE) : position;
}
/**
* 计算高缩放下绘制svg图标时新的的位置y
* @param y 旧y的值
* @return 新的y值
* */
public static int calculatePositionY(int y) {
return HI_DPI_ENABLED ? (int) (y * SVGLoader.SYSTEM_SCALE) : y;
}
}

Loading…
Cancel
Save