|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.fr.van.chart.custom.component; |
|
|
|
|
|
|
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
|
import com.fr.design.event.UIObserver; |
|
|
|
@ -8,21 +9,30 @@ import com.fr.plugin.chart.custom.CustomPlotFactory;
|
|
|
|
|
import com.fr.plugin.chart.custom.type.CustomPlotType; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.ImageIcon; |
|
|
|
|
import javax.swing.Icon; |
|
|
|
|
import javax.swing.JCheckBox; |
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.flex; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Created by Fangjie on 2016/4/19. |
|
|
|
|
*/ |
|
|
|
|
public class ChartImageCheckOutPane extends BasicPane implements UIObserver { |
|
|
|
|
|
|
|
|
|
private JCheckBox checkBox; |
|
|
|
|
private CustomPlotType customPlotType; |
|
|
|
|
private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>(); |
|
|
|
|
private Icon backgroundIcon; |
|
|
|
|
private final CustomPlotType customPlotType; |
|
|
|
|
private static final int ICON_WIDTH = 56; |
|
|
|
|
private static final int ICON_HEIGHT = 50; |
|
|
|
|
private final ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>(); |
|
|
|
|
|
|
|
|
|
public ChartImageCheckOutPane(CustomPlotType type){ |
|
|
|
|
this(type, false); |
|
|
|
@ -30,40 +40,40 @@ public class ChartImageCheckOutPane extends BasicPane implements UIObserver {
|
|
|
|
|
|
|
|
|
|
public ChartImageCheckOutPane( CustomPlotType type, boolean isSelected){ |
|
|
|
|
this.customPlotType = type; |
|
|
|
|
initComponent(isSelected); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
initCheckBox(isSelected); |
|
|
|
|
|
|
|
|
|
this.add(checkBox, BorderLayout.CENTER); |
|
|
|
|
@Override |
|
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
|
super.paintComponent(g); |
|
|
|
|
if (backgroundIcon != null) { |
|
|
|
|
backgroundIcon.paintIcon(this, g, 0, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CustomPlotType getCustomPlotType() { |
|
|
|
|
return customPlotType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initCheckBox(boolean isSelected) { |
|
|
|
|
private void initComponent(boolean isSelected) { |
|
|
|
|
this.checkBox = new JCheckBox(); |
|
|
|
|
this.checkBox.setSelected(isSelected); |
|
|
|
|
//设置提示
|
|
|
|
|
this.checkBox.setToolTipText(CustomPlotFactory.getTooltipText(this.customPlotType)); |
|
|
|
|
//背景
|
|
|
|
|
checkBox.setIcon(new ImageIcon(getClass().getResource(getIconPath(customPlotType,isSelected)))); |
|
|
|
|
|
|
|
|
|
//设置背景图标
|
|
|
|
|
this.backgroundIcon = new LazyIcon(getIconId(this.customPlotType), new Dimension(ICON_WIDTH, ICON_HEIGHT)); |
|
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
this.add(row(flex(), cell(checkBox)).getComponent(), BorderLayout.NORTH); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getIconPath(CustomPlotType customPlotType, boolean isSelected) { |
|
|
|
|
return isSelected ? CustomPlotFactory.getTypeIconPath(customPlotType)[0] : CustomPlotFactory.getTypeIconPath(customPlotType)[1]; |
|
|
|
|
private String getIconId(CustomPlotType customPlotType) { |
|
|
|
|
return CustomPlotFactory.getTypeIconId(customPlotType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JCheckBox getCheckBox() { |
|
|
|
|
return checkBox; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void checkIconImage(){ |
|
|
|
|
checkBox.setIcon(new ImageIcon(getClass().getResource(getIconPath(customPlotType, checkBox.isSelected())))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setPaneBorder(boolean isRightLine, boolean isBottomLine){ |
|
|
|
|
this.setBorder(BorderFactory.createMatteBorder(1, 1, isBottomLine ? 1 : 0, isRightLine ? 1 : 0, UIConstants.LINE_COLOR)); |
|
|
|
|
} |
|
|
|
@ -77,7 +87,6 @@ public class ChartImageCheckOutPane extends BasicPane implements UIObserver {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return null; |
|
|
|
|