From 7c88137c5bf4ecc37bae5c85823021d204f09118 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Tue, 19 Oct 2021 00:48:10 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-60942=20=E8=A7=86=E8=A7=89=E4=BC=98?= =?UTF-8?q?=E5=8C=96--=E9=AB=98=E4=BA=AE=E5=8C=BA=E5=9F=9F=E5=8A=A0?= =?UTF-8?q?=E4=B8=AA5=E5=83=8F=E7=B4=A0=E7=9A=84=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guide/scene/AbstractGuideScene.java | 20 ++++++++- .../guide/creator/GuideCreateUtils.java | 43 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java index 240244fff..95c7c24a4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java @@ -9,6 +9,7 @@ import com.fr.design.mainframe.guide.tip.BubbleTip; import com.fr.design.mainframe.guide.tip.GuideTip; import com.fr.stable.StringUtils; +import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JPanel; @@ -21,6 +22,7 @@ import java.awt.Composite; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; @@ -33,6 +35,7 @@ import java.util.List; public abstract class AbstractGuideScene extends JPanel implements GuideScene { private static final int DEFAULT_ARROW_HEIGHT = 12; private static final int DEFAULT_ARROW_WIDTH = 18; + public static final Insets DEFAULT_HIGHLIGHT_INSETS = new Insets(5, 5, 5, 5); private GuideScene nextScene; private SceneFilter sceneFilter; @@ -169,9 +172,22 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { private UILabel getTargetComponentWithImage(BufferedImage image, Rectangle rectangle) { ImageIcon ic = new ImageIcon(image); - UILabel label = new UILabel(ic); + UILabel label = new UILabel(ic){ + @Override + public Insets getInsets() { + return DEFAULT_HIGHLIGHT_INSETS; + } + }; + + label.setBorder(BorderFactory.createMatteBorder(DEFAULT_HIGHLIGHT_INSETS.top, DEFAULT_HIGHLIGHT_INSETS.left, DEFAULT_HIGHLIGHT_INSETS.bottom, DEFAULT_HIGHLIGHT_INSETS.right, Color.WHITE)); + label.setOpaque(true); - label.setBounds(rectangle); + label.setBounds(new Rectangle( + rectangle.x - DEFAULT_HIGHLIGHT_INSETS.left, + rectangle.y - DEFAULT_HIGHLIGHT_INSETS.top, + rectangle.width + DEFAULT_HIGHLIGHT_INSETS.left + DEFAULT_HIGHLIGHT_INSETS.right, + rectangle.height + DEFAULT_HIGHLIGHT_INSETS.top + DEFAULT_HIGHLIGHT_INSETS.bottom + )); return label; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java index 2e25eaac7..864459276 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java @@ -14,6 +14,7 @@ import com.fr.design.mainframe.FormCreatorDropTarget; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.guide.base.GuideManager; +import com.fr.design.mainframe.guide.scene.AbstractGuideScene; import com.fr.design.mainframe.guide.utils.ScreenImage; import com.fr.design.utils.ComponentUtils; import com.fr.file.FileNodeFILE; @@ -24,6 +25,7 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JDialog; @@ -32,8 +34,10 @@ import javax.swing.JRootPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; import java.awt.Container; +import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; @@ -153,11 +157,50 @@ public class GuideCreateUtils { return new UILabel(ic); } + public static UILabel createTarget(JComponent component, boolean isModal, boolean withBorder) { + ImageIcon ic; + if (isModal) { + ic = new ImageIcon(ScreenImage.createImageWithModal(component)); + } else { + ic = new ImageIcon(ScreenImage.createImage(component)); + } + return createImageTarget(ic, withBorder); + } + + private static UILabel createImageTarget(ImageIcon ic, boolean withBorder) { + if (withBorder) { + Insets insets = AbstractGuideScene.DEFAULT_HIGHLIGHT_INSETS; + UILabel label = new UILabel(ic){ + @Override + public Insets getInsets() { + return insets; + } + }; + + label.setBorder(BorderFactory.createMatteBorder(insets.top, insets.left, insets.bottom, insets.right, Color.WHITE)); + label.setOpaque(true); + return label; + } else { + return new UILabel(ic); + } + } + public static Rectangle getRelativeBounds(Component component, Component parent, int x, int y) { Point point = SwingUtilities.convertPoint(parent,0,0, GuideManager.getInstance().getCurrentGuide().getGuideView().getRootPane()); return new Rectangle(point.x + x, point.y + y, component.getWidth(), component.getHeight()); } + public static Rectangle getRelativeBoundsWithBorder(Component component, Component parent, int x, int y) { + Rectangle rectangle = getRelativeBounds(component, parent, x, y); + Insets insets = AbstractGuideScene.DEFAULT_HIGHLIGHT_INSETS; + return new Rectangle( + rectangle.x - insets.left, + rectangle.y - insets.top, + rectangle.width + insets.left + insets.right, + rectangle.height + insets.top + insets.bottom + ); + } + public static String openGuideFile(String sourcePath, String fileName, String suffix) { String fileWorkPath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, FILE_PREFIX + UUID.randomUUID().toString() + suffix); InputStream inputStream = GuideCreateUtils.class.getResourceAsStream(StableUtils.pathJoin(sourcePath, fileName + suffix));