private JButton createColorBarButton(BarGraph barGraph, int index) { // Button JButton colorBtn = new JButton(); colorBtn.setName(String.valueOf(index)); colorBtn.setFont(FONT_SMALL); colorBtn.addActionListener(this); colorBtn.setBackground(barGraph.getBackColor()); return colorBtn; }
private Color[] getBackColors() { Color[] backColors = new Color[nbColToGraph]; int i = 0; for (BarGraph bar : eltList) { if (bar.getChkBox().isSelected()) { backColors[i] = bar.getBackColor(); i++; } } return backColors; }
@Override public void actionPerformed(ActionEvent event) { boolean forceReloadData = false; final Object eventSource = event.getSource(); if (eventSource == displayButton) { actionMakeGraph(); } else if (eventSource == saveGraph) { saveGraphToFile = true; try { ActionRouter.getInstance() .getAction(ActionNames.SAVE_GRAPHICS, SaveGraphics.class.getName()) .doAction(new ActionEvent(this, 1, ActionNames.SAVE_GRAPHICS)); } catch (Exception e) { log.error(e.getMessage()); } } else if (eventSource == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("statistics.csv"); // $NON-NLS-1$ if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO Charset ? CSVSaveService.saveCSVStats( getAllTableData(), writer, saveHeaders.isSelected() ? COLUMNS : null); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } else if (eventSource == chooseForeColor) { Color color = JColorChooser.showDialog( null, JMeterUtils.getResString("aggregate_graph_choose_color"), // $NON-NLS-1$ colorBarGraph); if (color != null) { colorForeGraph = color; } } else if (eventSource == syncWithName) { graphTitle.setText(namePanel.getName()); } else if (eventSource == dynamicGraphSize) { // if use dynamic graph size is checked, we disable the dimension fields if (dynamicGraphSize.isSelected()) { graphWidth.setEnabled(false); graphHeight.setEnabled(false); } else { graphWidth.setEnabled(true); graphHeight.setEnabled(true); } } else if (eventSource == columnSelection) { if (columnSelection.isSelected()) { columnMatchLabel.setEnabled(true); applyFilterBtn.setEnabled(true); caseChkBox.setEnabled(true); regexpChkBox.setEnabled(true); } else { columnMatchLabel.setEnabled(false); applyFilterBtn.setEnabled(false); caseChkBox.setEnabled(false); regexpChkBox.setEnabled(false); // Force reload data forceReloadData = true; } } // Not 'else if' because forceReloadData if (eventSource == applyFilterBtn || forceReloadData) { if (columnSelection.isSelected() && columnMatchLabel.getText() != null && columnMatchLabel.getText().length() > 0) { pattern = createPattern(columnMatchLabel.getText()); } else if (forceReloadData) { pattern = null; matcher = null; } if (getFile() != null && getFile().length() > 0) { clearData(); FilePanel filePanel = (FilePanel) getFilePanel(); filePanel.actionPerformed(event); } } else if (eventSource instanceof JButton) { // Changing color for column JButton btn = ((JButton) eventSource); if (btn.getName() != null) { try { BarGraph bar = eltList.get(Integer.parseInt(btn.getName())); Color color = JColorChooser.showDialog(null, bar.getLabel(), bar.getBackColor()); if (color != null) { bar.setBackColor(color); btn.setBackground(bar.getBackColor()); } } catch (NumberFormatException nfe) { } // nothing to do } } }