@Override public void actionPerformed(ActionEvent event) { if (event.getActionCommand().equals("random")) { // create some random data and populate the scatter plot panel Random rand = new Random(); float xValues[] = new float[2000 + rand.nextInt(1000)]; float yValues[] = new float[xValues.length]; float zValues[] = new float[2000 + rand.nextInt(1000)]; for (int i = 0; i < xValues.length; i++) { xValues[i] = rand.nextFloat() * 400.f; yValues[i] = rand.nextFloat() * 600.f; } visPanel.setData( xValues, yValues, zValues, columnNames.get(y_index), columnNames.get(x_index), maxminXY); } else if (event.getActionCommand().equals("exit")) { System.exit(0); } else { // Additionally, add the selecting function to the menu bar // When choose the column for the menu bar, update the JCombox String cmd = event.getActionCommand(); String[] cmdParam = cmd.split(","); // for (String str : cmdParam) { // System.out.println(str); // } if (cmdParam[0].equals("SetX")) { x_index = columnNames.indexOf(cmdParam[1]); // Update the JCombox jbX.setSelectedItem(cmdParam[1]); } else { y_index = columnNames.indexOf(cmdParam[1]); // Update the JCombox jbY.setSelectedItem(cmdParam[1]); } maxminXY = new Double[] {max[x_index], min[x_index], max[y_index], min[y_index]}; float xValues[] = new float[rows.size()]; float yValues[] = new float[rows.size()]; float zValues[] = new float[rows.size()]; for (int irow = 0; irow < rows.size(); irow++) { ArrayList<Double> row = rows.get(irow); xValues[irow] = row.get(x_index).floatValue(); yValues[irow] = row.get(y_index).floatValue(); if (z_index >= 0) { zValues[irow] = (float) ((row.get(z_index) - min[z_index]) / (max[z_index] - min[z_index])); } else zValues[irow] = 1; // xValues[irow] = (float) ((row.get(x_index) - min[x_index]) / (max[x_index] - // min[x_index])); // System.out.println(xValues[irow]); // yValues[irow] = (float) ((row.get(y_index) - min[y_index]) / (max[y_index] - // min[y_index])); // System.out.println(yValues[irow]); } // visPanel.setData(xValues, yValues, columnNames.get(x_index), columnNames.get(y_index)); visPanel.setData( xValues, yValues, zValues, columnNames.get(y_index), columnNames.get(x_index), maxminXY); } }