List of usage examples for org.jfree.chart ChartFactory createXYLineChart
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:com.joey.software.plottingToolkit.PlotingToolkit.java
public static JFreeChart getPlot(float[] yData, String title, String xlabel, String ylabel) { float[] xData = getXDataFloat(yData.length); XYSeriesCollection datCol = getCollection(xData, yData, "Data"); // Create the chart JFreeChart chart = ChartFactory.createXYLineChart(title, // Title xlabel, // X-Axis label ylabel, // Y-Axis label new XYSeriesCollection(), // Dataset PlotOrientation.VERTICAL, true, // Show legend true, true);/*w ww . j av a 2 s . c o m*/ // Add the series chart.getXYPlot().setDataset(0, datCol); // Set the rendering XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true); chart.getXYPlot().setRenderer(0, rend1); return chart; }
From source file:window.view.VueCourbe.java
/** * Cree la courbe/*from w w w.ja v a2 s . c om*/ * @param dataset donnees de la courbe * @param title titre de la courbe * @return la courbe correspondant aux donnees */ private JFreeChart createChart(DefaultXYDataset dataset, String title) { // Create the chart JFreeChart chart = ChartFactory.createXYLineChart(title, // The chart title "Nb itrations", // x axis label "Dist. euclidienne", // y axis label dataset, // The dataset for the chart PlotOrientation.VERTICAL, false, // Is a legend required? false, // Use tooltips false // Configure chart to generate URLs? ); return chart; }
From source file:opensonata.dataDisplays.BaselineImage.java
private JFreeChart createChart(String inFilename, String userTitle, NssBaseline nssBaseline) { XYSeries series = new XYSeries(""); float[] baselineValues = nssBaseline.getBaselineValues(); // plot subband values for (int i = 0; i < baselineValues.length; i++) { series.add(i, baselineValues[i]); }/*from ww w. j av a 2s .c om*/ System.err.println("HERE!!!!"); // add a final point at the end with a zero Y value, series.add(baselineValues.length, 0.0); XYDataset data = new XYSeriesCollection(series); String inFilenameBase = new File(inFilename).getName(); DecimalFormat freqFormatter = new DecimalFormat("0000.000 MHz "); String freqString = freqFormatter.format(nssBaseline.getCenterFreqMhz()); DecimalFormat bandwidthFormatter = new DecimalFormat("0.00 MHz "); String bandwidthString = bandwidthFormatter.format(nssBaseline.getBandwidthMhz()); String mainTitle = ""; String xAxisLabel = "Subband"; String yAxisLabel = "Power"; JFreeChart chart = ChartFactory.createXYLineChart(mainTitle, xAxisLabel, yAxisLabel, data, PlotOrientation.VERTICAL, false, // legend true, // tooltips false // urls ); String subTitle1 = "Baseline: "; if (!userTitle.equals("")) { subTitle1 += userTitle; } else { subTitle1 += inFilenameBase; } chart.addSubtitle(new TextTitle(subTitle1)); String subTitle2 = "Center Freq: " + freqString + "Bandwidth: " + bandwidthString; chart.addSubtitle(new TextTitle(subTitle2)); // move the data off of the axes // by extending the minimum axis value XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot(); double axisMarginPercent = 0.02; NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); return chart; }
From source file:logica_controladores.controlador_estadistica.java
public static void grafica_reorden(JPanel panel_grafica_orden, Inventario inventario, JLabel lbLinea) { XYSeries serie_2 = null;/* w ww. ja v a 2 s.co m*/ XYDataset datos; JFreeChart linea; serie_2 = new XYSeries("graficas relacion gastos-reorden"); for (int i = 0; i < inventario.getGastos().size(); i++) { serie_2.add(inventario.getGastos().get(i).getReorden(), inventario.getGastos().get(i).getGastos()); } datos = new XYSeriesCollection(serie_2); linea = ChartFactory.createXYLineChart("grafica representativa de reordenes por corrida", "punto de orden", "gastos", datos, PlotOrientation.VERTICAL, true, true, true); BufferedImage graficoLinea = linea.createBufferedImage(panel_grafica_orden.getWidth(), panel_grafica_orden.getHeight()); lbLinea.setSize(panel_grafica_orden.getSize()); lbLinea.setIcon(new ImageIcon(graficoLinea)); panel_grafica_orden.updateUI(); }
From source file:net.sf.mzmine.modules.visualization.ida.IDAPlot.java
IDAPlot(final ActionListener listener, RawDataFile rawDataFile, IDAVisualizerWindow visualizer, IDADataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(null, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );//from ww w.j ava2s .c om chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new IDAPlotRenderer(); plot.setRenderer(0, mainRenderer); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // Add EMF and EPS options to the save as menu JPopupMenu popupMenu = getPopupMenu(); JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3); GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF"); GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS"); // Register for mouse-wheel events addMouseWheelListener(this); }
From source file:net.sf.mzmine.modules.visualization.msms.MsMsPlot.java
MsMsPlot(final ActionListener listener, RawDataFile rawDataFile, MsMsVisualizerWindow visualizer, MsMsDataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(null, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );//ww w. ja va 2s . c om chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new MsMsPlotRenderer(); plot.setRenderer(0, mainRenderer); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // Add EMF and EPS options to the save as menu JPopupMenu popupMenu = getPopupMenu(); JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3); GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF"); GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS"); // Register for mouse-wheel events addMouseWheelListener(this); }
From source file:syg_package01.PanelRysunek_Wykres.java
private void initGUI() { try {// www. j a v a 2s . c o m GridLayout thisLayout = new GridLayout(1, 1); thisLayout.setHgap(5); thisLayout.setVgap(5); thisLayout.setColumns(1); this.setLayout(thisLayout); setPreferredSize(new Dimension(400, 300)); if (this.wykres) { XYSeries series = new XYSeries("Wykres"); double punkt; double ta = this.sygnalWyswietlany.gett1(); if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY || sygnalWyswietlany.getPunktyY().size() <= 0) { punkt = this.sygnalWyswietlany.gett1(); while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) { punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta); this.sygnalWyswietlany.setPunktyY(punkt); series.add(ta, punkt); if (this.sygnalWyswietlany.gettyp() < 10) ta = ta + this.sygnalWyswietlany.getkroczek(); else ta = ta + this.sygnalWyswietlany.getkroczek() * 10; } } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY && sygnalWyswietlany.getPunktyY().size() > 0) { punkt = sygnalWyswietlany.getPunktzindexu(0); int iloscProbek = (int) (this.sygnalWyswietlany.getPunktyY().size()); for (int i = 1; i < iloscProbek; i++) { punkt = this.sygnalWyswietlany.getPunktzindexu(i); series.add(ta, punkt); // if (this.sygnalWyswietlany.gettyp() < 10) // ta = ta + this.sygnalWyswietlany.getkroczek(); // else ta = ta + this.sygnalWyswietlany.getkroczek(); } } XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart; if ((this.sygnalWyswietlany.gettyp() < 10) && (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY)) { chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, true, true); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); } else { chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, true, true); final XYPlot plot = chart.getXYPlot(); final XYDotRenderer renderer = new XYDotRenderer(); renderer.setDotHeight(3); renderer.setDotWidth(3); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } ChartPanel chartpanel = new ChartPanel(chart); chartpanel.setDomainZoomable(true); this.add(chartpanel); } Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.che.software.testato.business.SelectiveChartManager.java
/** * Creates a selective chart from a set of scripts related to 2 criterions. * Excluded values are optionals and will be created as a different set of * points. This allow to colored them in red in following steps. * //w w w . j ava 2 s . c o m * @author Clement HELIOU (clement.heliou@che-software.com). * @param xValues the x axis values list. * @param yValues the y axis values list. * @param title the title to give to the line chart. * @param xLabel the criterion label to display on the x axis. * @param yLabel the criterion label to display on the y axis. * @param xExcludedValues the x axis excluded values. * @param yExcludedValues the y axis excluded values. * @return the resulting chart. * @since August, 2011. */ public JFreeChart createSelectiveChart(List<MatrixResult> xValues, List<MatrixResult> yValues, String title, String xLabel, String yLabel, List<MatrixResult> xExcludedValues, List<MatrixResult> yExcludedValues) { LOGGER.debug("createSelectiveChart(" + xLabel + "," + yLabel + "," + xValues.size() + "," + yValues.size() + ")."); XYSeries notExcludedData = new XYSeries("1"), excludedData = new XYSeries("2"), lowMediumLine = new XYSeries("3"), mediumHighLine = new XYSeries("4"); for (int i = 0; i < xValues.size(); i++) { notExcludedData.add(yValues.get(i).getPercentage() * 100, xValues.get(i).getPercentage() * 100); } if (null != xExcludedValues) { for (int j = 0; j < xExcludedValues.size(); j++) { excludedData.add(yExcludedValues.get(j).getPercentage() * 100, xExcludedValues.get(j).getPercentage() * 100); } } double maxAbscissaValue = LineChartGraphistUtil.getMaxAbscissaValue(xValues, xExcludedValues) + 2; lowMediumLine.add(0, 0); lowMediumLine.add(0.5 * maxAbscissaValue, maxAbscissaValue); mediumHighLine.add(0, 0); mediumHighLine.add(1.5 * maxAbscissaValue, maxAbscissaValue); XYSeriesCollection dataSet = new XYSeriesCollection(); dataSet.addSeries(notExcludedData); dataSet.addSeries(excludedData); dataSet.addSeries(lowMediumLine); dataSet.addSeries(mediumHighLine); return ChartFactory.createXYLineChart(title, xLabel, yLabel, dataSet, PlotOrientation.HORIZONTAL, false, true, false); }
From source file:msi.gama.hpc.gui.perspective.chart.HeadlessChart.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart from XML output file", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/*ww w .j av a2s . co m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperXYChart.java
protected JFreeChart createLegend(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // url );/* w w w . jav a 2 s . c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }