Browse Source

REPORT-70593 图片控件合并主代码

feature/x
Jimmy.Zheng 2 years ago
parent
commit
8cb8c26b26
  1. 42
      designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java

42
designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java

@ -1,17 +1,17 @@
package com.fr.design.designer.ui; package com.fr.design.designer.ui;
import com.fr.general.ImageWithSuffix; import com.fr.general.ImageWithSuffix;
import com.fr.stable.Constants;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import javax.swing.JComponent; import javax.swing.JComponent;
/** /**
* * <p>图片控件中的已选图片展示面板</p>
* <p>图片控件中的已选图片展示面板</p> *
* * @author Jimmy.Zheng created on 2022/8/11 21:17
* @author Jimmy.Zheng created on 2022/8/11 21:17 **/
**/
public class ImgPanel extends JComponent { public class ImgPanel extends JComponent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Image backgroundImage; private Image backgroundImage;
@ -27,40 +27,41 @@ public class ImgPanel extends JComponent {
setImageDisplayMode(modeName); setImageDisplayMode(modeName);
} }
public Image getBackgroundImage() {
return this.backgroundImage;
}
public void setBackgroundImage(Image image) { public void setBackgroundImage(Image image) {
this.backgroundImage = image; this.backgroundImage = image;
repaint(); repaint();
} }
public Image getBackgroundImage() { public int getImageDisplayMode() {
return this.backgroundImage; return this.imageDisplayMode;
} }
public void setImageDisplayMode(int modeName) { public void setImageDisplayMode(int modeName) {
if (modeName == 1) { switch (modeName) {
case Constants.IMAGE_CENTER:
this.modeIndex = 0; this.modeIndex = 0;
} break;
case Constants.IMAGE_TILED:
if (modeName == 0) {
this.imageDisplayMode = 0; this.imageDisplayMode = 0;
this.modeIndex = 1; this.modeIndex = 1;
} break;
case Constants.IMAGE_EXTEND:
if (modeName == 2) {
this.imageDisplayMode = 2; this.imageDisplayMode = 2;
this.modeIndex = 2; this.modeIndex = 2;
} break;
if (modeName == 4) { case Constants.IMAGE_ADJUST:
this.imageDisplayMode = 4; this.imageDisplayMode = 4;
this.modeIndex = 3; this.modeIndex = 3;
break;
default:
} }
repaint(); repaint();
} }
public int getImageDisplayMode() {
return this.imageDisplayMode;
}
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
@ -105,6 +106,7 @@ public class ImgPanel extends JComponent {
int xx = (getWidth() - width) / 2; int xx = (getWidth() - width) / 2;
int yy = (getHeight() - height) / 2; int yy = (getHeight() - height) / 2;
g.drawImage(this.backgroundImage, xx, yy, width, height, this); g.drawImage(this.backgroundImage, xx, yy, width, height, this);
default:
} }
} }
} }

Loading…
Cancel
Save