List of usage examples for org.jfree.chart ChartPanel getChart
public JFreeChart getChart()
From source file:com.compomics.cell_coord.gui.controller.summary.VisualizeTracksController.java
/** * Initialize main view//from ww w. j av a 2 s . c om */ private void initVisualizeTracksPanel() { // create new view object visualizeTracksPanel = new VisualizeTracksPanel(); // add radiobuttons to a button group ButtonGroup scaleAxesButtonGroup = new ButtonGroup(); scaleAxesButtonGroup.add(visualizeTracksPanel.getDoNotScaleAxesRadioButton()); scaleAxesButtonGroup.add(visualizeTracksPanel.getScaleAxesRadioButton()); // another button group for the shifted/unshifted coordinates ButtonGroup shiftedCoordinatesButtonGroup = new ButtonGroup(); shiftedCoordinatesButtonGroup.add(visualizeTracksPanel.getRawCoordRadioButton()); shiftedCoordinatesButtonGroup.add(visualizeTracksPanel.getRosePlotRadioButton()); /** * Action Listeners. */ // do not scale the axes visualizeTracksPanel.getDoNotScaleAxesRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem()); boolean useRawData = visualizeTracksPanel.getRawCoordRadioButton().isSelected(); resetPlotLogic(); generateDataForPlots(useRawData); // use the data to set the charts setChartsWithCollections(nCols); } }); // scale the axes (use a common scale for all the samples) visualizeTracksPanel.getScaleAxesRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean useRawData = visualizeTracksPanel.getRawCoordRadioButton().isSelected(); for (ChartPanel chartPanel : tracksChartPanels) { scaleAxes(chartPanel.getChart(), useRawData); } } }); // plot the raw tracks visualizeTracksPanel.getRawCoordRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem()); resetPlotLogic(); generateDataForPlots(true); // use the data to set the charts setChartsWithCollections(nCols); } }); // make the Rose plot: shift coordinates to origin (zero, zero) visualizeTracksPanel.getRosePlotRadioButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem()); resetPlotLogic(); generateDataForPlots(false); // use the data to set the charts setChartsWithCollections(nCols); } }); // replot with a different number of columns visualizeTracksPanel.getnColumnsComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem()); boolean useRawData = visualizeTracksPanel.getRawCoordRadioButton().isSelected(); resetPlotLogic(); generateDataForPlots(useRawData); // use the data to set the charts setChartsWithCollections(nCols); } }); visualizeTracksPanel.getDoNotScaleAxesRadioButton().setSelected(true); visualizeTracksPanel.getRawCoordRadioButton().setSelected(true); visualizeTracksPanel.getTracksGraphicsParentPanel().revalidate(); visualizeTracksPanel.getTracksGraphicsParentPanel().repaint(); // add view to parent controller loadTracksController.getMainFrame().getVisualizeTracksParentPanel().add(visualizeTracksPanel, gridBagConstraints); }
From source file:sim.app.sugarscape.util.ResultsGrapher.java
public void buildGraphics(XYSeries[] series) { JFrame j = new JFrame("Results for " + resultsfile); j.setSize(800, 1000);/*from w w w . j a v a 2s . c om*/ Container cp = j.getContentPane(); ChartPanel c1 = new ChartPanel(this.createChart1(series)); JFreeChart c = c1.getChart(); //3 lines below for version .92. Not sure how to do in 1.0.1 yet. //StandardLegend legend = (StandardLegend)c.getLegend(); //legend.setDisplaySeriesLines(true); //legend.setDisplaySeriesShapes(true); cp.add(c1); cp.setVisible(true); j.pack(); j.setVisible(true); //j.getContentPane(). }
From source file:com.rapidminer.gui.plotter.charts.ChartPanelShiftController.java
/** * Creates a new controller to handle plot shifts. * //from ww w . j a va 2s. c om * @param chartPanel * The panel displaying the plot. */ public ChartPanelShiftController(ChartPanel chartPanel) { super(); this.chartPanel = chartPanel; // Check to see if plot is shiftable Plot plot = chartPanel.getChart().getPlot(); if ((plot instanceof XYPlot) || (plot instanceof FastScatterPlot)) { plotSupported = true; axesSwaped = isHorizontalPlot(plot); } }
From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DHeatmapViewTopComponent.java
private Chromatogram1DHeatmapViewerPanel createPanel(ADataset2D<IChromatogram1D, IScan> ds) { XYPlot p = createPlot(ds);/*from w w w.j av a2 s .com*/ final PaintScale ps = ((XYBlockRenderer) p.getRenderer()).getPaintScale(); p.setDomainGridlinesVisible(false); p.setRangeGridlinesVisible(false); JFreeChart jfc = new JFreeChart(p); final ChartPanel cp = new ChartPanel(jfc, true); cp.setZoomFillPaint(new Color(192, 192, 192, 96)); cp.setZoomOutlinePaint(new Color(220, 220, 220, 192)); cp.setFillZoomRectangle(false); cp.getChart().getLegend().setVisible(true); Chromatogram1DHeatmapViewerPanel panel = new Chromatogram1DHeatmapViewerPanel(content, getLookup(), ds); if (panel.getBackgroundColor() == null) { panel.setBackgroundColor((Color) ps.getPaint(ps.getLowerBound())); } cp.addKeyListener(panel); cp.setFocusable(true); cp.setDisplayToolTips(true); cp.setDismissDelay(3000); cp.setInitialDelay(0); cp.setReshowDelay(0); cp.setVisible(true); cp.setRefreshBuffer(true); cp.setMouseWheelEnabled(true); //FIXME fix peak overlay // if (project != null) { // for (Peak1DContainer peaks : project.getPeaks(chromatogram)) { // Peak1DHeatmapOverlay overlay = new Peak1DHeatmapOverlay(chromatogram, peaks.getName(), peaks.getDisplayName(), peaks.getShortDescription(), true, peaks); // cp.addOverlay(overlay); // content.add(overlay); // } // } panel.setChartPanel(cp); if (ps != null) { panel.setPaintScale(ps); } panel.setPlot(p); return panel; }
From source file:net.sf.mzmine.chartbasics.graphicsexport.ChartExportUtil.java
/** * takes Only Width in account/*from ww w.j a v a2 s . c o m*/ * * @param chart * @param sett * @throws Exception */ public static void writeChartToImage(ChartPanel chart, GraphicsExportParameters sett) throws Exception { boolean repaint = false; FixedSize fixed = sett.getFixedSize(); double oldW = sett.getWidthPixel(); double oldH = sett.getHeightPixel(); // Size only by width? if (sett.isUseOnlyWidth()) { // fixed size for chart or plot if (fixed.equals(FixedSize.Chart)) { sett.setHeightPixel(ChartLogics.calcHeightToWidth(chart, oldW, false)); } else { // fixed plot width sett.setPixelSize(ChartLogics.calcSizeForPlotWidth(chart, oldW)); } } else if (fixed.equals(FixedSize.Plot)) { // fixed plot size - width and height are given sett.setPixelSize(ChartLogics.calcSizeForPlotSize(chart, oldW, oldH)); } Dimension size = sett.getPixelSize(); // resize chart.setPreferredSize(size); chart.setMaximumSize(size); chart.setMinimumSize(size); // repaint if (repaint) { chart.revalidate(); chart.repaint(); } writeChartToImage(chart.getChart(), sett, chart.getChartRenderingInfo()); // reset size sett.setPixelSize(oldW, oldH); }
From source file:net.sf.mzmine.chartbasics.ChartLogics.java
/** * Translates mouse coordinates to chart coordinates (xy-axis) * /*from www . j a v a 2 s . c om*/ * @param myChart * @param mouseX * @param mouseY * @return Range as chart coordinates * @throws Exception */ public static Point2D mouseXYToPlotXY(ChartPanel myChart, int mouseX, int mouseY) throws Exception { Point2D p = myChart.translateScreenToJava2D(new Point(mouseX, mouseY)); XYPlot plot = null; // find plot as parent of axis ChartEntity entity = findChartEntity(myChart, mouseX, mouseY); if (entity instanceof AxisEntity) { Axis a = ((AxisEntity) entity).getAxis(); if (a.getPlot() instanceof XYPlot) plot = (XYPlot) a.getPlot(); } ChartRenderingInfo info = myChart.getChartRenderingInfo(); int subplot = info.getPlotInfo().getSubplotIndex(p); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); if (subplot != -1) dataArea = info.getPlotInfo().getSubplotInfo(subplot).getDataArea(); if (plot == null) plot = findXYSubplot(myChart.getChart(), info, p.getX(), p.getY()); // coordinates double cx = 0; double cy = 0; if (plot != null) { // find axis ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis = plot.getRangeAxis(); RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); // parent? if (domainAxis == null && plot.getParent() != null && plot.getParent() instanceof XYPlot) { XYPlot pp = ((XYPlot) plot.getParent()); domainAxis = pp.getDomainAxis(); domainAxisEdge = pp.getDomainAxisEdge(); } if (rangeAxis == null && plot.getParent() != null && plot.getParent() instanceof XYPlot) { XYPlot pp = ((XYPlot) plot.getParent()); rangeAxis = pp.getRangeAxis(); rangeAxisEdge = pp.getRangeAxisEdge(); } if (domainAxis != null) cx = domainAxis.java2DToValue(p.getX(), dataArea, domainAxisEdge); if (rangeAxis != null) cy = rangeAxis.java2DToValue(p.getY(), dataArea, rangeAxisEdge); } else { throw new Exception("no xyplot found"); } return new Point2D.Double(cx, cy); }
From source file:jamel.gui.JamelWindow.java
/** * Exports a rapport.//from w w w .j a v a2 s.c om */ public void exportRapport() { final int max = tabbedPane.getTabCount(); final ProgressMonitor progressMonitor = new ProgressMonitor(this, "Exporting", "", 0, max); progressMonitor.setMillisToDecideToPopup(0); final String rc = System.getProperty("line.separator"); final File outputDirectory = new File("exports/" + this.getTitle() + "-" + (new Date()).getTime()); outputDirectory.mkdir(); try { final FileWriter writer = new FileWriter(new File(outputDirectory, "Rapport.html")); writer.write("<HTML>" + rc); writer.write("<HEAD>"); writer.write("<TITLE>" + this.getTitle() + "</TITLE>" + rc); writer.write("</HEAD>" + rc); writer.write("<BODY>" + rc); writer.write("<H1>" + this.getTitle() + "</H1>" + rc); writer.write("<HR>" + rc); final Date start = viewManager.getStart().getDate(); final Date end = viewManager.getEnd().getDate(); for (int tabIndex = 0; tabIndex < max; tabIndex++) { try { final JPanel currentTab = (JPanel) tabbedPane.getComponentAt(tabIndex); final String tabTitle = tabbedPane.getTitleAt(tabIndex); writer.write("<H2>" + tabTitle + "</H2>" + rc); writer.write("<TABLE>" + rc); final int chartPanelCount = currentTab.getComponentCount(); for (int chartIndex = 0; chartIndex < chartPanelCount; chartIndex++) { if ((chartIndex == 3) | (chartIndex == 6)) writer.write("<TR>" + rc); final ChartPanel aChartPanel = (ChartPanel) currentTab.getComponent(chartIndex); final JamelChart chart = (JamelChart) aChartPanel.getChart(); if (chart != null) { final String chartTitle = chart.getTitle().getText(); if (!chartTitle.equals("Empty")) { try { chart.setTitle(""); chart.setTimeRange(start, end); String imageName = (tabTitle + "-" + chartIndex + "-" + chartTitle + ".png") .replace(" ", "_").replace("&", "and"); ChartUtilities.saveChartAsPNG(new File(outputDirectory, imageName), chart, aChartPanel.getWidth(), aChartPanel.getHeight()); writer.write("<TD><IMG src=\"" + imageName + "\" title=\"" + chartTitle + "\">" + rc); chart.setTitle(chartTitle); } catch (IOException e) { e.printStackTrace(); } } } } writer.write("</TABLE>" + rc); writer.write("<HR>" + rc); } catch (ClassCastException e) { } progressMonitor.setProgress(tabIndex); } writer.write("<H2>Scenario</H2>" + rc); writer.write(this.consoleText.toString()); writer.write("</BODY>" + rc); writer.write("</HTML>" + rc); writer.close(); } catch (IOException e1) { e1.printStackTrace(); } progressMonitor.close(); }
From source file:edu.fullerton.viewerplugin.PluginSupport.java
/** * Create an image from the Chart Panel and add it the database * @param cp input plot//from w ww . ja v a 2s . co m * @return image ID of newly added row * @throws IOException * @throws SQLException * @throws NoSuchAlgorithmException */ public int saveImageAsPNG(ChartPanel cp) throws IOException, SQLException, NoSuchAlgorithmException { JFreeChart chart = cp.getChart(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(bos, chart, width, height); ImageTable itbl = new ImageTable(db); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); int imgId = itbl.addImg(vuser.getCn(), bis, "image/png"); return imgId; }
From source file:net.sf.maltcms.common.charts.api.overlay.SelectionOverlay.java
/** * * @param g2// ww w .j a va2 s. co m * @param chartPanel */ @Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { if (chartPanel.getChart().getAntiAlias()) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } boolean isXYPlot = true; if (chartPanel.getChart().getPlot() instanceof XYPlot) { isXYPlot = true; } else if (chartPanel.getChart().getPlot() instanceof CategoryPlot) { isXYPlot = false; } else { throw new IllegalArgumentException("Can only handle XYPlot and CategoryPlot!"); } if (isVisible()) { for (ISelection selection : mouseClickSelection) { if (selection.isVisible()) { Shape selectedEntity = null; if (isXYPlot) { selectedEntity = chartPanel.getChart().getXYPlot().getRenderer() .getItemShape(selection.getSeriesIndex(), selection.getItemIndex()); } else { selectedEntity = chartPanel.getChart().getCategoryPlot().getRenderer() .getItemShape(selection.getSeriesIndex(), selection.getItemIndex()); } if (selectedEntity == null) { selectedEntity = generate(selection.getDataset(), selection.getSeriesIndex(), selection.getItemIndex()); } updateCrosshairs(selection.getDataset(), selection.getSeriesIndex(), selection.getItemIndex()); Shape transformed = toView(selectedEntity, chartPanel, selection.getDataset(), selection.getSeriesIndex(), selection.getItemIndex()); drawEntity(transformed, g2, selectionFillColor, chartPanel, false); } } if (this.drawFlashSelection) { for (ISelection selection : flashSelection) { Shape selectedEntity = null; if (isXYPlot) { selectedEntity = chartPanel.getChart().getXYPlot().getRenderer() .getItemShape(selection.getSeriesIndex(), selection.getItemIndex()); } else { selectedEntity = chartPanel.getChart().getCategoryPlot().getRenderer() .getItemShape(selection.getSeriesIndex(), selection.getItemIndex()); } if (selectedEntity == null) { selectedEntity = generate(selection.getDataset(), selection.getSeriesIndex(), selection.getItemIndex()); } Shape transformed = toView(selectedEntity, chartPanel, selection.getDataset(), selection.getSeriesIndex(), selection.getItemIndex()); drawEntity(transformed, g2, selectionFillColor.darker(), chartPanel, true); } } if (this.mouseHoverSelection != null && this.mouseHoverSelection.isVisible()) { Shape entity = null; if (isXYPlot) { entity = chartPanel.getChart().getXYPlot().getRenderer() .getItemShape(mouseHoverSelection.getSeriesIndex(), mouseHoverSelection.getItemIndex()); } else { entity = chartPanel.getChart().getCategoryPlot().getRenderer() .getItemShape(mouseHoverSelection.getSeriesIndex(), mouseHoverSelection.getItemIndex()); } if (entity == null) { entity = generate(mouseHoverSelection.getDataset(), mouseHoverSelection.getSeriesIndex(), mouseHoverSelection.getItemIndex()); } Shape transformed = toView(entity, chartPanel, mouseHoverSelection.getDataset(), mouseHoverSelection.getSeriesIndex(), mouseHoverSelection.getItemIndex()); drawEntity(transformed, g2, hoverFillColor, chartPanel, true); } } if (isXYPlot) { crosshairOverlay.paintOverlay(g2, chartPanel); } }
From source file:lu.lippmann.cdb.ext.hydviga.ui.GapFillingKnowledgeDBExplorerFrame.java
/** * Constructor.// w w w . jav a 2 s . co m */ GapFillingKnowledgeDBExplorerFrame(final Instances ds, final int dateIdx, final StationsDataProvider gcp) throws Exception { LogoHelper.setLogo(this); this.setTitle("KnowledgeDB: explorer"); this.gcp = gcp; this.tablePanel = new JXPanel(); this.tablePanel.setBorder(new TitledBorder("Cases")); final JXPanel highPanel = new JXPanel(); highPanel.setLayout(new BoxLayout(highPanel, BoxLayout.X_AXIS)); highPanel.add(this.tablePanel); this.geomapPanel = new JXPanel(); this.geomapPanel.add(buildGeoMapChart(new ArrayList<String>(), new ArrayList<String>())); highPanel.add(this.geomapPanel); this.caseChartPanel = new JXPanel(); this.caseChartPanel.setBorder(new TitledBorder("Inspected fake gap")); this.mostSimilarChartPanel = new JXPanel(); this.mostSimilarChartPanel.setBorder(new TitledBorder("Most similar")); this.nearestChartPanel = new JXPanel(); this.nearestChartPanel.setBorder(new TitledBorder("Nearest")); this.downstreamChartPanel = new JXPanel(); this.downstreamChartPanel.setBorder(new TitledBorder("Downstream")); this.upstreamChartPanel = new JXPanel(); this.upstreamChartPanel.setBorder(new TitledBorder("Upstream")); getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS)); //getContentPane().add(new JCheckBox("Use incomplete series")); getContentPane().add(highPanel); //getContentPane().add(new JXButton("Export")); getContentPane().add(caseChartPanel); getContentPane().add(mostSimilarChartPanel); getContentPane().add(nearestChartPanel); getContentPane().add(downstreamChartPanel); getContentPane().add(upstreamChartPanel); //final Instances kdbDS=GapFillingKnowledgeDB.getKnowledgeDBWithBestCasesOnly(); final Instances kdbDS = GapFillingKnowledgeDB.getKnowledgeDB(); final JXTable gapsTable = buidJXTable(kdbDS); final JScrollPane tableScrollPane = new JScrollPane(gapsTable); tableScrollPane.setPreferredSize( new Dimension(COMPONENT_WIDTH - 100, 40 + (int) (tableScrollPane.getPreferredSize().getHeight()))); this.tablePanel.add(tableScrollPane); gapsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); gapsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final int modelRow = gapsTable.getSelectedRow(); final String attrname = gapsTable.getModel().getValueAt(modelRow, 1).toString(); final int gapsize = (int) Double .valueOf(gapsTable.getModel().getValueAt(modelRow, 4).toString()).doubleValue(); final int position = (int) Double .valueOf(gapsTable.getModel().getValueAt(modelRow, 5).toString()).doubleValue(); final String mostSimilarFlag = gapsTable.getModel().getValueAt(modelRow, 14).toString(); final String nearestFlag = gapsTable.getModel().getValueAt(modelRow, 15).toString(); final String downstreamFlag = gapsTable.getModel().getValueAt(modelRow, 16).toString(); final String upstreamFlag = gapsTable.getModel().getValueAt(modelRow, 17).toString(); final String algoname = gapsTable.getModel().getValueAt(modelRow, 12).toString(); final boolean useDiscretizedTime = Boolean .valueOf(gapsTable.getModel().getValueAt(modelRow, 13).toString()); try { geomapPanel.removeAll(); caseChartPanel.removeAll(); mostSimilarChartPanel.removeAll(); nearestChartPanel.removeAll(); downstreamChartPanel.removeAll(); upstreamChartPanel.removeAll(); final Set<String> selected = new HashSet<String>(); final Instances tmpds = WekaDataProcessingUtil.buildFilteredDataSet(ds, 0, ds.numAttributes() - 1, Math.max(0, position - GapsUtil.getCountOfValuesBeforeAndAfter(gapsize)), Math.min(position + gapsize + GapsUtil.getCountOfValuesBeforeAndAfter(gapsize), ds.numInstances() - 1)); final List<String> attributeNames = WekaTimeSeriesUtil .getNamesOfAttributesWithoutGap(tmpds); //final List<String> attributeNames=WekaDataStatsUtil.getAttributeNames(ds); attributeNames.remove(attrname); attributeNames.remove("timestamp"); if (Boolean.valueOf(mostSimilarFlag)) { final String mostSimilarStationName = WekaTimeSeriesSimilarityUtil .findMostSimilarTimeSerie(tmpds, tmpds.attribute(attrname), attributeNames, false); selected.add(mostSimilarStationName); final Attribute mostSimilarStationAttr = tmpds.attribute(mostSimilarStationName); final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx, mostSimilarStationAttr, gapsize, position); cp0.getChart().removeLegend(); cp0.setPreferredSize(CHART_DIMENSION); mostSimilarChartPanel.add(cp0); } if (Boolean.valueOf(nearestFlag)) { final String nearestStationName = gcp.findNearestStation(attrname, attributeNames); selected.add(nearestStationName); final Attribute nearestStationAttr = ds.attribute(nearestStationName); final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx, nearestStationAttr, gapsize, position); cp0.getChart().removeLegend(); cp0.setPreferredSize(CHART_DIMENSION); nearestChartPanel.add(cp0); } if (Boolean.valueOf(downstreamFlag)) { final String downstreamStationName = gcp.findDownstreamStation(attrname, attributeNames); selected.add(downstreamStationName); final Attribute downstreamStationAttr = ds.attribute(downstreamStationName); final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx, downstreamStationAttr, gapsize, position); cp0.getChart().removeLegend(); cp0.setPreferredSize(CHART_DIMENSION); downstreamChartPanel.add(cp0); } if (Boolean.valueOf(upstreamFlag)) { final String upstreamStationName = gcp.findUpstreamStation(attrname, attributeNames); selected.add(upstreamStationName); final Attribute upstreamStationAttr = ds.attribute(upstreamStationName); final ChartPanel cp0 = GapsUIUtil.buildGapChartPanel(ds, dateIdx, upstreamStationAttr, gapsize, position); cp0.getChart().removeLegend(); cp0.setPreferredSize(CHART_DIMENSION); upstreamChartPanel.add(cp0); } final GapFiller gapFiller = GapFillerFactory.getGapFiller(algoname, useDiscretizedTime); final ChartPanel cp = GapsUIUtil.buildGapChartPanelWithCorrection(ds, dateIdx, ds.attribute(attrname), gapsize, position, gapFiller, selected); cp.getChart().removeLegend(); cp.setPreferredSize(new Dimension((int) CHART_DIMENSION.getWidth(), (int) (CHART_DIMENSION.getHeight() * 1.5))); caseChartPanel.add(cp); geomapPanel.add(buildGeoMapChart(Arrays.asList(attrname), selected)); getContentPane().repaint(); pack(); } catch (Exception e1) { e1.printStackTrace(); } } } }); gapsTable.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(final MouseEvent e) { if (!e.isPopupTrigger()) { // nothing? } else { final JPopupMenu jPopupMenu = new JPopupMenu("feur"); final JMenuItem mExport = new JMenuItem("Export this table as CSV"); mExport.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final JFileChooser fc = new JFileChooser(); fc.setAcceptAllFileFilterUsed(false); final int returnVal = fc.showSaveDialog(gapsTable); if (returnVal == JFileChooser.APPROVE_OPTION) { try { final File file = fc.getSelectedFile(); WekaDataAccessUtil.saveInstancesIntoCSVFile(kdbDS, file); } catch (Exception ee) { ee.printStackTrace(); } } } }); jPopupMenu.add(mExport); jPopupMenu.show(gapsTable, e.getX(), e.getY()); } } }); setPreferredSize(new Dimension(FRAME_WIDTH, 1000)); pack(); setVisible(true); /* select the first row */ gapsTable.setRowSelectionInterval(0, 0); }