|
|
@ -8,7 +8,6 @@ import com.fr.design.gui.imenu.UIMenuItem; |
|
|
|
import com.fr.design.gui.imenu.UIPopupMenu; |
|
|
|
import com.fr.design.gui.imenu.UIPopupMenu; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.plugin.chart.VanChartAttrHelper; |
|
|
|
import com.fr.plugin.chart.VanChartAttrHelper; |
|
|
|
import com.fr.plugin.chart.attr.axis.VanChartAxis; |
|
|
|
import com.fr.plugin.chart.attr.axis.VanChartAxis; |
|
|
|
import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; |
|
|
|
import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; |
|
|
@ -18,6 +17,8 @@ import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BoxLayout; |
|
|
|
import javax.swing.BoxLayout; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.FlowLayout; |
|
|
|
import java.awt.FlowLayout; |
|
|
@ -29,8 +30,6 @@ import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
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_W = 56; |
|
|
|
private static final int B_H = 21; |
|
|
|
private static final int B_H = 21; |
|
|
|
private static final int COL_COUNT = 3; |
|
|
|
private static final int COL_COUNT = 3; |
|
|
|
|
|
|
|
private static final int MAX_COUNT = 20; |
|
|
|
|
|
|
|
|
|
|
|
private UIButton addButton; |
|
|
|
private UIButton addButton; |
|
|
|
private UIPopupMenu popupMenu; |
|
|
|
private UIPopupMenu popupMenu; |
|
|
|
|
|
|
|
private UIMenuItem itemX; |
|
|
|
|
|
|
|
private UIMenuItem itemY; |
|
|
|
|
|
|
|
|
|
|
|
private List<ChartAxisButton> indexList_X = new ArrayList<ChartAxisButton>(); |
|
|
|
private List<ChartAxisButton> indexList_X = new ArrayList<ChartAxisButton>(); |
|
|
|
private List<ChartAxisButton> indexList_Y = new ArrayList<ChartAxisButton>(); |
|
|
|
private List<ChartAxisButton> indexList_Y = new ArrayList<ChartAxisButton>(); |
|
|
@ -51,7 +53,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
|
|
|
|
|
|
|
|
private VanChartAxisPane parent; |
|
|
|
private VanChartAxisPane parent; |
|
|
|
|
|
|
|
|
|
|
|
public VanChartAxisButtonPane(VanChartAxisPane vanChartAxisPane){ |
|
|
|
public VanChartAxisButtonPane(VanChartAxisPane vanChartAxisPane) { |
|
|
|
this.parent = vanChartAxisPane; |
|
|
|
this.parent = vanChartAxisPane; |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
|
|
|
@ -66,6 +68,20 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 0)); |
|
|
|
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 0)); |
|
|
|
this.add(buttonPane, BorderLayout.CENTER); |
|
|
|
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); |
|
|
|
addButton.addActionListener(addListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -92,12 +108,12 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
|
|
|
pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
|
|
|
buttonPane.add(pane); |
|
|
|
buttonPane.add(pane); |
|
|
|
} |
|
|
|
} |
|
|
|
if(pane != null) { |
|
|
|
if (pane != null) { |
|
|
|
pane.add(indexList_Y.get(i)); |
|
|
|
pane.add(indexList_Y.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(popupMenu != null){ |
|
|
|
if (popupMenu != null) { |
|
|
|
popupMenu.setVisible(false); |
|
|
|
popupMenu.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -114,19 +130,19 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
indexList_X.clear(); |
|
|
|
indexList_X.clear(); |
|
|
|
indexList_Y.clear(); |
|
|
|
indexList_Y.clear(); |
|
|
|
List<VanChartAxis> xList = plot.getXAxisList(); |
|
|
|
List<VanChartAxis> xList = plot.getXAxisList(); |
|
|
|
for(VanChartAxis axis : xList){ |
|
|
|
for (VanChartAxis axis : xList) { |
|
|
|
ChartAxisButton x = new ChartAxisButton(plot.getXAxisName(axis)); |
|
|
|
ChartAxisButton x = new ChartAxisButton(plot.getXAxisName(axis)); |
|
|
|
x.setToolTipText(plot.getXAxisName(axis)); |
|
|
|
x.setToolTipText(plot.getXAxisName(axis)); |
|
|
|
indexList_X.add(x); |
|
|
|
indexList_X.add(x); |
|
|
|
} |
|
|
|
} |
|
|
|
List<VanChartAxis> yList = plot.getYAxisList(); |
|
|
|
List<VanChartAxis> yList = plot.getYAxisList(); |
|
|
|
for(VanChartAxis axis : yList){ |
|
|
|
for (VanChartAxis axis : yList) { |
|
|
|
ChartAxisButton y = new ChartAxisButton(plot.getYAxisName(axis)); |
|
|
|
ChartAxisButton y = new ChartAxisButton(plot.getYAxisName(axis)); |
|
|
|
y.setToolTipText(plot.getYAxisName(axis)); |
|
|
|
y.setToolTipText(plot.getYAxisName(axis)); |
|
|
|
indexList_Y.add(y); |
|
|
|
indexList_Y.add(y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(indexList_X.isEmpty()){ |
|
|
|
if (indexList_X.isEmpty()) { |
|
|
|
this.removeAll(); |
|
|
|
this.removeAll(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
indexList_X.get(0).setSelected(true); |
|
|
|
indexList_X.get(0).setSelected(true); |
|
|
@ -143,7 +159,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getNewChartName(List<ChartAxisButton> existList, String prefix){ |
|
|
|
public String getNewChartName(List<ChartAxisButton> existList, String prefix) { |
|
|
|
int count = existList.size() + 1; |
|
|
|
int count = existList.size() + 1; |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
String name_test = prefix + count; |
|
|
|
String name_test = prefix + count; |
|
|
@ -165,31 +181,19 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
ActionListener addListener = new ActionListener() { |
|
|
|
ActionListener addListener = new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if(popupMenu == null){ |
|
|
|
popupMenu = new UIPopupMenu(); |
|
|
|
popupMenu = new UIPopupMenu(); |
|
|
|
if (indexList_X.size() < MAX_COUNT) { |
|
|
|
UIMenuItem item_x = new UIMenuItem(VanChartAttrHelper.X_AXIS_PREFIX); |
|
|
|
popupMenu.add(itemX); |
|
|
|
item_x.addActionListener(new ActionListener() { |
|
|
|
} |
|
|
|
@Override |
|
|
|
if (indexList_Y.size() < MAX_COUNT) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
popupMenu.add(itemY); |
|
|
|
addXAxis(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
UIMenuItem item_y = new UIMenuItem(VanChartAttrHelper.Y_AXIS_PREFIX); |
|
|
|
|
|
|
|
item_y.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
addYAxis(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
popupMenu.add(item_x); |
|
|
|
|
|
|
|
popupMenu.add(item_y); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
popupMenu.setVisible(true); |
|
|
|
popupMenu.setVisible(true); |
|
|
|
GUICoreUtils.showPopupMenu(popupMenu, addButton, addButton.getWidth() - popupMenu.getPreferredSize().width, addButton.getY() - 1 + addButton.getHeight()); |
|
|
|
GUICoreUtils.showPopupMenu(popupMenu, addButton, addButton.getWidth() - popupMenu.getPreferredSize().width, addButton.getY() - 1 + addButton.getHeight()); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private void addXAxis(){ |
|
|
|
private void addXAxis() { |
|
|
|
String name = getNewChartName(indexList_X, VanChartAttrHelper.X_AXIS_PREFIX); |
|
|
|
String name = getNewChartName(indexList_X, VanChartAttrHelper.X_AXIS_PREFIX); |
|
|
|
ChartAxisButton button = new ChartAxisButton(name); |
|
|
|
ChartAxisButton button = new ChartAxisButton(name); |
|
|
|
|
|
|
|
|
|
|
@ -199,7 +203,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
layoutPane(); |
|
|
|
layoutPane(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void addYAxis(){ |
|
|
|
private void addYAxis() { |
|
|
|
String name = getNewChartName(indexList_Y, VanChartAttrHelper.Y_AXIS_PREFIX); |
|
|
|
String name = getNewChartName(indexList_Y, VanChartAttrHelper.Y_AXIS_PREFIX); |
|
|
|
ChartAxisButton button = new ChartAxisButton(name); |
|
|
|
ChartAxisButton button = new ChartAxisButton(name); |
|
|
|
|
|
|
|
|
|
|
@ -216,9 +220,10 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
|
|
|
|
|
|
|
|
private class AddButton extends UIButton { |
|
|
|
private class AddButton extends UIButton { |
|
|
|
|
|
|
|
|
|
|
|
public AddButton(Icon icon){ |
|
|
|
public AddButton(Icon icon) { |
|
|
|
super(icon); |
|
|
|
super(icon); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 组件是否需要响应添加的观察者事件 |
|
|
|
* 组件是否需要响应添加的观察者事件 |
|
|
|
* |
|
|
|
* |
|
|
@ -277,19 +282,19 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void noSelected() { |
|
|
|
private void noSelected() { |
|
|
|
for(ChartAxisButton button : indexList_X){ |
|
|
|
for (ChartAxisButton button : indexList_X) { |
|
|
|
button.setSelected(false); |
|
|
|
button.setSelected(false); |
|
|
|
} |
|
|
|
} |
|
|
|
for(ChartAxisButton button : indexList_Y){ |
|
|
|
for (ChartAxisButton button : indexList_Y) { |
|
|
|
button.setSelected(false); |
|
|
|
button.setSelected(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void checkMoveOn(boolean moveOn) { |
|
|
|
private void checkMoveOn(boolean moveOn) { |
|
|
|
for(ChartAxisButton button : indexList_X){ |
|
|
|
for (ChartAxisButton button : indexList_X) { |
|
|
|
button.isMoveOn = false; |
|
|
|
button.isMoveOn = false; |
|
|
|
} |
|
|
|
} |
|
|
|
for(ChartAxisButton button : indexList_Y){ |
|
|
|
for (ChartAxisButton button : indexList_Y) { |
|
|
|
button.isMoveOn = false; |
|
|
|
button.isMoveOn = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|