List of usage examples for org.jfree.chart ChartPanel setDisplayToolTips
public void setDisplayToolTips(boolean flag)
From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java
public static ChartPanel CreateChartPanel(XYDataset dataset, Color[] colors) { XYPlot xy = createXYPlot(dataset, colors); JFreeChart chart = new JFreeChart(xy); ChartPanel chartPanel = new SpectrumChartPanel(chart); chartPanel.setDisplayToolTips(true); chartPanel.setMouseZoomable(true);/*from w ww .jav a 2s . co m*/ // Remove the autogenerated subtitle if (chart.getSubtitleCount() == 1) chart.removeSubtitle(chart.getSubtitle(chart.getSubtitleCount() - 1)); return chartPanel; }
From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java
public static ChartPanel CreateChartPanel(java.util.List datasets, Color[] colors) { if (datasets.size() == 1) return CreateChartPanel((XYSeriesCollection) datasets.get(0), colors); CombinedDomainXYPlot combined = new CombinedDomainXYPlot(); for (Iterator it = datasets.iterator(); it.hasNext();) { XYSeriesCollection series = (XYSeriesCollection) it.next(); XYPlot xy = createXYPlot(series, colors); combined.add(xy);// w ww. j ava2 s.com } NumberAxis axisDomain = new NumberAxis(); axisDomain.setAutoRangeIncludesZero(false); // axisDomain.setRange(400.0, 1600.0); combined.setDomainAxis(axisDomain); JFreeChart chart = new JFreeChart(combined); ChartPanel chartPanel = new SpectrumChartPanel(chart); chartPanel.setDisplayToolTips(true); chartPanel.setMouseZoomable(true); // Remove the autogenerated subtitle if (chart.getSubtitleCount() == 1) chart.removeSubtitle(chart.getSubtitle(chart.getSubtitleCount() - 1)); return chartPanel; }
From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java
public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) { super(new BorderLayout()); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(1.0);/*from w w w . jav a2 s .c o m*/ xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(1.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { XYZDataset xyzDataset = (XYZDataset) dataset; double x = xyzDataset.getXValue(series, item); double y = xyzDataset.getYValue(series, item); double z = xyzDataset.getZValue(series, item); return ("X=" + x + ", Y=" + y + ", Z=" + z); } }); PaintScale scale = new ColorPaintScale(lowerBound, upperBound); renderer.setPaintScale(scale); ValueAxis axis = new NumberAxis(); axis.setLowerBound(scale.getLowerBound()); axis.setUpperBound(scale.getUpperBound()); PaintScaleLegend legend = new PaintScaleLegend(scale, axis); legend.setMargin(new RectangleInsets(10, 10, 10, 10)); legend.setPosition(RectangleEdge.RIGHT); MatrixXYDataset dataset = new MatrixXYDataset(m); plot = new XYPlot(dataset, xAxis, yAxis, renderer); chart = new JFreeChart(plot); chart.removeLegend(); chart.addSubtitle(legend); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDisplayToolTips(true); this.add(chartPanel, BorderLayout.CENTER); }
From source file:jmemorize.gui.swing.panels.CardCounterPanel.java
private ChartPanel buildPiePanel() { JFreeChart chart = ChartFactory.createPieChart(null, m_pieDataset, true, false, false); setupPiePlot((PiePlot) chart.getPlot()); setupPieLegend(chart);//from w ww . ja va2s . c o m ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDisplayToolTips(false); /* * RED_FLAG this is a WORKAROUND TO a JFreeChart bug (as of 1.0.4) which * causes an affine transform to be applied to charts smaller than * 300x200. If the minimum sizes are not set to the same value, the * chart and legend are scaled by the proprtion! see * http://www.jfree.org/phpBB2/viewtopic.php?t=16972 */ chartPanel.setMinimumDrawHeight(300); chartPanel.setMinimumDrawWidth(300); return chartPanel; }
From source file:fi.smaa.jsmaa.gui.views.CriterionView.java
private JPanel buildValueFunctionChartPanel(ScaleCriterion criterion) { UtilityFunctionDataset dataset = new UtilityFunctionDataset(criterion); JFreeChart chart = ChartFactory.createXYLineChart("", "x", "v(x)", dataset, PlotOrientation.VERTICAL, false, true, true);/*from www . j a va 2 s . c o m*/ final XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(0, renderer); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3.0f)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); ValueAxis rAxis = plot.getRangeAxis(); rAxis.setAutoRange(false); rAxis.setRange(new Range(-0.03, 1.03)); ValueAxis dAxis = plot.getDomainAxis(); dAxis.setLowerMargin(0.03); dAxis.setUpperMargin(0.03); ChartPanel chartPanel = new ChartPanel(chart, false, true, true, false, true); chartPanel.addChartMouseListener(new ValueFunctionMouseListener(chartPanel, criterion, parent)); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); chartPanel.setDisplayToolTips(true); chartPanel.setToolTipText("Click to add/remove partial value function points"); chartPanel.setMouseWheelEnabled(false); chartPanel.setMouseZoomable(false); plot.setDomainCrosshairLockedOnData(false); plot.setRangeCrosshairLockedOnData(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); FormLayout layout = new FormLayout("left:pref", "p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); builder.add(chartPanel, cc.xy(1, 1)); builder.add(new ValueFunctionPointsPanel(criterion), cc.xy(1, 3)); return builder.getPanel(); }
From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DHeatmapViewTopComponent.java
private Chromatogram1DHeatmapViewerPanel createPanel(ADataset2D<IChromatogram1D, IScan> ds) { XYPlot p = createPlot(ds);//from w ww .j a va 2 s . c om 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; }