List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(Plot plot)
From source file:de.cebitec.readXplorer.plotting.CreatePlots.java
private synchronized static JFreeChart createCombinedChart(XYSeriesCollection normal, XYSeriesCollection posInf, XYSeriesCollection negInf, String xName, String yName, XYToolTipGenerator toolTip) { final NumberAxis domainAxis = new NumberAxis(xName); // create subplot 1... final XYDataset data1 = normal; final XYItemRenderer renderer1 = new XYShapeRenderer(); renderer1.setBaseToolTipGenerator(toolTip); final NumberAxis rangeAxis1 = new NumberAxis(yName); final XYPlot subplot1 = new XYPlot(data1, domainAxis, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // create subplot 2... final XYDataset data2 = negInf; final XYItemRenderer renderer2 = new XYShapeRenderer(); renderer2.setBaseToolTipGenerator(toolTip); final NumberAxis rangeAxis2 = new NumberAxis() { @Override/*from w ww .j av a 2 s .c om*/ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List myTicks = new ArrayList(); myTicks.add(new NumberTick(0, "-Inf", TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0)); return myTicks; } }; rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, domainAxis, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // create subplot 3... final XYDataset data3 = posInf; final XYItemRenderer renderer3 = new XYShapeRenderer(); renderer3.setBaseToolTipGenerator(toolTip); final NumberAxis rangeAxis3 = new NumberAxis() { @Override public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List myTicks = new ArrayList(); myTicks.add(new NumberTick(0, "Inf", TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0)); return myTicks; } }; rangeAxis3.setAutoRangeIncludesZero(false); final XYPlot subplot3 = new XYPlot(data3, domainAxis, rangeAxis3, renderer3); subplot2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domainAxis); plot.setGap(0); // add the subplots... plot.add(subplot3, 1); plot.add(subplot1, 10); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart(plot); }
From source file:JQGraphicModule.QueryTableApp.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: ChartPanel panel;/*w ww . j ava2s .c o m*/ JFreeChart chart = null; if (l.isSelected()) { // linear chart int validar = 1; XYSplineRenderer renderer = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries serie = new XYSeries("Data"); XYPlot plot; lineas.removeAll(); try { for (int f = 0; f < 6; f++) { serie.add(Float.parseFloat(String.valueOf(datos.getValueAt(f, 0))), Float.parseFloat(String.valueOf(datos.getValueAt(f, 1)))); } } catch (Exception e) { validar = 0; System.out.println("Cannot create data series for line graph"); } // end catch if (validar == 1) { dataset.addSeries(serie); plot = new XYPlot(dataset, x, y, rederer); chart = new JFreeChart(plot); chart.setTitle("Line chart"); } else { JOptionPane.showMessageDialog(this, "You should fill the table with data"); } } else { if (b.isSelected()) { // bar chart DefaultCategoryDataset data = new DefaultCategoryDataset(); // TODO: finish the bar chart } else { // pir chart } // end else } panel = new ChartPanel(chart); panel.setBounds(5, 10, 410, 350); if (l.isSelected()) { lineas.add(panel); lineas.repaint(); } else { if (b.isSelected()) { //bar chart } //end if else { // pie chart } // end else } //end else }
From source file:de.dal33t.powerfolder.ui.information.stats.StatsInformationCard.java
private JPanel getAveragePanel() { DateAxis domain = new DateAxis(Translation.getTranslation("stats_information_card.date")); TimeSeriesCollection series = new TimeSeriesCollection(); NumberAxis axis = new NumberAxis(Translation.getTranslation("stats_information_card.percentage")); series.addSeries(percentageBandwidthSeries); XYItemRenderer renderer = new StandardXYItemRenderer(); XYPlot plot = new XYPlot(series, domain, axis, renderer); JFreeChart graph = new JFreeChart(plot); ChartPanel cp = new ChartPanel(graph); FormLayout layout = new FormLayout("3dlu, fill:pref:grow, 3dlu", "3dlu, pref , 3dlu, pref, 3dlu, fill:pref:grow, 3dlu"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); CellConstraints cc = new CellConstraints(); JPanel p = buildPercentStatsControlPanel(); builder.add(p, cc.xy(2, 2));//from w w w. ja v a 2s . c o m builder.addSeparator(null, cc.xyw(1, 4, 3)); builder.add(cp, cc.xy(2, 6)); return builder.getPanel(); }
From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java
/** * Create a snp interval histogram without any axes * @param intervals/*ww w.j a v a 2 s . c o m*/ * the intervals to use * @param startInBasePairs * where should we start the graph? * @param extentInBasePairs * how far should the graph extend * @param visualInterval * the visual interval to use * @return * the histogram */ public JFreeChart createSnpIntervalHistogram(final List<? extends RealValuedBasePairInterval> intervals, final long startInBasePairs, final long extentInBasePairs, final HighlightedSnpInterval visualInterval) { // create the axes NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRangeIncludesZero(false); xAxis.setRange(new Range(startInBasePairs, startInBasePairs + extentInBasePairs)); NumberAxis yAxis = new NumberAxis(); // hide the axes xAxis.setVisible(false); yAxis.setVisible(false); // create the plot XYPlot plot = this.createSnpIntervalHistogramPlot(intervals, visualInterval, xAxis, yAxis); // more hiding plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); // create the final chart JFreeChart histogram = new JFreeChart(plot); histogram.removeLegend(); return histogram; }
From source file:com.romraider.logger.ecu.ui.handler.dash.DialGaugeStyle.java
protected JFreeChart buildChart() { DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0);/*from w w w . j a v a2 s.c o m*/ plot.setDataset(0, current); plot.setDataset(1, max); plot.setDataset(2, min); DialFrame dialFrame = new StandardDialFrame(); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer(new StandardGradientPaintTransformer(VERTICAL)); plot.setBackground(db); unitsLabel.setFont(new Font(Font.DIALOG, BOLD, 15)); unitsLabel.setRadius(0.7); unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits()); plot.addLayer(unitsLabel); DecimalFormat format = new DecimalFormat(loggerData.getSelectedConvertor().getFormat()); DialValueIndicator dvi = new DialValueIndicator(0); dvi.setNumberFormat(format); plot.addLayer(dvi); EcuDataConvertor convertor = loggerData.getSelectedConvertor(); GaugeMinMax minMax = convertor.getGaugeMinMax(); StandardDialScale scale = new StandardDialScale(minMax.min, minMax.max, 225.0, -270.0, minMax.step, 5); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); scale.setTickLabelFont(new Font(Font.DIALOG, PLAIN, 12)); scale.setTickLabelFormatter(format); plot.addScale(0, scale); plot.addScale(1, scale); plot.addScale(2, scale); StandardDialRange range = new StandardDialRange(rangeLimit(minMax, 0.75), minMax.max, RED); range.setInnerRadius(0.52); range.setOuterRadius(0.55); plot.addLayer(range); StandardDialRange range2 = new StandardDialRange(rangeLimit(minMax, 0.5), rangeLimit(minMax, 0.75), ORANGE); range2.setInnerRadius(0.52); range2.setOuterRadius(0.55); plot.addLayer(range2); StandardDialRange range3 = new StandardDialRange(minMax.min, rangeLimit(minMax, 0.5), GREEN); range3.setInnerRadius(0.52); range3.setOuterRadius(0.55); plot.addLayer(range3); DialPointer needleCurrent = new DialPointer.Pointer(0); plot.addLayer(needleCurrent); DialPointer needleMax = new DialPointer.Pin(1); needleMax.setRadius(0.84); ((DialPointer.Pin) needleMax).setPaint(RED); ((DialPointer.Pin) needleMax).setStroke(new BasicStroke(1.5F)); plot.addLayer(needleMax); DialPointer needleMin = new DialPointer.Pin(2); needleMin.setRadius(0.84); ((DialPointer.Pin) needleMin).setPaint(BLUE); ((DialPointer.Pin) needleMin).setStroke(new BasicStroke(1.5F)); plot.addLayer(needleMin); DialCap cap = new DialCap(); cap.setRadius(0.10); plot.setCap(cap); JFreeChart chart = new JFreeChart(plot); chart.setTitle(loggerData.getName()); return chart; }