kerry
8 years ago
5 changed files with 190 additions and 19 deletions
@ -0,0 +1,53 @@
|
||||
package com.fr.design.style.background; |
||||
|
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.general.Background; |
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/1/5. |
||||
*/ |
||||
public class BackgroundButtonPane extends BackgroundPane { |
||||
|
||||
|
||||
public BackgroundButtonPane() { |
||||
super(); |
||||
} |
||||
|
||||
protected void initTabPane() { |
||||
int index = 0; |
||||
for (Class<? extends Background> key : BackgroundFactory.buttonKindsOfKey()) { |
||||
BackgroundUIWrapper wrapper = BackgroundFactory.getButtonWrapper(key); |
||||
wrapper.setIndex(index++); |
||||
tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); |
||||
} |
||||
} |
||||
|
||||
protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { |
||||
return BackgroundFactory.getButtonWrapper(background == null ? null : background.getClass()); |
||||
} |
||||
|
||||
protected BackgroundDetailPane getTabItemPane(Background background, int index) { |
||||
BackgroundDetailPane quickPane = cacheMap.get(index); |
||||
if (quickPane == null) { |
||||
quickPane = BackgroundFactory.createButtonIfAbsent(background == null ? null : background.getClass()); |
||||
quickPane.addChangeListener(backgroundChangeListener); |
||||
cacheMap.put(index, quickPane); |
||||
} |
||||
tabbedPane.setComponentAt(index, quickPane); |
||||
tabbedPane.setSelectedIndex(index); |
||||
return quickPane; |
||||
} |
||||
|
||||
protected BackgroundDetailPane getTabItemPaneByIndex(int index) { |
||||
BackgroundDetailPane quickPane = cacheMap.get(index); |
||||
if (quickPane == null) { |
||||
quickPane = BackgroundFactory.createButtonIfAbsent(index); |
||||
tabbedPane.setComponentAt(index, quickPane); |
||||
cacheMap.put(index, quickPane); |
||||
quickPane.addChangeListener(backgroundChangeListener); |
||||
} |
||||
return quickPane; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,80 @@
|
||||
package com.fr.design.style.background.impl; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Style; |
||||
import com.fr.base.background.ImageBackground; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.general.Background; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.Constants; |
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/1/5. |
||||
*/ |
||||
public class ImageButtonBackgroundPane extends ImageBackgroundPane { |
||||
private UIButton chooseButton; |
||||
private UIButton clearButton; |
||||
|
||||
public ImageButtonBackgroundPane(){ |
||||
super(); |
||||
Style imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); |
||||
previewPane.setImageStyle(imageStyle); |
||||
} |
||||
|
||||
public JPanel initSelectFilePane(){ |
||||
|
||||
JPanel choosePane = new JPanel(new BorderLayout(0, 10)); |
||||
choosePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||
JPanel choosePane1 = new JPanel(new BorderLayout(0, 10)); |
||||
initButton(); |
||||
|
||||
choosePane.add(chooseButton, BorderLayout.NORTH); |
||||
|
||||
choosePane1.add(clearButton,BorderLayout.NORTH); |
||||
choosePane.add(choosePane1,BorderLayout.CENTER); |
||||
|
||||
imageSizeLabel.setHorizontalAlignment(SwingConstants.CENTER); |
||||
choosePane1.add(imageSizeLabel,BorderLayout.CENTER); |
||||
this.add(choosePane,BorderLayout.EAST); |
||||
|
||||
return choosePane; |
||||
} |
||||
|
||||
private void initButton() { |
||||
chooseButton = new UIButton(Inter.getLocText("Image-Select_Picture")); |
||||
chooseButton.addActionListener(selectPictureActionListener); |
||||
clearButton = new UIButton(Inter.getLocText("Clear")); |
||||
clearButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
previewPane.setImage(null); |
||||
previewPane.repaint(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public void imageStyleRepaint(){ |
||||
|
||||
} |
||||
|
||||
|
||||
public void populate(Background background) { |
||||
if(background != null && background instanceof ImageBackground){ |
||||
ImageBackground imageBackground = (ImageBackground) background; |
||||
if(imageBackground.getImage() != null) { |
||||
previewPane.setImage(imageBackground.getImage()); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
public Background update() { |
||||
if(previewPane.getImage() == null) { |
||||
return null; |
||||
} |
||||
return new ImageBackground(previewPane.getImage()); |
||||
} |
||||
} |
Loading…
Reference in new issue