帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
1.0 KiB

package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
/**
* Created by XiaXiang on 2017/5/2.
*/
public class FilePreviewPane extends JPanel {
public FilePreviewPane(BufferedImage image) {
setLayout(new BorderLayout());
UILabel label = new UILabel();
float widthScale = (AlphaFineConstants.RIGHT_WIDTH) / (float) image.getWidth();
float heightScale = (AlphaFineConstants.CONTENT_HEIGHT) / (float) image.getHeight();
Image showImage;
showImage = widthScale > heightScale ? image.getScaledInstance((int) (image.getWidth() * heightScale), AlphaFineConstants.CONTENT_HEIGHT, Image.SCALE_SMOOTH) : image.getScaledInstance(AlphaFineConstants.RIGHT_WIDTH, (int) (image.getWidth() * widthScale), Image.SCALE_SMOOTH);
label.setIcon(new ImageIcon(showImage));
add(label);
}
}