Browse Source

REPORT-60942 加载图视觉更新

bugfix/11.0
kuangshuai 3 years ago
parent
commit
223e15fcbb
  1. 5
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java
  2. 19
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingGlassPane.java
  3. 98
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingPane.java
  4. 28
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ImagePanel.java

5
designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java

@ -40,7 +40,6 @@ public class GuideView extends JDialog {
this.setSize(window.getSize());
this.setLayout(FRGUIPaneFactory.createBorderLayout());
setBg();
this.setGlassPane(new GuideLoadingGlassPane());
DesignerContext.getDesignerFrame().addWindowListener(new WindowAdapter() {
@Override
@ -106,12 +105,16 @@ public class GuideView extends JDialog {
}
public void showLoading() {
this.setGlassPane(GuideLoadingGlassPane.getInstance());
GuideLoadingGlassPane.getInstance().startLoading();
updateGuideViewLocation();
this.setVisible(true);
this.invalidate();
this.getGlassPane().setVisible(true);
}
public void hideLoading() {
GuideLoadingGlassPane.getInstance().stopLoading();
this.getGlassPane().setVisible(false);
repaint();
SwingUtilities.invokeLater(new Runnable() {

19
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingGlassPane.java

@ -9,11 +9,11 @@ import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
public class GuideLoadingGlassPane extends JPanel {
private static final String loadingImagePath = "/com/fr/design/mainframe/guide/loading.gif";
private static GuideLoadingGlassPane loadingPane;
public static GuideLoadingGlassPane getInstance() {
@ -32,16 +32,15 @@ public class GuideLoadingGlassPane extends JPanel {
public void initComponent() {
JPanel loadingView = FRGUIPaneFactory.createBorderLayout_S_Pane();
loadingView.setOpaque(false);
loadingView.setPreferredSize(new Dimension(130, 120));
loadingView.setPreferredSize(new Dimension(150, 90));
JPanel imageContainer = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane();
imageContainer.setOpaque(false);
ImagePanel imagePanel = new ImagePanel(loadingImagePath);
imagePanel.setOpaque(false);
imagePanel.setPreferredSize(new Dimension(84, 84));
imageContainer.add(imagePanel);
imageContainer.add(GuideLoadingPane.getInstance());
UILabel hintLabel = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Loading_Wait"));
hintLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
hintLabel.setHorizontalAlignment(SwingConstants.CENTER);
hintLabel.setForeground(Color.WHITE);
@ -50,4 +49,12 @@ public class GuideLoadingGlassPane extends JPanel {
this.add(loadingView, new GridBagConstraints());
}
public void startLoading() {
GuideLoadingPane.getInstance().start();
}
public void stopLoading() {
GuideLoadingPane.getInstance().stop();
}
}

98
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingPane.java

@ -0,0 +1,98 @@
package com.fr.design.mainframe.guide.ui;
import javax.swing.JPanel;
import javax.swing.Timer;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by kerry on 2020-10-23
*/
public class GuideLoadingPane extends JPanel {
private static final BasicStroke STROKE = new BasicStroke(4);
private static final int FPS = 30;
private static final int START_ANGLE = 90;
private static GuideLoadingPane imagePanel;
private Image image;
private int angle;
private Timer timer;
public static GuideLoadingPane getInstance() {
if (imagePanel == null) {
imagePanel = new GuideLoadingPane();
}
return imagePanel;
}
public GuideLoadingPane() {
this.setOpaque(false);
this.setPreferredSize(new Dimension(50, 50));
timer = new Timer(1000 / FPS, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
repaint();
angle -= 180 / FPS; // 5 degrees per 100 ms = 50 degrees/second
if (angle > -270) {
angle += 2 * 360;
}
}
});
}
public void start() {
angle = START_ANGLE;
timer.start();
}
public void stop() {
timer.stop();
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Composite oldComposite = g2.getComposite();
Stroke oldStroke = g2.getStroke();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
int d = Math.min(getWidth(), getHeight());
int r = d / 2;
Point circlePoint = new Point(getWidth() / 2, getHeight() / 2);
g2.setColor(Color.WHITE);
g2.fillOval(circlePoint.x - r, circlePoint.y - r, d, d);
g2.setColor(Color.BLACK);
int waitCircleD = d / 10;
int waitCircleR = waitCircleD / 2;
g2.fillOval(circlePoint.x - r / 3 - waitCircleR, circlePoint.y - waitCircleR, waitCircleD, waitCircleD);
g2.fillOval(circlePoint.x - waitCircleR, circlePoint.y - waitCircleR, waitCircleD, waitCircleD);
g2.fillOval(circlePoint.x + r / 3 - waitCircleR, circlePoint.y - waitCircleR, waitCircleD, waitCircleD);
g2.setStroke(STROKE);
g2.setColor(Color.decode("#419BF9"));
int lineWidth = (int) STROKE.getLineWidth();
g2.drawArc(circlePoint.x - r + lineWidth / 2 , circlePoint.y - r + lineWidth / 2, d - lineWidth, d - lineWidth, angle, -90);
g2.setStroke(oldStroke);
g2.setComposite(oldComposite);
}
}

28
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ImagePanel.java

@ -1,28 +0,0 @@
package com.fr.design.mainframe.guide.ui;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
/**
* Created by kerry on 2020-10-23
*/
public class ImagePanel extends JPanel {
private Image image;
public ImagePanel(String imagePath) {
image = Toolkit.getDefaultToolkit().createImage(ImagePanel.class
.getResource(imagePath));
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
}
}
Loading…
Cancel
Save