public mainUI() {
        setContentPane(contentPane);
        setModal(true);
        getRootPane().setDefaultButton(buttonOK);
        vecList = new ArrayList<IClusterCalculable>();

//        for (int i = 1; i < 19; i++) {
//            typeBox.addItem(i + "");
////            rgbs[i] = (int) (Math.random() * 1000 % 255);
//        }

//        typeBox.addItemListener(new ItemListener() {
//            @Override
//            public void itemStateChanged(ItemEvent e) {
//                currentType = Integer.valueOf((String) e.getItem());
//
//            }
//        });


        canvasPanel.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
                System.out.println("type=" + currentType + "\t" + e.getX() + "-" + e.getY());
                Graphics g = canvasPanel.getGraphics();
                switch (currentType % 4) {
                    case 1:
                        g.setColor(new Color(237, 31, 0));
                        break;
                    case 2:
                        g.setColor(new Color(17, 24, 128));
                        break;
                    case 3:
                        g.setColor(new Color(28, 217, 50));
                        break;
                    default:
                        g.setColor(new Color(248, 27, 248));
                        break;
                }
//                g.setColor(new Color(rgbs[currentType]));
//                g.drawArc(e.getX(), e.getY(), 10, 10, 0, 360);
//                g.drawRoundRect(e.getX(), e.getY(), 10, 10, 0, 360);
                g.fillArc(e.getX(), e.getY(), 10, 10, 0, 360);
                //填充坐标点数据
                float[] vecdata = new float[]{
                        e.getX(), e.getY()
                };
                NodeData nd = new NodeData(vecdata, (int) System.currentTimeMillis());
                vecList.add(nd);
            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });


        btn_export.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JSONArray vecs = new JSONArray();
                for (IClusterCalculable node : vecList) {
                    JSONObject jnode = new JSONObject();
                    try {
                        jnode.put("ID", node.getID());
                        jnode.put("typeID", node.getTypeID());
                        JSONArray vecCoord = new JSONArray();
                        for (float coor : node.getVecValues()) {
                            vecCoord.put(coor);
                        }
                        jnode.put("vecValues", vecCoord);
                    } catch (JSONException e1) {
                        e1.printStackTrace();
                    }
                    vecs.put(jnode);
                }
                pickPath pp = new pickPath(vecs.toString());
                pp.pack();
                pp.setVisible(true);
//                System.out.println(vecs);
            }
        });

        tab_Panel.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                System.out.println(tab_Panel.getSelectedIndex());
//                isAPcluster = ;

            }
        });

        btn_clear.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                onClear();
            }
        });

        btn_cluster.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                NodeData[] vecDatas = new NodeData[vecList.size()];
                for (int i = 0; i < vecList.size(); i++) {
                    IClusterCalculable icc = vecList.get(i);
                    vecDatas[i] = (NodeData) icc;
                }
                IClusterCalculable[][] iClusterCalculables = new IClusterCalculable[0][];
                //检查是什么聚类方法
                switch (tab_Panel.getSelectedIndex()) {
                    case 0://0为AP
                    {
                        int iterNum = Integer.valueOf(text_iterNum.getText());
                        float lam = Float.valueOf(text_lam.getText());
                        float coePK = Float.valueOf(text_PK.getText());
                        APCluster apCluster = new APCluster(vecDatas, iterNum, lam, coePK);
                        iClusterCalculables = apCluster.startCluster();
                    }
                    break;
                    case 1://1为kmeans
                    {
                        int kmeans_iterNum = Integer.valueOf(text_iterNum_kmeans.getText());
                        int clusterNum = Integer.valueOf(text_clusterNum.getText());
                        KMeansCluster kc = new KMeansCluster(clusterNum, kmeans_iterNum);
                        iClusterCalculables = kc.kmeans(vecDatas);
                    }
                    break;
                }

                System.out.println("聚类完毕！");
                canvasPanel.getGraphics().dispose();
                onDrawNodes(iClusterCalculables);
            }
        });


        buttonOK.addActionListener(new

                                           ActionListener() {
                                               public void actionPerformed(ActionEvent e) {
                                                   onOK();
                                               }
                                           }

        );

        buttonCancel.addActionListener(new ActionListener() {
                                           public void actionPerformed(ActionEvent e) {
                                               onCancel();
                                           }
                                       }

        );

        // call onCancel() when cross is clicked
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

        addWindowListener(new WindowAdapter() {
                              public void windowClosing(WindowEvent e) {
                                  onCancel();
                              }
                          }
        );

// call onCancel() on ESCAPE
        contentPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    }