package com.dev.ntm; import java.awt.BorderLayout; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Properties; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JSplitPane; import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.EtchedBorder; import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import com.Com; import com.dev.ntm.BattTestData.MonData; import com.dev.ntm.BattTestData.TestData; import com.dev.ntm.data.fbo.FboData; import com.dev.ntm.data.fbo.FboDataInf; import com.steema.teechart.drawing.Color; import com.teechart.TBarChart; import com.teechart.TBarChart_fbs; import com.teechart.TMultVolLineChart; import javax.swing.BoxLayout; import javax.swing.JCheckBox; import java.awt.event.ItemListener; import java.awt.event.ItemEvent; public class ntm_page_datamanage_chart extends JPanel{ private static final String PropertiesFileName = "cn.properties"; public final static int TestDataType_RT_MONITOR = 0; public final static int TestDataType_ALL_TESTDATA = 1; public final static int TestDataType_DISCHARGE = 2; public final static int TestDataType_CHARGE = 3; public final static int TestDataType_RES_SER = 4; public final static int ChartType_GroupVol = 0; public final static int ChartType_Current = 1; public final static int ChartType_MonBar = 2; public final static int ChartType_MonLine = 3; public final static byte ShowBattLowType_None = 0; public final static byte ShowBattLowType_All = 1; public final static byte ShowBattLowType_Now = 2; public final static byte ShowBattLowType_Sel = 3; private static final long serialVersionUID = 1L; private boolean mChartViewStateMax = false; public int mBattGroupId = 10001; private String mBattGroupName = ""; public BattTestData mBattTestData = new BattTestData(); public TBarChart m_TBarMonVolChart; public TBarChart m_TBarMonTmpChart; public TBarChart m_TBarMonResChart; public TBarChart m_TBarConnResChart; public TMultVolLineChart m_MonVolLineChart; public TMultVolLineChart m_MonTmpLineChart; public TMultVolLineChart m_GroupLineChart; public TMultVolLineChart m_CurrLineChart; public BattGroupInf m_BattGroupInf = new BattGroupInf(); private byte m_ShowBattLowType = ShowBattLowType_None; private byte m_TBarChartDataType = BattTestData.MonData_Vol; private int m_TBarChartDataIndex = 0; public ArrayList m_MonLineShowList = new ArrayList(); private JLabel Label_ChartTitle; private JLabel lb_battstate; private JLabel lb_groupvol; private JLabel lb_battcurr; private JLabel lb_testtime; private JLabel lb_testtimelong; private JLabel lb_testcap; private JLabel lb_restcap; //private JLabel lb_resttime; private JTextField tf_BattState; private JTextField tf_TestStartTime; private JTextField tf_TestTimeLong; private JTextField tf_TestCap; public JSlider m_DataIndexSlider; private JSplitPane m_SplitPane_Chart; private JSplitPane m_SplitPane_Chart_1; private JSplitPane m_SplitPane_Chart_2; private JSplitPane m_SplitPane_ListTable; private JTextField tf_TestCurr; private JTextField tf_GroupVol; private JTextField tf_RestCap; private JTextField tf_RestTime; private Properties mProperties = null; public JCheckBox max_CheckBox; private JPanel parent_panel = null; public ntm_page_datamanage_chart(JPanel parent_panel_t) { parent_panel = parent_panel_t; InputStream fis = this.getClass().getResourceAsStream(PropertiesFileName); mProperties = new Properties(); try { mProperties.load(fis); fis.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } this.setLayout(new BorderLayout(0, 0)); m_TBarMonTmpChart = new TBarChart(this, TBarChart_fbs.Bar_Type_MonTmp); m_TBarMonResChart = new TBarChart(this, TBarChart_fbs.Bar_Type_MonRes); m_TBarConnResChart = new TBarChart(this, TBarChart_fbs.Bar_Type_ConnRes); m_MonTmpLineChart = new TMultVolLineChart(this, TMultVolLineChart.LineType_MonTmp); /*******************************************************************************************/ /*******************************************************************************************/ JPanel panel_chart = new JPanel(); panel_chart.setLayout(new BorderLayout(0, 0)); this.add(panel_chart, BorderLayout.CENTER); JPanel TeeChart_panel = new JPanel(); add(TeeChart_panel, BorderLayout.CENTER); TeeChart_panel.setLayout(new BorderLayout(0, 0)); m_DataIndexSlider = new JSlider(); m_DataIndexSlider.setMaximum(0); m_DataIndexSlider.setMinimum(0); m_DataIndexSlider.setValue(0); m_DataIndexSlider.addChangeListener(new ChangeListener(){ @Override public void stateChanged(ChangeEvent arg0) { if(m_DataIndexSlider.getMaximum() > 0) { upDateSingleRecordMonvol(m_DataIndexSlider.getValue(), false); } } }); JPanel panel = new JPanel(); TeeChart_panel.add(panel, BorderLayout.NORTH); panel.setLayout(new BorderLayout(0, 0)); Label_ChartTitle = new JLabel(); Label_ChartTitle.setFont(new Font("Dialog", Font.BOLD, 12)); panel.add(Label_ChartTitle); Label_ChartTitle.setHorizontalAlignment(SwingConstants.CENTER); Label_ChartTitle.setText(" "); max_CheckBox = new JCheckBox("\u9690\u85CF\u5DE6\u680F"); max_CheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { parent_panel.setVisible(!max_CheckBox.isSelected()); } }); //panel.add(max_CheckBox, BorderLayout.WEST); m_TBarMonVolChart = new TBarChart(this, TBarChart_fbs.Bar_Type_MonVol); m_GroupLineChart = new TMultVolLineChart(this, TMultVolLineChart.LineType_GroupVol); m_CurrLineChart = new TMultVolLineChart(this, TMultVolLineChart.LineType_BattCurr); m_MonVolLineChart = new TMultVolLineChart(this, TMultVolLineChart.LineType_MonVol); m_SplitPane_Chart_1 = new JSplitPane(); m_SplitPane_Chart_1.setOrientation(JSplitPane.HORIZONTAL_SPLIT); m_SplitPane_Chart_1.addComponentListener(new ComponentAdapter(){ @Override public void componentResized(ComponentEvent e){ if(false == mChartViewStateMax) { m_SplitPane_Chart_1.setDividerLocation(0.5); } } }); m_SplitPane_Chart_2 = new JSplitPane(); m_SplitPane_Chart_2.setOrientation(JSplitPane.HORIZONTAL_SPLIT); m_SplitPane_Chart_2.addComponentListener(new ComponentAdapter(){ @Override public void componentResized(ComponentEvent e){ if(false == mChartViewStateMax) { m_SplitPane_Chart_2.setDividerLocation(0.5); } } }); m_SplitPane_Chart = new JSplitPane(); m_SplitPane_Chart.setOrientation(JSplitPane.VERTICAL_SPLIT); m_SplitPane_Chart.setTopComponent(m_SplitPane_Chart_1); TeeChart_panel.add(m_SplitPane_Chart, BorderLayout.CENTER); m_SplitPane_Chart.setBottomComponent(m_SplitPane_Chart_2); m_SplitPane_Chart.setResizeWeight(0); m_SplitPane_Chart.addComponentListener(new ComponentAdapter(){ @Override public void componentResized(ComponentEvent e){ if(false == mChartViewStateMax) { m_SplitPane_Chart.setDividerLocation(0.5); } } }); TeeChart_panel.add(m_DataIndexSlider, BorderLayout.SOUTH); JPanel panel_1 = new JPanel(); panel_1.setBorder(new CompoundBorder((Border) new TitledBorder((Border) new EtchedBorder(EtchedBorder.LOWERED, null, null), "", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)), null)); this.add(panel_1, BorderLayout.NORTH); panel_1.setLayout(new GridLayout(0, 4, 8, 2)); JPanel panel_testtype = new JPanel(); panel_1.add(panel_testtype); panel_testtype.setLayout(new BoxLayout(panel_testtype, BoxLayout.X_AXIS)); //panel.setLayout(new BorderLayout(0, 0)); lb_battstate = new JLabel(mProperties.getProperty("monitor_page_tf_label_testtype")); panel_testtype.add(lb_battstate/*, BorderLayout.WEST*/); lb_battstate.setHorizontalAlignment(SwingConstants.TRAILING); tf_BattState = new JTextField(); panel_testtype.add(tf_BattState/*, BorderLayout.CENTER*/); tf_BattState.setColumns(10); JPanel panel_groupvol = new JPanel(); panel_1.add(panel_groupvol); panel_groupvol.setLayout(new BoxLayout(panel_groupvol, BoxLayout.X_AXIS)); lb_groupvol = new JLabel(mProperties.getProperty("monitor_page_tf_label_groupvol")); panel_groupvol.add(lb_groupvol); tf_GroupVol = new JTextField(); panel_groupvol.add(tf_GroupVol); tf_GroupVol.setColumns(10); JPanel panel_battcurr = new JPanel(); panel_1.add(panel_battcurr); panel_battcurr.setLayout(new BoxLayout(panel_battcurr, BoxLayout.X_AXIS)); lb_battcurr = new JLabel(mProperties.getProperty("monitor_page_tf_label_battcurr")); panel_battcurr.add(lb_battcurr); tf_TestCurr = new JTextField(); panel_battcurr.add(tf_TestCurr); tf_TestCurr.setColumns(10); JPanel panel_teststarttime = new JPanel(); panel_1.add(panel_teststarttime); panel_teststarttime.setLayout(new BoxLayout(panel_teststarttime, BoxLayout.X_AXIS)); lb_testtime = new JLabel(mProperties.getProperty("monitor_page_tf_label_testtime")); panel_teststarttime.add(lb_testtime); lb_testtime.setHorizontalAlignment(SwingConstants.TRAILING); tf_TestStartTime = new JTextField(); panel_teststarttime.add(tf_TestStartTime); tf_TestStartTime.setColumns(10); JPanel panel_testtimelong = new JPanel(); panel_1.add(panel_testtimelong); panel_testtimelong.setLayout(new BoxLayout(panel_testtimelong, BoxLayout.X_AXIS)); lb_testtimelong = new JLabel(mProperties.getProperty("monitor_page_tf_label_testlong")); panel_testtimelong.add(lb_testtimelong); lb_testtimelong.setHorizontalAlignment(SwingConstants.TRAILING); tf_TestTimeLong = new JTextField(); panel_testtimelong.add(tf_TestTimeLong); tf_TestTimeLong.setColumns(10); JPanel panel_testcap = new JPanel(); panel_1.add(panel_testcap); panel_testcap.setLayout(new BoxLayout(panel_testcap, BoxLayout.X_AXIS)); lb_testcap = new JLabel(mProperties.getProperty("monitor_page_tf_label_testcap")); panel_testcap.add(lb_testcap); lb_testcap.setHorizontalAlignment(SwingConstants.TRAILING); tf_TestCap = new JTextField(); panel_testcap.add(tf_TestCap); tf_TestCap.setColumns(10); JPanel panel_restcap = new JPanel(); panel_1.add(panel_restcap); panel_restcap.setLayout(new BoxLayout(panel_restcap, BoxLayout.X_AXIS)); lb_restcap = new JLabel(mProperties.getProperty("monitor_page_tf_label_restcap")); panel_restcap.add(lb_restcap); tf_RestCap = new JTextField(); panel_restcap.add(tf_RestCap); tf_RestCap.setColumns(10); JPanel panel_resttime = new JPanel(); panel_1.add(panel_resttime); //lb_resttime = new JLabel(mProperties.getProperty("monitor_page_tf_label_resttime")); tf_RestTime = new JTextField(); tf_RestTime.setColumns(10); panel_resttime.setLayout(new BorderLayout(0, 0)); panel_resttime.add(max_CheckBox, BorderLayout.CENTER); //panel_resttime.add(tf_RestTime); /*******************************************************************************************/ setChartViewType(); setChartViewState(ChartType_MonBar, false); } public void putAndShowFBOData(String ntm_sel_file, FboDataInf data_inf, ArrayList al_fbo_data) { Label_ChartTitle.setText(ntm_sel_file); m_BattGroupInf.MonCapStd = data_inf.STDCap; m_BattGroupInf.BattCount = data_inf.BattSum; m_BattGroupInf.MonVolStd = data_inf.MonomerVol; mBattTestData.clearAllData(); mBattTestData = new BattTestData(); mBattTestData.BattTestStopType = data_inf.StopType; mBattTestData.MonCount = data_inf.BattSum; for(int n=0; n val_index = m_MonLineShowList; if(val_index.size() > 0) { m_MonVolLineChart.setLineSerialVisiable(-1, false); m_MonTmpLineChart.setLineSerialVisiable(-1, false); for(int n=0; n