From dca702f558ac454ed087dc9b695fa4dcd1f3eda9 Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 7 Nov 2022 09:28:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20REPORT-82928=E3=80=90=E8=A7=86=E8=A7=89?= =?UTF-8?q?=E9=AA=8C=E6=94=B6=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=B5=B7?= =?UTF-8?q?=E5=A7=8B=E9=A1=B5=20debug=20=E7=9B=B8=E5=85=B3=E7=9A=84?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E3=80=82=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E8=AF=A6=E8=A7=81=EF=BC=9Ahttps://kms.fineres.com/pages/vie?= =?UTF-8?q?wpage.action=3FpageId=3D572293771?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../startup/ui/StartupPageWorkspacePanel.java | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java index ced2aa3767..923a12292c 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java @@ -4,6 +4,7 @@ import com.fr.base.svg.IconUtils; import com.fr.design.components.tooltip.ModernToolTip; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.FRGraphics2D; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.ColorUtils; @@ -17,6 +18,8 @@ import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JToolTip; +import javax.swing.JViewport; +import javax.swing.RepaintManager; import javax.swing.ScrollPaneConstants; import javax.swing.border.EmptyBorder; import java.awt.BasicStroke; @@ -28,9 +31,11 @@ import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridLayout; +import java.awt.Image; import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.image.ImageObserver; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -127,9 +132,15 @@ public class StartupPageWorkspacePanel extends JPanel { this.contentPanel = generateUnLimitContentPanel(this.partitions); this.add(contentPanel, BorderLayout.NORTH); } - private JComponent generateUnLimitContentPanel(List> partitions) { + JComponent panel = generateUnLimitContentPanel0(partitions); + ColorUtils.transparentBackground(panel); + return panel; + } + + private JComponent generateUnLimitContentPanel0(List> partitions) { + JPanel workspaceDescWrapper = new JPanel(); workspaceDescWrapper.setLayout(new BorderLayout(0, 0)); workspaceDescWrapper.setBorder(new EmptyBorder(0, 0, 0, 0)); @@ -144,14 +155,20 @@ public class StartupPageWorkspacePanel extends JPanel { if (needScroll) { // 滚动条 UIScrollPane scrollPane = new UIScrollPane(workspaceDescPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + JViewport viewport = scrollPane.getViewport(); + JViewport scrollViewport = new TransparentScrollViewPort(); + // 动态画图 + scrollViewport.addChangeListener(e -> repaintAll()); + scrollViewport.setView(viewport.getView()); + scrollPane.setViewport(scrollViewport); scrollPane.setBorder(new EmptyBorder(10, 0, 0, 0)); scrollPane.setPreferredSize(new Dimension(CONTENT_WIDTH, SCROLL_HEIGHT)); workspaceDescWrapper.add(scrollPane, BorderLayout.CENTER); + return workspaceDescWrapper; } workspaceDescWrapper.add(workspaceDescPanel, BorderLayout.CENTER); - ColorUtils.transparentBackground(workspaceDescWrapper); return workspaceDescWrapper; } @@ -580,4 +597,27 @@ public class StartupPageWorkspacePanel extends JPanel { this.getRootPane().repaint(); } + + /** + * 支持透明的滚动视图 + */ + private class TransparentScrollViewPort extends JViewport { + + /** + * 从而屏蔽掉 {@link RepaintManager.PaintManager#paintDoubleBuffered(JComponent, Image, Graphics, int, int, int, int)} + * + * @return 创建一个不会实际画图的 Graphics + */ + @Override + public Graphics getGraphics() { + + Graphics graphics = super.getGraphics(); + return new FRGraphics2D((Graphics2D) graphics) { + @Override + public boolean drawImage(Image img, int x, int y, ImageObserver observer) { + return true; + } + }; + } + } }