|
|
|
@ -2,14 +2,10 @@ package com.fr.van.chart.custom.component;
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import com.fr.design.gui.ibutton.UITabGroup; |
|
|
|
|
import com.fr.design.gui.ibutton.UIToggleButton; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.Icon; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.GridBagConstraints; |
|
|
|
|
import java.awt.GridBagLayout; |
|
|
|
|
import java.awt.LayoutManager; |
|
|
|
|
|
|
|
|
@ -36,66 +32,6 @@ public class VanChartCustomPlotUITabGroup extends UITabGroup{
|
|
|
|
|
return new GridBagLayout(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void initButton(UIToggleButton labelButton, int buttonIndex) { |
|
|
|
|
|
|
|
|
|
int ButtonWidth = WIDTH / 3; |
|
|
|
|
if (listNum <= 1){ |
|
|
|
|
return; |
|
|
|
|
}else if (listNum == 2){ |
|
|
|
|
ButtonWidth = WIDTH / 2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//将button加入到pane中,以便可以对边框进行控制
|
|
|
|
|
labelButton.setRoundBorder(false); |
|
|
|
|
labelButton.setBorderPainted(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
labelButtonList.add(labelButton); |
|
|
|
|
|
|
|
|
|
int index = labelButtonList.size() - 1; |
|
|
|
|
|
|
|
|
|
JPanel panel = getButtonPanel(labelButton, index); |
|
|
|
|
|
|
|
|
|
GridBagConstraints constraints=new GridBagConstraints(); |
|
|
|
|
|
|
|
|
|
int end = listNum % 3; |
|
|
|
|
|
|
|
|
|
if (end == 1 && index == 0){ |
|
|
|
|
constraints.gridy = 0; |
|
|
|
|
constraints.gridx = 0; |
|
|
|
|
constraints.gridheight = 1; |
|
|
|
|
constraints.gridwidth = 6; |
|
|
|
|
ButtonWidth = WIDTH + 2; |
|
|
|
|
}else if (end == 2 && (index == 0 || index == 1) && listNum != 2){ |
|
|
|
|
constraints.gridy = 0; |
|
|
|
|
constraints.gridx = index == 1 ? 4 : 0; |
|
|
|
|
constraints.gridheight = 1; |
|
|
|
|
constraints.gridwidth = index == 0 ? 4 : 2; |
|
|
|
|
ButtonWidth = index == 0 ? ButtonWidth * 2 + 1 : ButtonWidth; |
|
|
|
|
}else { |
|
|
|
|
int l = ((index + ((end == 0) ? end : (3 - end))) / 3); |
|
|
|
|
constraints.gridy = l; |
|
|
|
|
constraints.gridx = ((index - (l * 3 - (end == 0 ? end : 3 - end))))*2; |
|
|
|
|
constraints.gridheight = 1; |
|
|
|
|
constraints.gridwidth = 2; |
|
|
|
|
} |
|
|
|
|
labelButton.setPreferredSize(new Dimension(ButtonWidth, BUTTON_HEIGHT)); |
|
|
|
|
|
|
|
|
|
this.add(panel, constraints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel getButtonPanel(UIToggleButton labelButton, int index) { |
|
|
|
|
JPanel panel = new JPanel(); |
|
|
|
|
panel.setLayout(new BorderLayout()); |
|
|
|
|
panel.add(labelButton,BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
setPanelBorder(panel, index); |
|
|
|
|
|
|
|
|
|
return panel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setPanelBorder(JPanel panel, int index) { |
|
|
|
|
int end = listNum % 3; |
|
|
|
|
int num = listNum; |
|
|
|
|