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.
103 lines
3.4 KiB
103 lines
3.4 KiB
/* |
|
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
|
*/ |
|
package com.fr.design.headerfooter; |
|
|
|
import com.fine.theme.light.ui.FineRoundBorder; |
|
import com.fine.theme.utils.FineUIScale; |
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
import com.fr.design.dialog.BasicPane; |
|
import com.fr.design.gui.frpane.ImgChooseWrapper; |
|
import com.fr.design.gui.ibutton.UIButton; |
|
import com.fr.design.gui.ilable.UILabel; |
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
import com.fr.design.style.background.image.ImageFileChooser; |
|
import com.fr.design.style.background.image.ImagePreviewPane; |
|
|
|
|
|
import javax.swing.BorderFactory; |
|
import javax.swing.JPanel; |
|
import javax.swing.JScrollPane; |
|
import java.awt.BorderLayout; |
|
import java.awt.Color; |
|
import java.awt.Dimension; |
|
import java.awt.Image; |
|
import java.awt.event.ActionEvent; |
|
import java.awt.event.ActionListener; |
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
import static com.fine.swing.ui.layout.Layouts.column; |
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
/** |
|
* Image Pane. |
|
*/ |
|
public class ImagePane extends BasicPane { |
|
private ImagePreviewPane imagePreviewPane; |
|
private ImageFileChooser imageFileChooser = null; |
|
|
|
public ImagePane() { |
|
this(true); |
|
} |
|
|
|
public ImagePane(boolean hasPreviewBorder) { |
|
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
|
|
|
//preview pane. |
|
imagePreviewPane = new ImagePreviewPane(); |
|
JScrollPane previewPane = new JScrollPane(imagePreviewPane); |
|
previewPane.setBorder(new FineRoundBorder()); |
|
previewPane.setPreferredSize(new Dimension(FineUIScale.scale(500), FineUIScale.scale(400))); |
|
previewPane.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
imagePreviewPane.setOpaque(false); |
|
previewPane.getViewport().setOpaque(false); |
|
|
|
//select image |
|
JPanel rightPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
UIButton selectImageButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image_Select_Picture")); |
|
rightPane.add(selectImageButton, BorderLayout.NORTH); |
|
selectImageButton.addActionListener(selectPictureActionListener); |
|
|
|
//init image file chooser. |
|
imageFileChooser = new ImageFileChooser(); |
|
imageFileChooser.setMultiSelectionEnabled(false); |
|
|
|
this.add(column( |
|
5, |
|
cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"))), |
|
row( |
|
10, |
|
cell(previewPane).weight(0.9), |
|
cell(rightPane).weight(0.2) |
|
).weight(1) |
|
).getComponent()); |
|
} |
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return "image"; |
|
} |
|
|
|
public void populate(Image image) { |
|
if(image == null) { |
|
return; |
|
} |
|
|
|
this.imagePreviewPane.setImage(image); |
|
} |
|
|
|
public Image update() { |
|
return this.imagePreviewPane.getImageWithSuffix(); |
|
} |
|
|
|
/** |
|
* Select picture. |
|
*/ |
|
ActionListener selectPictureActionListener = new ActionListener() { |
|
public void actionPerformed(ActionEvent evt) { |
|
int returnVal = imageFileChooser.showOpenDialog(ImagePane.this); |
|
ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, null).dealWithImageFile(returnVal); |
|
} |
|
}; |
|
}
|
|
|