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