mxpopstar
2022-05-03 e75ef5f04f61aa5fbd89fd5c413dcee1819b7a91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
package com.teechart;
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.Calendar;
 
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
 
import com.Com;
import com.dev.ntm.BattTestData;
import com.dev.ntm.ntm_page_datamanage_chart;
import com.steema.teechart.TChart;
import com.steema.teechart.drawing.Color;
import com.steema.teechart.drawing.DashStyle;
import com.steema.teechart.events.SeriesMouseEvent;
import com.steema.teechart.events.SeriesMouseListener;
import com.steema.teechart.events.TextResolver;
import com.steema.teechart.legend.LegendStyle;
import com.steema.teechart.styles.Line;
import com.steema.teechart.styles.MarksStyle;
import com.steema.teechart.styles.PointerStyle;
import com.steema.teechart.tools.MarksTip;
import com.steema.teechart.tools.MarksTipMouseAction;
 
/********************************* Tee Line Chart For Vol ***************************************/
public class TMultVolLineChart extends TChart
{
    private static final long serialVersionUID = 1L;
    
    public static final byte LineType_GroupVol = 0;
    public static final byte LineType_BattCurr = 1;
    public static final byte LineType_MonVol = 2;
    public static final byte LineType_MonTmp = 3;
    public static final Color[] Line_Color = new Color[]{
        Color.aqua, Color.bisque, Color.blue, Color.darkGray, Color.fuchsia, 
        Color.gold,Color.green, Color.greenYellow, Color.lightYellow, Color.olive, 
        Color.orange, Color.pink, Color.red, Color.silver, Color.skyBlue, 
        Color.teal, Color.white, Color.yellow};
    
    private ArrayList<Line> al_LineSer;
    private ArrayList<Line> al_PxySer;
    private int PXY_index = -1;
    private String m_LeftAxalValueFormat = "#0.0";
    private BattTestData mChartData = null;
    private int mLineVerticalPos = 0;
    private ntm_page_datamanage_chart m_UI;
    private byte m_LineType;
    private MarksTip tooltip1;
    private String serial_title = "";
    private Line m_SelectedLine = null;
    private int m_UI_GridViewIndex = 0;
    
    private SeriesMouseListener m_SeriesMouseListener = null;
    
    public double maxValue = 0;
    public double minValue = 0;
    
    public TMultVolLineChart(ntm_page_datamanage_chart UI, byte line_type)
    {
        m_UI = UI;
        m_LineType = line_type;
        al_LineSer = new ArrayList<Line>();
        
        this.getChart().getTitle().setText("");
        this.getChart().getTitle().getFont().setColor(Color.GRAY);
        this.getChart().getTitle().setVisible(true);
        if((LineType_MonVol==line_type) || (LineType_MonTmp == line_type)) {
            this.getLegend().setVisible(false);
        } else {
            this.getLegend().setVisible(true);
        }
        this.getLegend().setColor(Color.transparent);
        this.getLegend().setLegendStyle(LegendStyle.SERIES);
        this.getLegend().setFontSeriesColor(true);
        this.getAspect().setView3D(false);
        this.getPanel().setMarginLeft(0);
        this.getPanel().setMarginRight(1);
        this.getPanel().setMarginTop(1.5);
        this.getPanel().setMarginBottom(2);
        this.getPanel().setColor(Color.BLACK);
        this.getAxes().getLeft().getLabels().getFont().setColor(Color.GRAY);
        this.getAxes().getLeft().getGrid().setColor(Color.fromArgb(50, 50, 50));
        this.getAxes().getLeft().getAxisPen().setColor(Color.GRAY);
        this.getAxes().getBottom().getAxisPen().setColor(Color.GRAY);
        this.getAxes().getBottom().getLabels().getFont().setColor(Color.GRAY);
        this.getAxes().getBottom().getLabels().setDateTimeFormat("HH:mm:ss");
        this.getAxes().getBottom().getGrid().setVisible(false);
        
        if(null != m_UI)
        {
            this.addMouseMotionListener(new MouseMotionListener(){
 
                @Override
                public void mouseDragged(MouseEvent arg0) {
                    // TODO Auto-generated method stub
                    
                }
 
                @Override
                public void mouseMoved(MouseEvent arg0) {
                    // TODO Auto-generated method stub
                    if(al_LineSer.size() < 1)
                        return;
                    
                    int posx = Integer.parseInt(String.format("%1.0f", al_LineSer.get(0).xScreenToValue(arg0.getX())));
                    float posy = (float) al_LineSer.get(0).yScreenToValue(arg0.getY());
                    int pos_max = al_LineSer.get(0).getXValues().count;
                    if(posx >= pos_max)
                    {
                        posx = pos_max-1;
                    }
                    
                    if(posx >= 0)
                    {
                        setMLinePosition(posx, posy, PXY_index);
                    }
                }
            });
            
            this.addMouseListener(new MouseListener(){
                @Override
                public void mouseClicked(MouseEvent arg0) {
                    if(arg0.getClickCount() == 2)
                    {
                        setChartViewState();
                    }
                    else if(arg0.getButton() == MouseEvent.BUTTON1)
                    {
                        if(null == al_PxySer)
                            return;
                        
                        if((m_SelectedLine != null) && (null != al_PxySer) && (PXY_index < 0))
                        {
                            for(int n=0; n<al_PxySer.size(); n++)
                            {
                                if(m_SelectedLine.getTitle().equals(al_PxySer.get(n).getTitle()))
                                {
                                    PXY_index = n;
                                    al_PxySer.get(PXY_index).setColor(Color.WHITE);
                                }
                            }
                        }
                        else
                        {
                            if((PXY_index >= 0) && (PXY_index < al_PxySer.size()))
                            {
                                al_PxySer.get(PXY_index).setColor(Color.GRAY);
                                PXY_index = -1;
                            }
                        }
                    }
                    else if(arg0.getButton() == MouseEvent.BUTTON3)
                    {
                        JPopupMenu popupMenu = new JPopupMenu();
                        
                        Line m_SelLine = m_SelectedLine;
                        
                        JMenuItem item_mon_vol_line = new JMenuItem("µ¥ÌåµçѹÇúÏß");
                        JMenuItem item_mon_tmp_line = new JMenuItem("µ¥ÌåζÈÇúÏß");
                        
                        JMenuItem item_posx1 = new JMenuItem("ÏÔʾ²¢Òƶ¯ XA »ù×¼Ïß");
                        JMenuItem item_posx2 = new JMenuItem("ÏÔʾ²¢Òƶ¯ XB »ù×¼Ïß");
                        JMenuItem item_posy1 = new JMenuItem("ÏÔʾ²¢Òƶ¯ YA »ù×¼Ïß");
                        JMenuItem item_posy2 = new JMenuItem("ÏÔʾ²¢Òƶ¯ YB »ù×¼Ïß");
                        
                        JMenuItem item_pos_stop = new JMenuItem("Òþ²Ø XY »ù×¼Ïß");
                        JMenuItem item_posx_hide = new JMenuItem("Òþ²Ø X »ù×¼Ïß");
                        JMenuItem item_posy_hide = new JMenuItem("Òþ²Ø Y »ù×¼Ïß");
                        
                        JMenuItem item_selline = new JMenuItem("½öÑ¡Ôñ¸ÃÇúÏß");
                        JMenuItem item_selall_line = new JMenuItem("ÏÔʾȫ²¿ÇúÏß");
                        
                        JMenuItem item_cutline = new JMenuItem("½Ø¶ÏÊý¾Ý");
                        JMenuItem item_restore_cutline = new JMenuItem("»¹Ô­±»½Ø¶ÏµÄÊý¾Ý");
                        JMenuItem item_show_linetitle = new JMenuItem("ÏÔʾ/Òþ²ØÍ¼Àý");
                        JMenuItem item_restore_curve = new JMenuItem("»¹Ô­Ëõ·Å״̬");
                        JMenuItem item_max_normal = new JMenuItem("×î´ó/Õý³£»¯Í¼±í");
                        
                        ActionListener act_Listener = new ActionListener(){
                            @Override
                            public void actionPerformed(ActionEvent arg0) {
                                if(arg0.getSource() == item_mon_vol_line)
                                {
                                    m_UI.setMonLineChartType(LineType_MonVol);
                                }
                                else if(arg0.getSource() == item_mon_tmp_line)
                                {
                                    m_UI.setMonLineChartType(LineType_MonTmp);
                                }
                                else if(arg0.getSource() == item_posx1)
                                {
                                    PXY_index = 0;
                                    al_PxySer.get(PXY_index).setVisible(true);
                                    al_PxySer.get(PXY_index).setColor(Color.WHITE);
                                }
                                else if(arg0.getSource() == item_posx2)
                                {
                                    PXY_index = 1;
                                    al_PxySer.get(PXY_index).setVisible(true);
                                    al_PxySer.get(PXY_index).setColor(Color.WHITE);
                                }
                                else if(arg0.getSource() == item_posy1)
                                {
                                    PXY_index = 2;
                                    al_PxySer.get(PXY_index).setVisible(true);
                                    al_PxySer.get(PXY_index).setColor(Color.WHITE);
                                }
                                else if(arg0.getSource() == item_posy2)
                                {
                                    PXY_index = 3;
                                    al_PxySer.get(PXY_index).setVisible(true);
                                    al_PxySer.get(PXY_index).setColor(Color.WHITE);
                                }
                                else if(arg0.getSource() == item_pos_stop)
                                {
                                    PXY_index = -1;
                                    al_PxySer.get(0).setVisible(false);
                                    al_PxySer.get(1).setVisible(false);
                                    al_PxySer.get(2).setVisible(false);
                                    al_PxySer.get(3).setVisible(false);
                                    updateLinePositionText();
                                }
                                else if(arg0.getSource() == item_posx_hide)
                                {
                                    PXY_index = -1;
                                    al_PxySer.get(0).setVisible(false);
                                    al_PxySer.get(1).setVisible(false);
                                    updateLinePositionText();
                                }
                                else if(arg0.getSource() == item_posy_hide)
                                {
                                    PXY_index = -1;
                                    al_PxySer.get(2).setVisible(false);
                                    al_PxySer.get(3).setVisible(false);
                                    updateLinePositionText();
                                }
                                else if(arg0.getSource() == item_selline)
                                {
                                    boolean stat = false;
                                    for(int n=1; n<al_LineSer.size(); n++) {
                                        stat = false;
                                        if(al_LineSer.get(n).equals(m_SelLine)) {
                                            stat = true;
                                        }
                                        
                                        al_LineSer.get(n).setVisible(stat);
                                    }
                                } else if(arg0.getSource() == item_selall_line) {
                                    for(int n=1; n<al_LineSer.size(); n++) {
                                        al_LineSer.get(n).setVisible(true);
                                    }
                                }
                                else if(arg0.getSource() == item_cutline)
                                    ;//m_UI.cutOffLineChart(true);
                                else if(arg0.getSource() == item_restore_cutline)
                                    ;//m_UI.cutOffLineChart(false);
                                else if(arg0.getSource() == item_show_linetitle)
                                {
                                    boolean vis = TMultVolLineChart.this.getLegend().getVisible();
                                    TMultVolLineChart.this.getLegend().setVisible(!vis);
                                }
                                else if(arg0.getSource() == item_restore_curve)
                                {
                                    if(null != mChartData)
                                    {
                                        updateChartData(mChartData);
                                        setMLinePosition(mLineVerticalPos, 0, 0);
                                    }
                                }
                                else if(arg0.getSource() == item_max_normal)
                                {
                                    setChartViewState();
                                }
                            }
                        };
                        
                        item_mon_vol_line.addActionListener(act_Listener);
                        item_mon_tmp_line.addActionListener(act_Listener);
                        item_posx1.addActionListener(act_Listener);
                        item_posx2.addActionListener(act_Listener);
                        item_posy1.addActionListener(act_Listener);
                        item_posy2.addActionListener(act_Listener);
                        item_pos_stop.addActionListener(act_Listener);
                        item_posx_hide.addActionListener(act_Listener);
                        item_posy_hide.addActionListener(act_Listener);
                        
                        item_selline.addActionListener(act_Listener);
                        item_selall_line.addActionListener(act_Listener);
                        
                        item_cutline.addActionListener(act_Listener);
                        item_restore_cutline.addActionListener(act_Listener);
                        item_show_linetitle.addActionListener(act_Listener);
                        item_restore_curve.addActionListener(act_Listener);
                        item_max_normal.addActionListener(act_Listener);
                        
                        if((LineType_MonVol == m_LineType) || (LineType_MonTmp == m_LineType)) {
                            popupMenu.add(item_mon_vol_line);
                            popupMenu.add(item_mon_tmp_line);
                            popupMenu.addSeparator();
                        }
                        if((null != al_PxySer) && (al_PxySer.size() == 4))
                        {
                            popupMenu.add(item_posx1);
                            popupMenu.add(item_posx2);
                            popupMenu.add(item_posy1);
                            popupMenu.add(item_posy2);
                            popupMenu.add(item_pos_stop);
                            popupMenu.add(item_posx_hide);
                            popupMenu.add(item_posy_hide);
                            popupMenu.addSeparator();
                        }
                        if(null != m_SelectedLine)
                        {
                            item_selline.setText("½öÏÔʾ " + m_SelectedLine.getTitle() + " ÇúÏß");
                            popupMenu.add(item_selline);
                        }
                        
                        popupMenu.add(item_selall_line);
                        popupMenu.addSeparator();
                        
                        if(LineType_MonVol == m_LineType)
                        {
                            popupMenu.add(item_cutline);
                            popupMenu.add(item_restore_cutline);
                            popupMenu.addSeparator();
                        }
                        popupMenu.add(item_show_linetitle);
                        popupMenu.add(item_restore_curve);
                        popupMenu.addSeparator();
                        popupMenu.add(item_max_normal);
                        popupMenu.show(arg0.getComponent(), arg0.getX(), arg0.getY());
                    }
                }
 
                @Override
                public void mouseEntered(MouseEvent arg0) {
                    // TODO Auto-generated method stub
                }
 
                @Override
                public void mouseExited(MouseEvent arg0) {
                    // TODO Auto-generated method stub
                    
                }
 
                @Override
                public void mousePressed(MouseEvent arg0) {
                    // TODO Auto-generated method stub
                    
                }
 
                @Override
                public void mouseReleased(MouseEvent arg0) {
                    // TODO Auto-generated method stub
                    
                }
            });
        }
        
        tooltip1 = new MarksTip(this.getChart());
        tooltip1.setMouseDelay(50);
        tooltip1.setMouseAction(MarksTipMouseAction.MOVE);
        tooltip1.setStyle(MarksStyle.LABELVALUE);
        tooltip1.setToolTipResolver(new TextResolver(){
 
            @Override
            public String getText(Object arg0, String arg1) {
                // TODO Auto-generated method stub
                return serial_title + arg1.replace(" ", "    ");
            }
        });
        
        //-------------------------------------------------------//
        m_SeriesMouseListener = new SeriesMouseListener(){
 
            @Override
            public void seriesClicked(SeriesMouseEvent arg0) {
                // TODO Auto-generated method stub
                //if(arg0.getMouseEvent().getClickCount() > 1)
                //    System.out.println("seriesClicked");
            }
 
            @Override
            public void seriesEntered(SeriesMouseEvent arg0) {
                // TODO Auto-generated method stub
                Line L = (Line) arg0.getSource();
                if(L.getTitle().contains("#"))
                {
                    L.getLinePen().setWidth(2);
                }
                m_SelectedLine = L;
                serial_title = m_SelectedLine.getTitle() + "    ";
                //int index = (int) L.xScreenToValue((int) arg0.getPoint().getX());
                //System.out.println(al_LineSer.get(0).getLabels().get(index));
            }
            
            @Override
            public void seriesExited(SeriesMouseEvent arg0) {
                // TODO Auto-generated method stub
                Line L = (Line) arg0.getSource();
                if(L.getTitle().contains("#"))
                {
                    L.getLinePen().setWidth(1);
                }
                m_SelectedLine = null;
                serial_title = "";
            }
        };
        //-------------------------------------------------------//
    }
    
    public void setGridViewIndex(int index) {
        m_UI_GridViewIndex = index;
    }
    public int getGridViewIndex() {
        return m_UI_GridViewIndex;
    }
    
    private void setChartViewState()
    {
        m_UI.setChartViewState(getGridViewIndex(), !m_UI.getChartViewState());
    }
    
    public void setLineSerialVisiable(int index, boolean state)
    {
        if(index >= al_LineSer.size())
            return;
        else if(-1 == index)
        {
            for(int n=1; n<al_LineSer.size(); n++)
                al_LineSer.get(n).setVisible(state);
        }
        else
            al_LineSer.get(index).setVisible(state);
    }
    
    private void updateLinePositionText()
    {
        int px1 = (int) al_PxySer.get(0).getXValues().getFirst();
        int px2 = (int) al_PxySer.get(1).getXValues().getFirst();
        float py1 = (float) al_PxySer.get(2).getYValues().getFirst();
        float py2 = (float) al_PxySer.get(3).getYValues().getFirst();
        
        String str_px1 = String.format("%s", (String) al_LineSer.get(0).getLabels().get(px1));
        String str_px2 = String.format("%s", (String) al_LineSer.get(0).getLabels().get(px2));
        //-----------------------------------------------------------//
        Calendar c1 = Calendar.getInstance(); c1.setTime(Com.get_DT_FromStr(str_px1, Com.DTF_hms));
        Calendar c2 = Calendar.getInstance(); c2.setTime(Com.get_DT_FromStr(str_px2, Com.DTF_hms));
        long seconds = (c2.getTimeInMillis() - c1.getTimeInMillis()) / 1000;
        
        String str_dtpx = String.format("%02d:%02d:%02d", Math.abs(seconds)/3600, 
                                            (Math.abs(seconds)%3600)/60, Math.abs(seconds)%60);
        if(seconds < 0) {
            str_dtpx = "-" + str_dtpx;
        }
        str_dtpx = "¦¤PX " + str_dtpx;
        //-----------------------------------------------------------//
        String str_py1 = String.format("PYA %1.3f", py1);
        String str_py2 = String.format("PYB %1.3f", py2);
        String str_dtpy = String.format("¦¤PY %1.3f", py1-py2);
        
        String title_pxy = "";
        if(true == al_PxySer.get(0).getVisible())
        {
            title_pxy = "PXA " + str_px1;
        }
        if(true == al_PxySer.get(1).getVisible())
        {
            if(title_pxy.length() > 0)
            {
                title_pxy += ", ";
            }
            title_pxy += "PXB " + str_px2;
        }
        if((true == al_PxySer.get(0).getVisible()) && (true == al_PxySer.get(1).getVisible()))
        {
            if(title_pxy.length() > 0)
            {
                title_pxy += ", ";
            }
            title_pxy += str_dtpx;
        }
        
        if(true == al_PxySer.get(2).getVisible())
        {
            if(title_pxy.length() > 0)
            {
                title_pxy += ", ";
            }
            title_pxy += str_py1;
        }
        if(true == al_PxySer.get(3).getVisible())
        {
            if(title_pxy.length() > 0)
            {
                title_pxy += ", ";
            }
            title_pxy += str_py2;
        }
        if((true == al_PxySer.get(2).getVisible()) && (true == al_PxySer.get(3).getVisible()))
        {
            if(title_pxy.length() > 0)
            {
                title_pxy += ", ";
            }
            title_pxy += str_dtpy;
        }
        
        this.getChart().getTitle().setText(title_pxy);
    }
    
    public void setMLinePosition(int posx, float poxy, int pxy_index)
    {
        if((null == al_PxySer) || (null == al_LineSer) || (al_LineSer.size() < 1))
        {
            return;
        }
        
        if((pxy_index<0) || (pxy_index>=al_PxySer.size()))
        {
            return;
        }
        
        Line pxy_line = al_PxySer.get(pxy_index);
        if(false == pxy_line.getVisible())
        {
            pxy_line.setVisible(true);
        }
        pxy_line.clear();
        
        mLineVerticalPos = posx;
        /*
        DateTime dt = new DateTime(mChartData.al_TestData.get(pos).testTimeLong*1000 - Com.DT_OFFSET);
        m_Line.add(dt, minValue);
        m_Line.add(dt, maxValue);
        */
        /*
        if(0 == pos)
        {
            int timelong = mChartData.getTestTimeLong(pos);
            m_Line.add(pos, minValue, String.format("%02d:%02d:%02d", timelong/3600, (timelong%3600)/60, timelong%60));
            m_Line.add(pos, maxValue, String.format("%02d:%02d:%02d", timelong/3600, (timelong%3600)/60, timelong%60));
        }
        else
        */
        {
            int pos_max = al_LineSer.get(0).getLabels().getCount();
            if(pos_max < 1)
                return;
            
            if(pxy_index < 2)
            {
                pxy_line.add(posx, minValue);
                pxy_line.add(posx, maxValue);
            }
            else
            {
                pxy_line.add(0, poxy);
                pxy_line.add(pos_max, poxy);
            }
            
            if(al_LineSer.size() > 0)
            {
                if(mLineVerticalPos >= pos_max)
                {
                    mLineVerticalPos = pos_max-1;
                }
                
                updateLinePositionText();
            }
        }
    }
    
    public void clearAllSerialData()
    {
        for(int n=0; n<al_LineSer.size(); n++)
            al_LineSer.get(n).clear();
        
        al_LineSer.clear();
        this.getSeries().clear();
    }
    
    public void updateChartData(BattTestData data)
    {
        mChartData = data;
        clearAllSerialData();
        
        Color Lcolor = Color.LIME;
        int mon_count = 1;
        if((LineType_MonVol == m_LineType) || (LineType_MonTmp == m_LineType)) {
            mon_count = data.MonCount;
        } else if(LineType_BattCurr == m_LineType) {
            Lcolor = Color.GOLD;
        }
        
        int record_count = data.al_TestData.size();
        if(LineType_MonVol == m_LineType)
        {
            m_LeftAxalValueFormat = "#0.00V";
            Line line = new Line();
            line.setValueFormat("#0.000V");
            line.setColor(Line_Color[0]);
            line.setTitle("#avg");
            line.addSeriesMouseListener(m_SeriesMouseListener);
            al_LineSer.add(line);
            
            for(int n=1; n<mon_count+1; n++)
            {
                line = new Line();
                line.setValueFormat("#0.000V");
                line.setColor(Line_Color[n%Line_Color.length]);
                line.setTitle("#" + (n));
                line.addSeriesMouseListener(m_SeriesMouseListener);
                al_LineSer.add(line);
            }
        } else if(LineType_MonTmp == m_LineType) {
            m_LeftAxalValueFormat = "#0.0¡ãC";
            Line line = new Line();
            line.setValueFormat("#0.0¡ãC");
            line.setColor(Line_Color[0]);
            line.setTitle("#avg");
            line.addSeriesMouseListener(m_SeriesMouseListener);
            al_LineSer.add(line);
            
            for(int n=1; n<mon_count+1; n++)
            {
                line = new Line();
                line.setValueFormat("#0.0¡ãC");
                line.setColor(Line_Color[n%Line_Color.length]);
                line.setTitle("#" + (n));
                line.addSeriesMouseListener(m_SeriesMouseListener);
                al_LineSer.add(line);
            }
        } else {
            Line line = new Line();
            if(LineType_BattCurr == m_LineType)
            {
                m_LeftAxalValueFormat = "#0.0A";
                line.setValueFormat("#0.0A");
                line.setTitle("Current");
                line.addSeriesMouseListener(m_SeriesMouseListener);
            }
            else if(LineType_GroupVol == m_LineType)
            {
                m_LeftAxalValueFormat = "#0.0V";
                line.setValueFormat("#0.0V");
                line.setTitle("GroupVol");
                line.addSeriesMouseListener(m_SeriesMouseListener);
            }
            /*
            line.getPointer().setStyle(PointerStyle.CIRCLE);
            line.getPointer().setVertSize(3);
            line.getPointer().setHorizSize(3);
            line.getPointer().setVisible(true);
            */
            line.getLinePen().setWidth(2);
            line.setColor(Lcolor);
            al_LineSer.add(line);
        }
        
        long timelong = 0;
        for(int km=0; km<record_count; km++)
        {
            float[] mon_dat = null;
            
            timelong = data.getTestTimeLong(km);
            boolean data_available = data.al_TestData.get(km).data_Available;
            float tmp_value = 0;
            
            if(LineType_MonVol == m_LineType)
            {
                mon_dat = data.getMonData(BattTestData.MonData_Vol, km);
                for(int n=0; n<mon_count+1; n++)
                {
                    if(0 == n)
                        tmp_value = Com.getAvrageData(mon_dat, mon_count);
                    else
                        tmp_value = mon_dat[n-1];
                    
                    Color t_color = Line_Color[n%Line_Color.length];
                    if(false == data_available)
                        t_color = Color.fromArgb(50, 50, 50);
                    
                    //al_LineSer.get(n).add(new DateTime(timelong*1000 - Com.DT_OFFSET), tmp_value, t_color);
                    
                    al_LineSer.get(n).add(tmp_value, 
                            String.format("%02d:%02d:%02d", timelong/3600, (timelong%3600)/60, timelong%60),
                            t_color);
                }
            }
            else if(LineType_MonTmp == m_LineType)
            {
                mon_dat = data.getMonData(BattTestData.MonData_Tmp, km);
                for(int n=0; n<mon_count+1; n++)
                {
                    if(0 == n)
                        tmp_value = Com.getAvrageData(mon_dat, mon_count);
                    else
                        tmp_value = mon_dat[n-1];
                    
                    Color t_color = Line_Color[n%Line_Color.length];
                    if(false == data_available)
                        t_color = Color.fromArgb(50, 50, 50);
                    
                    //al_LineSer.get(n).add(new DateTime(timelong*1000 - Com.DT_OFFSET), tmp_value, t_color);
                    al_LineSer.get(n).add(tmp_value, 
                            String.format("%02d:%02d:%02d", timelong/3600, (timelong%3600)/60, timelong%60),
                            t_color);
                }
            }
            else
            {
                if(LineType_GroupVol == m_LineType)
                    tmp_value = data.al_TestData.get(km).groupVol;
                else if(LineType_BattCurr == m_LineType)
                    tmp_value = data.al_TestData.get(km).testCurr;
                
                Color t_color = Lcolor;
                if(false == data_available)
                    t_color = Color.fromArgb(50, 50, 50);
                
                //al_LineSer.get(n).add(new DateTime(timelong*1000 - Com.DT_OFFSET), tmp_value, t_color);
                
                al_LineSer.get(0).add(tmp_value, 
                        String.format("%02d:%02d:%02d", timelong/3600, (timelong%3600)/60, timelong%60),
                        t_color);
            }
        }
        
        maxValue = -90000;
        minValue = 90000;
        
        for(int n=0; n<al_LineSer.size(); n++)
        {
            Line line = al_LineSer.get(n);
            this.addSeries(line);
            if(maxValue <= line.getMaxYValue())
                maxValue = line.getMaxYValue();
            if(minValue >= line.getMinYValue())
                minValue = line.getMinYValue();
        }
        if(minValue > 0) {
            minValue *= 0.95;
            if(LineType_BattCurr == m_LineType){
                if(Math.abs(minValue) < 5) {
                    minValue = -5;
                }
            }
        } else {
            minValue = (minValue * 1.05);
            if(LineType_BattCurr == m_LineType){
                minValue -= 5;
            }
        }
        
        if(maxValue > 0) {
            maxValue = maxValue*1.05;
            if(LineType_BattCurr == m_LineType){
                maxValue += 5;
            }
        } else {
            maxValue *= 0.95;
            if(LineType_BattCurr == m_LineType){
                if(Math.abs(maxValue) < 5) {
                    maxValue = 5;
                }
            }
        }
        
        al_PxySer = new ArrayList<Line>();
        for(int n=0; n<4; n++)
        {
            Line pL = new Line();
            pL.setVisible(false);
            pL.setTitle("#POS");
            pL.setColor(Color.GRAY);
            pL.getLinePen().setStyle(DashStyle.DASH);
            pL.getPointer().setStyle(PointerStyle.CIRCLE);
            pL.getPointer().setVertSize(3);
            pL.getPointer().setHorizSize(3);
            pL.getPointer().setVisible(true);
            pL.getXValues().setDateTime(true);
            pL.addSeriesMouseListener(m_SeriesMouseListener);
            al_PxySer.add(pL);
            this.addSeries(pL);
        }
        al_PxySer.get(0).setTitle("PX1");
        al_PxySer.get(1).setTitle("PX2");
        al_PxySer.get(2).setTitle("PY1");
        al_PxySer.get(3).setTitle("PY2");
        
        this.getZoom().undo();
        
        if(al_LineSer.size() < 1)
            return;
        /*
        long min_x = (long) ((0 - Com.DT_OFFSET) - Math.abs(timelong*1000*0.02));
        long max_x = (long) ((timelong*1000 - Com.DT_OFFSET) + Math.abs(timelong*1000*0.1));
        this.getAxes().getBottom().setMinMax(min_x, max_x);
        */
        this.getAxes().getLeft().getLabels().setValueFormat(m_LeftAxalValueFormat);
        this.getAxes().getLeft().setMinMax(minValue, maxValue);
        this.getAxes().getBottom().setMinMax(0-al_LineSer.get(0).getMaxXValue()*0.02, 
                                                al_LineSer.get(0).getMaxXValue()*1.1);
    }
}
/************************************************************************************************/