@ -8,7 +8,6 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu ;
import com.fr.design.utils.gui.GUICoreUtils ;
import com.fr.general.ComparatorUtils ;
import com.fr.plugin.chart.VanChartAttrHelper ;
import com.fr.plugin.chart.attr.axis.VanChartAxis ;
import com.fr.plugin.chart.attr.plot.VanChartAxisPlot ;
@ -18,6 +17,8 @@ import javax.swing.BorderFactory;
import javax.swing.BoxLayout ;
import javax.swing.Icon ;
import javax.swing.JPanel ;
import java.util.ArrayList ;
import java.util.List ;
import java.awt.BorderLayout ;
import java.awt.Dimension ;
import java.awt.FlowLayout ;
@ -29,8 +30,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener ;
import java.awt.geom.Rectangle2D ;
import java.awt.image.BufferedImage ;
import java.util.ArrayList ;
import java.util.List ;
/ * *
* 坐标轴 - 上方按钮界面
@ -41,9 +40,12 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> {
private static final int B_W = 56 ;
private static final int B_H = 21 ;
private static final int COL_COUNT = 3 ;
private static final int MAX_COUNT = 20 ;
private UIButton addButton ;
private UIPopupMenu popupMenu ;
private UIMenuItem itemX ;
private UIMenuItem itemY ;
private List < ChartAxisButton > indexList_X = new ArrayList < ChartAxisButton > ( ) ;
private List < ChartAxisButton > indexList_Y = new ArrayList < ChartAxisButton > ( ) ;
@ -66,6 +68,20 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> {
buttonPane . setBorder ( BorderFactory . createEmptyBorder ( 0 , 5 , 10 , 0 ) ) ;
this . add ( buttonPane , BorderLayout . CENTER ) ;
itemX = new UIMenuItem ( VanChartAttrHelper . X_AXIS_PREFIX ) ;
itemX . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
addXAxis ( ) ;
}
} ) ;
itemY = new UIMenuItem ( VanChartAttrHelper . Y_AXIS_PREFIX ) ;
itemY . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
addYAxis ( ) ;
}
} ) ;
addButton . addActionListener ( addListener ) ;
}
@ -165,24 +181,12 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> {
ActionListener addListener = new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
if ( popupMenu = = null ) {
popupMenu = new UIPopupMenu ( ) ;
UIMenuItem item_x = new UIMenuItem ( VanChartAttrHelper . X_AXIS_PREFIX ) ;
item_x . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
addXAxis ( ) ;
}
} ) ;
UIMenuItem item_y = new UIMenuItem ( VanChartAttrHelper . Y_AXIS_PREFIX ) ;
item_y . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
addYAxis ( ) ;
if ( indexList_X . size ( ) < MAX_COUNT ) {
popupMenu . add ( itemX ) ;
}
} ) ;
popupMenu . add ( item_x ) ;
popupMenu . add ( item_y ) ;
if ( indexList_Y . size ( ) < MAX_COUNT ) {
popupMenu . add ( itemY ) ;
}
popupMenu . setVisible ( true ) ;
GUICoreUtils . showPopupMenu ( popupMenu , addButton , addButton . getWidth ( ) - popupMenu . getPreferredSize ( ) . width , addButton . getY ( ) - 1 + addButton . getHeight ( ) ) ;
@ -219,6 +223,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> {
public AddButton ( Icon icon ) {
super ( icon ) ;
}
/ * *
* 组件是否需要响应添加的观察者事件
*